From: Paul Hänsch Date: Sun, 25 Jul 2021 20:16:44 +0000 (+0200) Subject: bugfox: retain times when switching between todall and splittimes X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=36247cc4c321b0f3b884a673428598a6c8818d27;p=webpoll bugfox: retain times when switching between todall and splittimes --- diff --git a/newdate.sh b/newdate.sh index 790d740..32533b8 100755 --- a/newdate.sh +++ b/newdate.sh @@ -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/"