]> git.plutz.net Git - webpoll/commitdiff
bugfox: retain times when switching between todall and splittimes
authorPaul Hänsch <paul@plutz.net>
Sun, 25 Jul 2021 20:16:44 +0000 (22:16 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 25 Jul 2021 20:16:44 +0000 (22:16 +0200)
newdate.sh

index 790d7400ed0027bf1aa6daecf6c3eed719d4ff7d..32533b8090b17dce35e21e194134e836e437a1bb 100755 (executable)
@@ -56,22 +56,18 @@ if [ "$REQUEST_METHOD" = POST ]; then
   splittimes="$(POST splittimes |grep -m 1 -xE 'yes|no')"
   addtime="$(POST addtime)"
 
-  [ "$splittimes" ] && DBM "$file" set splittimes "$splittimes" || splittimes="$(DBM "$file" get splittimes || printf no)"
+  if [ "$splittimes" = yes ]; then
+    DBM "$file" set splittimes "$splittimes"
+    splittimes="no"   # receive remainder of todall form
+  elif [ "$splittimes" = no ]; then
+    DBM "$file" set splittimes "$splittimes"
+    splittimes="yes"  # receive remainder of splittimes form
+  else
+    splittimes="$(DBM "$file" get splittimes || printf no)"
+  fi
 
   DBM "$file" set title "$(POST title)"
   DBM "$file" set description "$(POST description)"
-  DBM "$file" set dates "$(
-    for date in $(seq 0 $(POST_COUNT date)); do
-      [ "$date" -eq 0 ] \
-      && POST date_add \
-      || POST date "$date"
-      printf \\n
-    done \
-    | grep -vxF "$(POST date_remove)" \
-    | grep -xE '^[0-9]{4}-((01|03|05|07|08|10|12)-([012][0-9]|3[01])|(04|06|09|11)-([012][0-9]|30)|02-[012][0-9])$' \
-    | sort -u
-  )"
-
   # Store common time options "todall"
   [ "$splittimes" = no ] && DBM "$file" set todall "$(
     for todcount in $(seq 1 $(POST_COUNT todstart)); do
@@ -103,6 +99,18 @@ if [ "$REQUEST_METHOD" = POST ]; then
     [ "$addtime" = "$date" ] && DBM "$file" append "tod_${date}" "${BR}-"
   done
 
+  DBM "$file" set dates "$(
+    for date in $(seq 0 $(POST_COUNT date)); do
+      [ "$date" -eq 0 ] \
+      && POST date_add \
+      || POST date "$date"
+      printf \\n
+    done \
+    | grep -vxF "$(POST date_remove)" \
+    | grep -xE '^[0-9]{4}-((01|03|05|07|08|10|12)-([012][0-9]|3[01])|(04|06|09|11)-([012][0-9]|30)|02-[012][0-9])$' \
+    | sort -u
+  )"
+
   if [ "$(POST cancel)" = cancel ]; then
     rm -- "$file"
     REDIRECT "$_BASE/"