changeset 1003:5bd1b5125049 draft

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 wrap: on
line diff
--- a/s4-blog.sh	Sun Dec 04 16:59:59 2022 +0859
+++ b/s4-blog.sh	Sun Dec 11 17:19:32 2022 +0859
@@ -795,9 +795,10 @@
   if [ -z "$CATCSV" ]; then
     echo "<hr><h2>総合</h2>"
     echo "$sql" | lshandout_ulink_table
-    echo "<h2>総合(<a href=\"?gethandoutcsv+$rowid\">CSV</a>)</h2>"
+    echo "<h2>総合(<a id=\"gethandoutcsv\" href=\"?gethandoutcsv+$rowid\">CSV</a>)</h2>"
+    echo '<p id="bommsg"></p>'
     printf ".mode csv\n.header ON\n" | query
-    echo '<pre class="list">'
+    echo '<pre id="totalcsv" class="list">'
     echo "$sql" | query | sed 's/^"[0-9]*	/"/'
     echo "</pre>"
     echo "<pre><a href=\"?gethandoutcsv2+$rowid\">縦持ちCSV</a></pre>"
--- a/s4-funcs.sh	Sun Dec 04 16:59:59 2022 +0859
+++ b/s4-funcs.sh	Sun Dec 11 17:19:32 2022 +0859
@@ -2844,6 +2844,26 @@
       title=\"Shortcut: e${nl}Edit Group\">グループ情報の編集</a>"
     iamowner=$rowid
     colmd=" mode"
+    # We have to specify report-type blog to lshandoutall
+    repblog=`query "
+	WITH grpblogs AS (
+	  SELECT id FROM blog_s
+	  WHERE key='owner' AND val=(SELECT gname FROM grp WHERE rowid=$rowid)
+	), ownerMode AS (
+	  SELECT id,
+	  	 max(CASE key WHEN 'owner' THEN val END) owner,
+		 max(CASE key WHEN 'mode' THEN val END) mode
+	  FROM blog_s
+	  GROUP BY id
+	), blogid AS (
+	  SELECT id
+	  FROM grpblogs NATURAL LEFT JOIN ownerMode
+	  WHERE mode LIKE 'report%' LIMIT 1
+	) SELECT blog.rowid FROM blogid NATURAL LEFT JOIN blog;"`
+    if [ -n "$repblog" ]; then
+       csvid="gethandoutcsv"
+       replink="/ <a href=\"?lshandoutall+$repblog#$csvid\">レポート全集計</a>"
+    fi
   fi
   if [ -n "$ismember" ]; then
     #echo "${iamowner:+ / }<a href=\"?blog+$rowid\">グループの新規話題作成</a>"
@@ -2853,7 +2873,8 @@
 	${iamowner:+ / }<a accesskey="n" title="Shortcut: n${nl}New blog"
 	  href="?blog+$rowid">グループの新規話題作成</a>
 	  / <a accesskey="m" title="Shortcut: m${nl}Operations on Members"
-	  href="?grpaction+$rowid">メンバーを個別選択しての操作</a></p>
+	  href="?grpaction+$rowid">メンバーを個別選択しての操作</a>
+	  $replink</p>
 	<form action="?send2mem" method="POST" enctype="multipart/form-data">
 	<div class="fold clear">
 	`cgi_checkbox send yes id="send"`<label
--- a/s4-main.js	Sun Dec 04 16:59:59 2022 +0859
+++ b/s4-main.js	Sun Dec 11 17:19:32 2022 +0859
@@ -1189,6 +1189,24 @@
 	else
 	    rewriteReplyHover();
     }
+    var getHandoutCSV;
+    function initGetHandoutCSV() {
+	getHandoutCSV = document.getElementById("gethandoutcsv");
+	if (!getHandoutCSV) return;
+	document.getElementById("bommsg").innerText =
+	    `Excelで開く場合は上記CSVリンクをCtrlを押しながら。
+You need to click CSV link above with Ctrl-key when you handle CSV with Excel`;
+	getHandoutCSV.addEventListener("click", (e) => {
+	    e.preventDefault();		// Stop visiting link
+	    let bom = e.ctrlKey;
+	    let csv = document.getElementById("totalcsv");
+	    if (!csv || !csv.textContent) return;
+	    let fn = "report-count", plus=myurl.lastIndexOf("+");
+	    if (plus) fn += ("-"+myurl.substring(1+plus));
+	    fn = fn.replace(/#.*/, "");
+	    downloadFile(fn+".csv", csv.textContent, bom);
+	});
+    }
     function init() {
 	isOlderJS = !("insertAdjacentElement" in document.body);
 	initGrpAction();
@@ -1198,6 +1216,7 @@
 	initGrphome();
 	initMath();
 	initReplyHover();
+	initGetHandoutCSV();
     }
     document.addEventListener('DOMContentLoaded', init, null);
 })();

yatex.org