s4

diff s4-funcs.sh @ 893:c1a5d137740d

Display momentary information of frozen state change
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 26 Dec 2020 15:17:56 +0900
parents 7ca1f11ab5e8
children c01b13db3bd3
line diff
     1.1 --- a/s4-funcs.sh	Tue Dec 22 10:58:03 2020 +0900
     1.2 +++ b/s4-funcs.sh	Sat Dec 26 15:17:56 2020 +0900
     1.3 @@ -2868,10 +2868,18 @@
     1.4  	EOF
     1.5    cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by 稼動状態, ctime desc"
     1.6    colstate="state:稼動状態:frozen=rowclass=凍結"
     1.7 +  frzbtn='<button class="toggle-frozen"></button>'
     1.8    DT_CHLD=article:blogid \
     1.9  	 DT_QOWNER="$qgrp" \
    1.10  	 DT_VIEW=replyblog dumptable html blog \
    1.11 -	 "ctime title heading team notify:通知$colmd $colstate" "$cond"
    1.12 +	 "ctime title heading team notify:通知$colmd $colstate" "$cond" \
    1.13 +    | if [ -n "$iamowner" ]
    1.14 +  then
    1.15 +    sed -Ee "s,(<TD class=\"稼動状態\">).*(</TD>),\1$frzbtn\2,"
    1.16 +  else
    1.17 +    cat
    1.18 +  fi
    1.19 +  ## DO not convert to frzbtn when not admin
    1.20    echo "</div>  <!-- in showgroupsub -->"
    1.21  
    1.22    getgname="(select gname from grp where rowid=$rowid)"
    1.23 @@ -3724,6 +3732,11 @@
    1.24      showgroup $grid
    1.25    done
    1.26  }
    1.27 +dt_colhack() {
    1.28 +  # FROM: <TD>xxx:yyy</TD>
    1.29 +  # TO:   <TD class="xxx">yyy</TD>
    1.30 +  sed -Ee 's,<TD>([^:<"]+):([^<]*)(</TD>|$),<TD class="\1">\2\3,g'
    1.31 +}
    1.32  dt_rowhack() {
    1.33    # From: <TR>
    1.34    #        ....
    1.35 @@ -3737,7 +3750,7 @@
    1.36  	  N
    1.37  	  /<\/TR>/ {
    1.38  	    s/\n//
    1.39 -	    s,^<TR>\(.*\)<TD>rowclass=\(.*\)\(</TD></TR>\),<TR class="\2">\1<TD>\2\3,
    1.40 +	    s,^<TR>\(.*\)<TD\([^>]*\)>rowclass=\(.*\)\(</TD></TR>\),<TR class="\3">\1<TD\2>\3\4,
    1.41  	    n
    1.42  	  }
    1.43  	  $q
    1.44 @@ -3826,6 +3839,11 @@
    1.45    substr=${substr:-%s}
    1.46    for col in ${3:-`gettbl_s_cols $2`}; do
    1.47      valvar=val
    1.48 +    fromtbl=b
    1.49 +    if gettblcols "$2" | grep -w "$col" >/dev/null 2>&1; then
    1.50 +      # If $col belongs to master table
    1.51 +      fromtbl=a; col=${col#a.}
    1.52 +    fi
    1.53      case $col in
    1.54        gecos)	scols="$scols${scols:+, }${col#}"
    1.55  		continue ;;	# built-in column name
    1.56 @@ -3836,15 +3854,23 @@
    1.57  			 h=${cnd%%=*} v=${cnd#*=}
    1.58  			 h=`sqlquotestr "$h"`
    1.59  			 v=`sqlquotestr "$v"`
    1.60 -			 valvar="CASE val WHEN $h THEN $v END"
    1.61 +			 if [ x"$fromtbl" = x"b" ]; then
    1.62 +			   valvar="CASE val WHEN $h THEN $v END"
    1.63 +			 else
    1.64 +			   valvar="$h"
    1.65 +			 fi
    1.66  			 as=${as%%:*} ;;
    1.67  		esac
    1.68  		;;
    1.69        *)	as=${col} ;;
    1.70      esac
    1.71      ss=`printf "$substr" "$valvar"`
    1.72 -    eav=$eav${eav:+,}" max(case key when '$col' then $ss end) as $as"
    1.73 -    scols="$scols${scols:+, }b.$as"
    1.74 +    if [ x"$fromtbl" = x"b" ]; then
    1.75 +      eav=$eav${eav:+,}" \"$as:\"||coalesce(max(case key when '$col' then $ss end), '') as $as"
    1.76 +    else
    1.77 +      eav=$eav${eav:+,}" \"$as:\"||$ss as $as"
    1.78 +    fi
    1.79 +    scols="$scols${scols:+, }${fromtbl}.$as"
    1.80    done
    1.81  #case author when '$user' then a.rowid else '---' end as ID,
    1.82    if [ -n "$DT_SQL" ]; then
    1.83 @@ -3877,7 +3903,7 @@
    1.84      ## $ddd LINE exists at the end of this function
    1.85    fi
    1.86    printf '.mode list\n.header 0\n' >> $sqlfile
    1.87 -  cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)\(#[0-9a-fxs]*\)*</TD>,\1$elink$dvlink</TD>," | dt_rowhack
    1.88 +  cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)\(#[0-9a-fxs]*\)*</TD>,\1$elink$dvlink</TD>," | dt_colhack | dt_rowhack
    1.89  <div> <!-- for folding by check button (s4-funcs.sh:dumptable()) -->
    1.90  <div class="dumptable">
    1.91  <table class="b$dt_class">