From 36247cc4c321b0f3b884a673428598a6c8818d27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sun, 25 Jul 2021 22:16:44 +0200 Subject: [PATCH] bugfox: retain times when switching between todall and splittimes --- newdate.sh | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) 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/" -- 2.39.2