]> git.plutz.net Git - webpoll/blobdiff - widgets.sh
submit mode for calendar widget
[webpoll] / widgets.sh
index 4d3df23b7a9023257322dfd394282f915e9f46f5..ab88b3ec699319238b3db7452839d15fc8b2139b 100755 (executable)
@@ -21,7 +21,7 @@ selected(){
 
 w_month() {
   # Arguments:
-  # 1. (optional) select, multiple, none - default: select
+  # 1. (optional) select, multiple, submit, none - default: select
   # 2. (optional) Name of form field - default: "date"
   # 3. (optional) Month to display in format: YYYY-MM - default: current month
   # 4. (optional, multiple) Days to preselect in format: DD - default: none
@@ -77,6 +77,11 @@ w_month() {
         printf '[td [input type=checkbox id="%s_%s" name="%s" value="%s" %s][label for="%s_%s" . %i]]' \
                "$input" "$date" "$input" "$date" "$(checked $dom $selected)" "$input" "$date" "$dom"
         ;;
+      submit)
+        [ "$(checked $dom $selected)" ] \
+        && printf '[td [submit "%s_remove" "%s" . %i][hidden "%s" "%s"]]' "$input" "$date" "$dom" "$input" "$date" \
+        || printf '[td [submit "%s_add"    "%s" . %i]]' "$input" "$date" "$dom"
+        ;;
       select|*)
         printf '[td [input type=radio id="%s_%s" name="%s" value="%s" %s][label for="%s_%s" . %i]]' \
                "$input" "$date" "$input" "$date" "$(checked $dom $selected)" "$input" "$date" "$dom"