s4

changeset 1003:5bd1b5125049

Direct link to lshandoutall in group home for grp-admin
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 11 Dec 2022 17:19:32 +0859
parents 47b3e770372d
children 70d9e8f1a85a
files s4-blog.sh s4-funcs.sh s4-main.js
diffstat 3 files changed, 44 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Sun Dec 04 16:59:59 2022 +0859
     1.2 +++ b/s4-blog.sh	Sun Dec 11 17:19:32 2022 +0859
     1.3 @@ -795,9 +795,10 @@
     1.4    if [ -z "$CATCSV" ]; then
     1.5      echo "<hr><h2>総合</h2>"
     1.6      echo "$sql" | lshandout_ulink_table
     1.7 -    echo "<h2>総合(<a href=\"?gethandoutcsv+$rowid\">CSV</a>)</h2>"
     1.8 +    echo "<h2>総合(<a id=\"gethandoutcsv\" href=\"?gethandoutcsv+$rowid\">CSV</a>)</h2>"
     1.9 +    echo '<p id="bommsg"></p>'
    1.10      printf ".mode csv\n.header ON\n" | query
    1.11 -    echo '<pre class="list">'
    1.12 +    echo '<pre id="totalcsv" class="list">'
    1.13      echo "$sql" | query | sed 's/^"[0-9]*	/"/'
    1.14      echo "</pre>"
    1.15      echo "<pre><a href=\"?gethandoutcsv2+$rowid\">縦持ちCSV</a></pre>"
     2.1 --- a/s4-funcs.sh	Sun Dec 04 16:59:59 2022 +0859
     2.2 +++ b/s4-funcs.sh	Sun Dec 11 17:19:32 2022 +0859
     2.3 @@ -2844,6 +2844,26 @@
     2.4        title=\"Shortcut: e${nl}Edit Group\">グループ情報の編集</a>"
     2.5      iamowner=$rowid
     2.6      colmd=" mode"
     2.7 +    # We have to specify report-type blog to lshandoutall
     2.8 +    repblog=`query "
     2.9 +	WITH grpblogs AS (
    2.10 +	  SELECT id FROM blog_s
    2.11 +	  WHERE key='owner' AND val=(SELECT gname FROM grp WHERE rowid=$rowid)
    2.12 +	), ownerMode AS (
    2.13 +	  SELECT id,
    2.14 +	  	 max(CASE key WHEN 'owner' THEN val END) owner,
    2.15 +		 max(CASE key WHEN 'mode' THEN val END) mode
    2.16 +	  FROM blog_s
    2.17 +	  GROUP BY id
    2.18 +	), blogid AS (
    2.19 +	  SELECT id
    2.20 +	  FROM grpblogs NATURAL LEFT JOIN ownerMode
    2.21 +	  WHERE mode LIKE 'report%' LIMIT 1
    2.22 +	) SELECT blog.rowid FROM blogid NATURAL LEFT JOIN blog;"`
    2.23 +    if [ -n "$repblog" ]; then
    2.24 +       csvid="gethandoutcsv"
    2.25 +       replink="/ <a href=\"?lshandoutall+$repblog#$csvid\">レポート全集計</a>"
    2.26 +    fi
    2.27    fi
    2.28    if [ -n "$ismember" ]; then
    2.29      #echo "${iamowner:+ / }<a href=\"?blog+$rowid\">グループの新規話題作成</a>"
    2.30 @@ -2853,7 +2873,8 @@
    2.31  	${iamowner:+ / }<a accesskey="n" title="Shortcut: n${nl}New blog"
    2.32  	  href="?blog+$rowid">グループの新規話題作成</a>
    2.33  	  / <a accesskey="m" title="Shortcut: m${nl}Operations on Members"
    2.34 -	  href="?grpaction+$rowid">メンバーを個別選択しての操作</a></p>
    2.35 +	  href="?grpaction+$rowid">メンバーを個別選択しての操作</a>
    2.36 +	  $replink</p>
    2.37  	<form action="?send2mem" method="POST" enctype="multipart/form-data">
    2.38  	<div class="fold clear">
    2.39  	`cgi_checkbox send yes id="send"`<label
     3.1 --- a/s4-main.js	Sun Dec 04 16:59:59 2022 +0859
     3.2 +++ b/s4-main.js	Sun Dec 11 17:19:32 2022 +0859
     3.3 @@ -1189,6 +1189,24 @@
     3.4  	else
     3.5  	    rewriteReplyHover();
     3.6      }
     3.7 +    var getHandoutCSV;
     3.8 +    function initGetHandoutCSV() {
     3.9 +	getHandoutCSV = document.getElementById("gethandoutcsv");
    3.10 +	if (!getHandoutCSV) return;
    3.11 +	document.getElementById("bommsg").innerText =
    3.12 +	    `Excelで開く場合は上記CSVリンクをCtrlを押しながら。
    3.13 +You need to click CSV link above with Ctrl-key when you handle CSV with Excel`;
    3.14 +	getHandoutCSV.addEventListener("click", (e) => {
    3.15 +	    e.preventDefault();		// Stop visiting link
    3.16 +	    let bom = e.ctrlKey;
    3.17 +	    let csv = document.getElementById("totalcsv");
    3.18 +	    if (!csv || !csv.textContent) return;
    3.19 +	    let fn = "report-count", plus=myurl.lastIndexOf("+");
    3.20 +	    if (plus) fn += ("-"+myurl.substring(1+plus));
    3.21 +	    fn = fn.replace(/#.*/, "");
    3.22 +	    downloadFile(fn+".csv", csv.textContent, bom);
    3.23 +	});
    3.24 +    }
    3.25      function init() {
    3.26  	isOlderJS = !("insertAdjacentElement" in document.body);
    3.27  	initGrpAction();
    3.28 @@ -1198,6 +1216,7 @@
    3.29  	initGrphome();
    3.30  	initMath();
    3.31  	initReplyHover();
    3.32 +	initGetHandoutCSV();
    3.33      }
    3.34      document.addEventListener('DOMContentLoaded', init, null);
    3.35  })();