]> git.plutz.net Git - webpoll/blobdiff - newdate.sh
UI improvements
[webpoll] / newdate.sh
index e2902e471256cd1dd42e0fd385de94efc7d6c6e6..9c5a1e71cb9dd654c55cc2642eb46f5ae8963035 100755 (executable)
@@ -127,9 +127,13 @@ if [ "$REQUEST_METHOD" = POST ]; then
     | sort -u
   )"
 
-  if [ "$(POST cancel)" = cancel ]; then
-    rm -- "$file"
-    REDIRECT "$_BASE/"
+  if [ "$(POST delete)" = delete ]; then
+    if [ "$(POST delconfirm)" -o ! "$(DBM "$file" get participants)" ]; then
+      rm -- "$file"
+      REDIRECT "$_BASE/"
+    else
+      REDIRECT "$_BASE$PATH_INFO${month:+?month=}${month}#ERROR_NEEDCONFIRM"
+    fi
   elif [ "$(POST post)" = post ]; then
     REDIRECT "$_BASE${PATH_INFO%/*}"
   elif [ "$(POST bookmark)" -a ! "$bookmarks" ]; then
@@ -161,8 +165,12 @@ else
            [hidden "month" "$month"]
          ]
          $([ "$splittimes" = "yes" ] && fs_splittimes || fs_timeofday )
-         [submit "cancel" "cancel" Cancel]
-         [submit "post" "post" Post Event]
+         $(if [ "$(DBM "$file" get participants)" ]; then
+           printf '[checkbox "delconfirm" "confirm" id="delconfirm"][label for=delconfirm Delete Poll]
+                    [submit "delete" "delete" Delete Poll] [submit "post" "post" Poll page]'
+         else
+           printf '[submit "delete" "delete" Cancel] [submit "post" "post" Post Event]'
+         fi)
          $(if [ "$bookmarks" ]; then
            printf '[section .bookmark This admin page is accessible via the link [a href="%s" %s]. You must copy this link and keep it safe, so you can modify this poll later! The poll has also been bookmarked and will be listed on the front page.' \
            "$(URL "//$(HEADER Host)/${_BASE}/${id}/${admin}")" \