]> git.plutz.net Git - lobster/blobdiff - cards/widgets.sh
quick fix: put temp file into lock, should switch to session_lock functions
[lobster] / cards / widgets.sh
index 8be5cdec305c2f20679d34414f0c98135cc0b607..8b5b986623c6100a2e42e2f2437318a4f9680df3 100755 (executable)
@@ -1,4 +1,4 @@
-# Copyright 2014 - 2019 Paul Hänsch
+# Copyright 2014 - 2019, 2021 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
@@ -22,12 +22,12 @@ cat <<EOF
     [legend $(l10n filter_item):]
 
     $(for field in any name street zip TEL BDAY; do
-      printf '[input id="%s%i" type="radio" name="filter_type%i" value="%s" %s]
+      printf '[input id="%s%i" type="radio" .tab name="filter_type%i" value="%s" %s]
               [label for="%s%i" %s ]' \
               "$field" "$n" "$n" "$field" "$([ "$1" = "$field" ] && printf checked )" \
               "$field" "$n" "$(l10n filter_$field)"
     done)
-    [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
+    [input type="text" .tab name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
   ]
 EOF
 }
@@ -44,17 +44,18 @@ w_filter_diag(){
         w_filter_item "${fil%%:*}" "${fil#*:}" $n
         n=$((n + 1))
       done
-      w_filter_item any '' $n
+      [ "$n" -eq 0 -o "$(GET newfilter)" ] && w_filter_item any '' $n
     )
-  
+    [button type="submit" name="choice" value="new_filter" $(l10n filter_more)]
     [fieldset class="order"
       [legend $(l10n filter_order):]
-      [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
       [label [radio "order" "lastname"  $( [ "$order" = lastname  ] && printf checked )] $(l10n filter_lastname)]
+      [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
       [label [radio "order" "bdate"     $( [ "$order" = bdate     ] && printf checked )] $(l10n filter_bdate)]
     ]
-    [button type="submit" name="choice" value="new_filter" $(l10n filter_apply)]
+    [button type="submit" name="choice" value="filter" $(l10n filter_apply)]
     [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
+    [button type="submit" name="choice" value="export_csv" $(l10n export_csv)]
   ]
 EOF
 }
@@ -73,7 +74,7 @@ card_item(){
       GENDER) printf '[span .item .GENDER . %s]' "$(pdi_value "$card" GENDER |l10n)"
         ;;
       NICKNAME) seq 1 $cnt |while read c; do
-          printf '[span .item .NICKNAME aka. "%s"]' \
+          printf '[span .item .NICKNAME aka. "%s"]' \
                  "$(pdi_value "$card" NICKNAME $c |pdi_unescape |HTML)"
         done
         ;;
@@ -110,9 +111,10 @@ card_item(){
         [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n TEL)"
         seq 1 $cnt |while read c; do
           teltype="$(pdi_attrib "$card" TEL $c TYPE)"
+          ttl10="$(l10n "TYPE=$teltype")"  # See below: HTML-Escape teltype if there is no translation (translations are always pre escaped)
           [ "$teltype" ] \
           && printf '[span .item .TEL [span .type . %s:] %s]' \
-                    "$(l10n "TYPE=$teltype" |HTML)" \
+                    "$([ "$ttl10" = "TYPE=$teltype" ] && { printf %s "$ttl10" |HTML; } || printf %s "$ttl10")" \
                     "$(pdi_value "$card" TEL $c |pdi_unescape |HTML)" \
           || printf '[span .item .TEL . %s]' \
                     "$(pdi_value "$card" TEL $c |pdi_unescape |HTML)"
@@ -138,7 +140,7 @@ card_item(){
         (cd "$_DATA/therapies/"; printf '%s\n' "${client}".*.tpy) \
         | while read tpyfile; do
           [ "$tpyfile" = "${client}.*.tpy" ] \
-          && printf '[a .item .therapy href="/therapies/%s/new" . +]' "${client}" \
+          && printf '[a .button .therapy href="/therapies/%s/new" . +]' "${client}" \
           && break
           tpy="${tpyfile%.tpy}";
           tpydates="$(sed -En 's;^session[0-9]+_date:;;p;' "$_DATA/therapies/$tpyfile" \
@@ -177,8 +179,7 @@ edit_item(){
                EOF
         else
          N="$(pdi_value "$card" FN |pdi_unescape)"
-          n1="${N%%[a-z]*}" n1="${N#$n1}"
-          [ "$n1" ] || n1="${N##* }"
+          n1="${N##* }"
           n2="${N%$n1}"
         fi
         printf '
@@ -189,7 +190,7 @@ edit_item(){
         [input .item .N name="5N" placeholder="%s" value="%s"]
         ' "$(l10n "$item")" \
         "$(l10n n_pre)"   "$(HTML "$n4")" \
-        "$(l10n n_first)" "$(HTML "${n2}${n3:+ }${n3}")" \
+        "$(l10n n_first)" "$(HTML "${n2}$([ "$n2" -a "$n3" ] && printf ' ')${n3}")" \
         "$(l10n n_last)"  "$(HTML "$n1")" \
         "$(l10n n_post)"  "$(HTML "$n5")"
         ;;
@@ -256,11 +257,9 @@ edit_item(){
                $(pdi_value "$card" X-HEALTH-INSURANCE $c)
                EOF
           cat <<-EOF
-               [input type="radio" name="$item" value="list" #hi_select_list checked]<!--
-               -->[label for="hi_select_list" $(l10n hi_from_list)]<!--
-               -->[input type="radio" name="$item" value="other" #hi_other checked]<!--
-               -->[label for="hi_other" $(l10n hi_other)]<!--
-               -->[select class="item" name="hi_company"
+               [radio "$item" "list" .tab #hi_select_list checked][label for="hi_select_list" $(l10n hi_from_list)]
+               [radio "$item" "other" .tab #hi_other][label for="hi_other" $(l10n hi_other)]
+               [select .tab .item name="hi_company"
                  [option value="" disabled="disabled" $(selected "${hi_name}" "") . $(l10n hi_company)]
                  $(list_hi_companies |while read f; do
                    printf '[option value="%s" %s . %s]' "$(pdi_unescape "$f" |HTML)" \
@@ -268,9 +267,9 @@ edit_item(){
                                                         "$(pdi_unescape "$f" |HTML)"
                  done)
                ]
-               [input type="text" name="hi_other" value="$hi_name" placeholder="$(l10n hi_company)"]
-               [input name="hi_number" value="$(pdi_unescape "$hi_number" |HTML)" placeholder="$(l10n hi_number)"]
-               [input name="hi_status" value="$(pdi_unescape "$hi_status" |HTML)" placeholder="$(l10n hi_status)"]
+               [input type="text" .tab name="hi_other" value="$hi_name" placeholder="$(l10n hi_company)"]
+               [input type="text" name="hi_number" value="$(pdi_unescape "$hi_number" |HTML)" placeholder="$(l10n hi_number)"]
+               [input type="text" name="hi_status" value="$(pdi_unescape "$hi_status" |HTML)" placeholder="$(l10n hi_status)"]
                EOF
         done
         ;;