]> git.plutz.net Git - confetti/commitdiff
basic support for telephone type
authorPaul Hänsch <paul@plutz.net>
Sun, 4 Aug 2019 18:25:41 +0000 (20:25 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 4 Aug 2019 18:25:41 +0000 (20:25 +0200)
cards/l10n.sh
cards/list.sh
cards/update_card.sh

index 48ee59ee4b706f2362c5586b26b06e5aefd7b18c..841adb4977ddc45c3fbddfc051af61ea58c3d0d4 100755 (executable)
@@ -135,6 +135,13 @@ l10n(){
     male) printf %s "&#x2642;";;
     other) printf %s "&#x26A5;";;
     none) printf %s "&#x26AA;";;
     male) printf %s "&#x2642;";;
     other) printf %s "&#x26A5;";;
     none) printf %s "&#x26AA;";;
+
+    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
 }
     *) printf %s "$1";;
   esac
 }
index 4a57bd2314f300585b6ef50eb6f9162536898945..834803f336756b7419de663eec5a8b3585f44e0e 100755 (executable)
@@ -56,6 +56,19 @@ card_item(){
           done
         fi
         ;;
           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 &shy;%s:] %s]' \
+                      "$(l10n "$teltype" |HTML)" \
+                      "$(pdi_value "$card" TEL $c |unescape |HTML)" \
+            || printf '[span .item .TEL &shy;%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
       *) 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)
         "$(l10n n_post)"  "$(HTML "$n5")"
         ;;
       GENDER)
+        gender="$(pdi_value "$card" GENDER)"
         printf '
         [select .item .GENDER name="GENDER"
           [option value="" disabled="disabled" %s %s]
         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]
           [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]
         ;;
       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
         ;;
           "$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"]' \
       *) printf '[h3 %s]' "$(l10n "$item")"
         seq 1 $cnt |while read c; do
           printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \
index ee9ac3eb295cb7e524714dc1550dab82f16b524d..b16ea0549c8548fd727d23b78de7ed6e54928ac5 100755 (executable)
@@ -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)
       #   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
          vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(POST "$field" "$cnt")")"
         ;;
     esac