From: Paul Hänsch Date: Tue, 6 Aug 2019 12:11:49 +0000 (+0200) Subject: per field add buttons X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=79c8cc42d90a62b40dd2fc2215c3d07208160f22;p=confetti per field add buttons --- diff --git a/cards/list.sh b/cards/list.sh index 825b683..8f3b720 100755 --- a/cards/list.sh +++ b/cards/list.sh @@ -136,6 +136,7 @@ edit_item(){ printf '' \ "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" done + printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" ;; TEL) printf '[h3 %s]' "$(l10n "$item")" seq 1 $cnt |while read c; do @@ -158,6 +159,7 @@ edit_item(){ printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" done + printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" ;; *)printf '[h3 %s]' "$(l10n "$item")" seq 1 $cnt |while read c; do @@ -166,6 +168,7 @@ edit_item(){ printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" done + printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" ;; esac done diff --git a/cards/update_card.sh b/cards/update_card.sh index 52ccfcd..f44eb28 100755 --- a/cards/update_card.sh +++ b/cards/update_card.sh @@ -20,6 +20,10 @@ . "$_EXEC/pdiread.sh" . "$_EXEC/session_lock.sh" +unset filter order card action newfield +unset cardfile attfile tempfile +unset vcf field cnt delete_key + filter="$(REF f)" order="$(REF o)" @@ -28,7 +32,12 @@ cardfile="$_DATA/vcard/$card" attfile="$_DATA/mappings/attendance" action="$(POST action)" -newfield="$(POST newfield)" +newfield="$(POST newfield |grep -m 1 -xE '[A-Z][A-Z0-9-]*')" + +if printf '%s\n' "$action" |grep -qxE 'addfield [A-Z][A-Z0-9]*'; then + newfield="${action##* }" + action=addfield +fi if ! tempfile=$(CHECK_SLOCK "$cardfile"); then SET_COOKIE 0 message="NO VALID FILE LOCK"