From: Paul Hänsch Date: Sun, 4 Aug 2019 18:25:41 +0000 (+0200) Subject: basic support for telephone type X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=39d5084924d723c5bbea52c2b62fdfc39d39fe23;p=confetti basic support for telephone type --- diff --git a/cards/l10n.sh b/cards/l10n.sh index 48ee59e..841adb4 100755 --- a/cards/l10n.sh +++ b/cards/l10n.sh @@ -135,6 +135,13 @@ l10n(){ male) printf %s "♂";; other) printf %s "⚥";; none) printf %s "⚪";; + + teltype) printf %s "Anschlusstyp:";; + HOME) printf %s "Privat";; + WORK) printf %s "Geschäftlich";; + CELL) printf %s "Mobil";; + FAX) printf %s "Fax";; + *) printf %s "$1";; esac } diff --git a/cards/list.sh b/cards/list.sh index 4a57bd2..834803f 100755 --- a/cards/list.sh +++ b/cards/list.sh @@ -56,6 +56,19 @@ card_item(){ done fi ;; + TEL) if [ $cnt -gt 0 ]; then + printf '[h3 %s]' "$(l10n TEL)" + seq 1 $cnt |while read c; do + teltype="$(pdi_attrib "$card" TEL $c TYPE)" + [ "$teltype" ] \ + && printf '[span .item .TEL [span .type ­%s:] %s]' \ + "$(l10n "$teltype" |HTML)" \ + "$(pdi_value "$card" TEL $c |unescape |HTML)" \ + || printf '[span .item .TEL ­%s]' \ + "$(pdi_value "$card" TEL $c |unescape |HTML)" + done + fi + ;; *) if [ $cnt -gt 0 ]; then printf '[h3 %s]' "$(l10n "$item")" seq 1 $cnt |while read c; do @@ -101,6 +114,7 @@ edit_item(){ "$(l10n n_post)" "$(HTML "$n5")" ;; GENDER) + gender="$(pdi_value "$card" GENDER)" printf ' [select .item .GENDER name="GENDER" [option value="" disabled="disabled" %s %s] @@ -108,18 +122,12 @@ edit_item(){ [option value="male" %s %s] [option value="other" %s %s] [option value="none" %s %s] - ] - ' \ - "$([ "$(pdi_value "$card" GENDER)" = '' ] && printf 'selected="selected"')" \ - "$(l10n GENDER)" \ - "$([ "$(pdi_value "$card" GENDER)" = 'female' ] && printf 'selected="selected"')" \ - "$(l10n gender_female)" \ - "$([ "$(pdi_value "$card" GENDER)" = 'male' ] && printf 'selected="selected"')" \ - "$(l10n gender_male)" \ - "$([ "$(pdi_value "$card" GENDER)" = 'other' ] && printf 'selected="selected"')" \ - "$(l10n gender_other)" \ - "$([ "$(pdi_value "$card" GENDER)" = 'none' ] && printf 'selected="selected"')" \ - "$(l10n gender_none)" + ]\n' \ + "$([ "$gender" = '' ] && printf 'selected="selected"')" "$(l10n GENDER)" \ + "$([ "$gender" = 'female' ] && printf 'selected="selected"')" "$(l10n gender_female)" \ + "$([ "$gender" = 'male' ] && printf 'selected="selected"')" "$(l10n gender_male)" \ + "$([ "$gender" = 'other' ] && printf 'selected="selected"')" "$(l10n gender_other)" \ + "$([ "$gender" = 'none' ] && printf 'selected="selected"')" "$(l10n gender_none)" ;; BDAY|X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) printf '[h3 %s] @@ -134,6 +142,26 @@ edit_item(){ "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" done ;; + TEL) printf '[h3 %s]' "$(l10n "$item")" + seq 1 $cnt |while read c; do + teltype="$(pdi_attrib "$card" TEL $c TYPE)" + printf '[select .item .teltype name="teltype" + [option value="" disabled="disabled" %s %s] + [option value="HOME" %s %s] + [option value="WORK" %s %s] + [option value="CELL" %s %s] + [option value="FAX" %s %s] + ]\n' \ + "$([ "$teltype" = '' ] && printf 'selected="selected"')" "$(l10n teltype)" \ + "$([ "$teltype" = 'HOME' ] && printf 'selected="selected"')" "$(l10n HOME)" \ + "$([ "$teltype" = 'WORK' ] && printf 'selected="selected"')" "$(l10n WORK)" \ + "$([ "$teltype" = 'CELL' ] && printf 'selected="selected"')" "$(l10n CELL)" \ + "$([ "$teltype" = 'FAX' ] && printf 'selected="selected"')" "$(l10n FAX)" + + printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ + "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" + done + ;; *) printf '[h3 %s]' "$(l10n "$item")" seq 1 $cnt |while read c; do printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ diff --git a/cards/update_card.sh b/cards/update_card.sh index ee9ac3e..b16ea05 100755 --- a/cards/update_card.sh +++ b/cards/update_card.sh @@ -59,7 +59,11 @@ for field in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*'); do # (TEL) # printf '%s;TYPE=%s:%s\r\n' "${field}" "${_POST[phonetype${key#TEL}]}" "$(vcf_escape "$(POST "$field" "$cnt")")" # ;; - (*) + TEL) + vcf="$(pdi_update_attrib "$vcf" TEL $cnt TYPE="$(POST teltype $cnt |grep -Exm1 'HOME|WORK|CELL|FAX')")" + vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(POST "$field" "$cnt")")" + ;; + *) vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(POST "$field" "$cnt")")" ;; esac