Fossil SCM

Add a confirmer wrapper around the forum post close/reopen button to help avoid accidental closing of posts via mis-clicks, per /chat discussion.

stephan 2025-07-02 10:55 trunk
Commit 751dbe28ceb6d1f5bd3e545a8f17dbd8106303e3931a8866238ef8054e889f2f
+4 -2
--- src/forum.c
+++ src/forum.c
@@ -933,11 +933,12 @@
933933
@ <form method="post" \
934934
@ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'>
935935
login_insert_csrf_secret();
936936
@ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
937937
if( moderation_pending(p->fpid)==0 ){
938
- @ <input type="submit" value='%s(iClosed ? "Re-open" : "Close")' />
938
+ @ <input type="button" value='%s(iClosed ? "Re-open" : "Close")' \
939
+ @ class='%s(iClosed ? "action-reopen" : "action-close")'/>
939940
}
940941
@ </form>
941942
}
942943
@ </div>
943944
}
@@ -1114,11 +1115,12 @@
11141115
** Emit Forum Javascript which applies (or optionally can apply)
11151116
** to all forum-related pages. It does not include page-specific
11161117
** code (e.g. "forum.js").
11171118
*/
11181119
static void forum_emit_js(void){
1119
- builtin_fossil_js_bundle_or("copybutton", "pikchr", NULL);
1120
+ builtin_fossil_js_bundle_or("copybutton", "pikchr", "confirmer",
1121
+ NULL);
11201122
builtin_request_js("fossil.page.forumpost.js");
11211123
}
11221124
11231125
/*
11241126
** WEBPAGE: forumpost
11251127
--- src/forum.c
+++ src/forum.c
@@ -933,11 +933,12 @@
933 @ <form method="post" \
934 @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'>
935 login_insert_csrf_secret();
936 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
937 if( moderation_pending(p->fpid)==0 ){
938 @ <input type="submit" value='%s(iClosed ? "Re-open" : "Close")' />
 
939 }
940 @ </form>
941 }
942 @ </div>
943 }
@@ -1114,11 +1115,12 @@
1114 ** Emit Forum Javascript which applies (or optionally can apply)
1115 ** to all forum-related pages. It does not include page-specific
1116 ** code (e.g. "forum.js").
1117 */
1118 static void forum_emit_js(void){
1119 builtin_fossil_js_bundle_or("copybutton", "pikchr", NULL);
 
1120 builtin_request_js("fossil.page.forumpost.js");
1121 }
1122
1123 /*
1124 ** WEBPAGE: forumpost
1125
--- src/forum.c
+++ src/forum.c
@@ -933,11 +933,12 @@
933 @ <form method="post" \
934 @ action='%R/forumpost_%s(iClosed > 0 ? "reopen" : "close")'>
935 login_insert_csrf_secret();
936 @ <input type="hidden" name="fpid" value="%z(rid_to_uuid(iHead))" />
937 if( moderation_pending(p->fpid)==0 ){
938 @ <input type="button" value='%s(iClosed ? "Re-open" : "Close")' \
939 @ class='%s(iClosed ? "action-reopen" : "action-close")'/>
940 }
941 @ </form>
942 }
943 @ </div>
944 }
@@ -1114,11 +1115,12 @@
1115 ** Emit Forum Javascript which applies (or optionally can apply)
1116 ** to all forum-related pages. It does not include page-specific
1117 ** code (e.g. "forum.js").
1118 */
1119 static void forum_emit_js(void){
1120 builtin_fossil_js_bundle_or("copybutton", "pikchr", "confirmer",
1121 NULL);
1122 builtin_request_js("fossil.page.forumpost.js");
1123 }
1124
1125 /*
1126 ** WEBPAGE: forumpost
1127
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -117,8 +117,19 @@
117117
setTimeout(()=>{delete form.dataset.submitted}, 7000);
118118
return;
119119
};
120120
document.querySelectorAll("form").forEach(function(form){
121121
form.addEventListener('submit',formSubmitted);
122
+ form
123
+ .querySelectorAll("input.action-close, input.action-reopen")
124
+ .forEach(function(e){
125
+ F.confirmer(e, {
126
+ confirmText: (e.classList.contains('action-reopen')
127
+ ? "Confirm re-open"
128
+ : "Confirm close"),
129
+ onconfirm: ()=>form.submit()
130
+ });
131
+ });
122132
});
133
+
123134
})/*F.onPageLoad callback*/;
124135
})(window.fossil);
125136
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -117,8 +117,19 @@
117 setTimeout(()=>{delete form.dataset.submitted}, 7000);
118 return;
119 };
120 document.querySelectorAll("form").forEach(function(form){
121 form.addEventListener('submit',formSubmitted);
 
 
 
 
 
 
 
 
 
 
122 });
 
123 })/*F.onPageLoad callback*/;
124 })(window.fossil);
125
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -117,8 +117,19 @@
117 setTimeout(()=>{delete form.dataset.submitted}, 7000);
118 return;
119 };
120 document.querySelectorAll("form").forEach(function(form){
121 form.addEventListener('submit',formSubmitted);
122 form
123 .querySelectorAll("input.action-close, input.action-reopen")
124 .forEach(function(e){
125 F.confirmer(e, {
126 confirmText: (e.classList.contains('action-reopen')
127 ? "Confirm re-open"
128 : "Confirm close"),
129 onconfirm: ()=>form.submit()
130 });
131 });
132 });
133
134 })/*F.onPageLoad callback*/;
135 })(window.fossil);
136

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button