unify client and attendee editing templates
authorpaul <paul@plutz.net>
Mon, 14 Nov 2016 17:02:47 +0000 (17:02 +0000)
committerpaul <paul@plutz.net>
Mon, 14 Nov 2016 17:02:47 +0000 (17:02 +0000)
svn path=/trunk/; revision=147

pages/cards.sh
templates/edit_card.sh [moved from templates/edit_attendee.sh with 98% similarity]
templates/edit_client.sh [deleted file]

index 2d1d4e2..945908e 100755 (executable)
@@ -31,7 +31,6 @@ medical)
   SUP_FIELDS=(N NICKNAME GENDER BDAY ADR TEL EMAIL X-HEALTH-INSURANCE X-HEALTH-INSURANCE-NOCONTRIB IMPP URL NOTE X-CLIENT-REFERRAL)
   FORCE_ITEMS=(ADR TEL EMAIL NOTE X-CLIENT-REFERRAL)
   view_card="$_EXEC/templates/view_client.sh"
-  edit_card="$_EXEC/templates/edit_client.sh"
   _GET[order]="${_GET[order]:-lastname}"
   _GET[filtertype]="${_GET[filtertype]:-name}"
   profile_medical=x
@@ -40,7 +39,6 @@ circus)
   SUP_FIELDS=(N NICKNAME GENDER BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE EMAIL TEL IMPP ADR URL NOTE)
   FORCE_ITEMS=(BDAY X-ZACK-JOINDATE TEL EMAIL ADR NOTE)
   view_card="$_EXEC/templates/view_attendee.sh"
-  edit_card="$_EXEC/templates/edit_attendee.sh"
   _GET[order]="${_GET[order]:-firstname}"
   _GET[filtertype]="${_GET[filtertype]:-any}"
   profile_circus=x
@@ -269,5 +267,5 @@ edit_card() {  #Parameter: Cardfile
   declare -A values
   vcf_parse "$cardfile"
   force_items $FORCE_ITEMS
-  . $edit_card
+  . "$_EXEC/templates/edit_card.sh"
 }
similarity index 98%
rename from templates/edit_attendee.sh
rename to templates/edit_card.sh
index 820bce8..b3af045 100755 (executable)
@@ -76,9 +76,9 @@ list_section(){
   printf '</div>'
 }
 
-hi_company="${values[X-HEALTH-INSURANCE+1]}"
- hi_number="${values[X-HEALTH-INSURANCE+2]}"
- hi_status="${values[X-HEALTH-INSURANCE+3]}"
+hi_company="${values[X-HEALTH-INSURANCE+0]}"
+ hi_number="${values[X-HEALTH-INSURANCE+1]}"
+ hi_status="${values[X-HEALTH-INSURANCE+2]}"
 
 [ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)"
 
diff --git a/templates/edit_client.sh b/templates/edit_client.sh
deleted file mode 100755 (executable)
index f2c5afb..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-# Copyright 2014 - 2016 Paul Hänsch
-#
-# This file is part of Confetti.
-# 
-# Confetti is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# Confetti is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
-
-setchecked() {
-  printf 'checked="checked"'
-}
-setselected() {
-  printf 'selected="selected"'
-}
-check_gen() {
-  [ "$values[GENDER]" = "$1" ] && setselected
-}
-check_a() {
-  egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked
-}
-teltype() {
-  cat <<-EOF
-       <select class="item phonetype" name="phonetype">
-         <option value="" disabled="disabled" $([ -z "$1" ] && setselected )>$(l10n phone_typeselect)</option>
-         <option value=""></option>
-         <option value="HOME" $([ "$1" = HOME ] && setselected)>$(l10n phone_home)</option>
-         <option value="CELL" $([ "$1" = CELL ] && setselected)>$(l10n phone_cell)</option>
-         <option value="WORK" $([ "$1" = WORK ] && setselected)>$(l10n phone_work)</option>
-         <option value="FAX"  $([ "$1" = FAX  ] && setselected)>$(l10n phone_fax )</option>
-       </select>
-       EOF
-}
-
-list_items(){
-  item="$1"
-  placeholder="$2"
-  [ -n "${values[$item]+x}" ] && printf '<h3>%s</h3>\n' "$(l10n $item)"
-  for n in "$item" "$item"{0..100}; do
-    if [ -n "${values[$n]+x}" ]; then
-      case "$item" in
-        (ADR|NOTE)
-          printf '<textarea class="item %s" name="%s">%s</textarea>\n' \
-            "$item" "$item" "$(htmlsafe ${values[$n]})"
-          ;;
-        (TEL)
-          teltype "${values[${n}_TYPE]}"
-          printf '<input class="item %s" name="%s" value="%s" />\n' \
-            "$item" "$item" "$(attribsafe ${values[$n]})"
-          ;;
-        (*)
-          printf '<input class="item %s" name="%s" value="%s" placeholder="%s"/>\n' \
-            "$item" "$item" "$(attribsafe ${values[$n]})" "$placeholder"
-          ;;
-      esac
-    else
-      break
-    fi
-  done
-}
-
-hi_company="${values[X-HEALTH-INSURANCE+1]}"
-hi_number= "${values[X-HEALTH-INSURANCE+2]}"
-hi_status= "${values[X-HEALTH-INSURANCE+3]}"
-
-[ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)"
-
-cat <<END_HTML
-<form id="$id" class="card" action="?action=update_card" method="POST">
-  <input type="hidden" name="card" value="${id}"/>
-  <div class="section basic">
-    <h3>$(l10n N)</h3>
-    <input class="item N" name="3N" placeholder="$(l10n n_pre)" value="$values[N+3]" />
-    <input class="item N" name="1N" placeholder="$(l10n n_first)" value="$values[N+1]" />
-    <input class="item N" name="2N" placeholder="$(l10n n_middle)" value="$values[N+2]" />
-    <input class="item N" name="0N" placeholder="$(l10n n_last)" value="$values[N+0]" />
-    <input class="item N" name="4N" placeholder="$(l10n n_post)" value="$values[N+4]" />
-
-    <select class="item GENDER" name="GENDER">
-      <option value="" disabled="disabled">$(l10n GENDER)</option>
-      <option value="female" $(check_gen female)>$(l10n gender_female)</option>
-      <option value="male" $(check_gen male)>$(l10n gender_male)</option>
-      <option value="other" $(check_gen other)>$(l10n gender_other)</option>
-      <option value="none" $(check_gen none)>$(l10n gender_none)</option>
-    </select>
-
-    $(for n in NICKNAME NICKNAME{0..10}; do
-      printf %s\\n "${values[$n]+<input class="item NICKNAME" name="NICKNAME" placeholder="$(l10n NICKNAME)" value="$values[$n]" />}"
-    done)
-
-    $(list_items BDAY YYYY-MM-DD)
-
-    $(list_items X-ZACK-JOINDATE YYYY-MM-DD)
-    $(list_items X-ZACK-LEAVEDATE YYYY-MM-DD)
-
-    $([ -n "$values[SOUND]" ] && printf '
-      <audio controls="controls" class="item SOUND">
-        <source type="audio/ogg" src="data:audio/ogg;base64,%s" />
-      </audio>' "$values[SOUND]"
-    )
-    ${values[PHOTO]+<img class="item PHOTO" src="data:image/$values[PHOTO_TYPE];base64,$values[PHOTO]" />}
-    ${values[LOGO]+<img class="item LOGO" src="data:image/$values[LOGO_TYPE];base64,$values[LOGO]" />}
-  </div>
-
-  <div class="section address">
-    $(list_items ADR)
-  </div>
-
-  <div class="section phone">
-    $(list_items TEL)
-    $(list_items EMAIL)
-    $(list_items IMPP)
-    $(list_items URL)
-  </div>
-
-  <div class="section insurance">
-    <h3>$(l10n X-HEALTH-INSURANCE)</h3>
-    <input type="radio" name="hi_select" value="list" id="hi_select_list" checked /><label for="hi_select_list">$(l10n hi_from_list)</label><!--
-    --><input type="radio" name="hi_select" value="other" id="hi_other"><label for="hi_other">$(l10n hi_other)</label>
-    <select class="item" name="hi_company">
-      <option value="" disabled="disabled" ${hi_company:-selected}>$(l10n hi_company)</option>
-      $(list_hi_companies |while read f; do
-        [ "$f" = "$hi_company" ] \
-        && printf '<option value="%s" selected>%s</option>' "$f" "$f" \
-        || printf '<option value="%s">%s</option>' "$f" "$f"
-      done)
-    </select>
-    <input type="text" name="hi_other" value="$hi_company" placeholder="$(l10n hi_company)" />
-    <input name="hi_number" value="$hi_number" placeholder="$(l10n hi_number)" />
-    <input name="hi_status" value="$hi_status" placeholder="$(l10n hi_status)" />
-
-  </div>
-
-  <div class="section note">
-    $(list_items NOTE)
-    $(list_items X-CLIENT-REFERRAL)
-  </div>
-
-  <div class="control">
-    <select class="item" name="newfield">
-      <option value="" disabled="disabled" selected="selected">$(l10n edit_addfieldtext)</option>
-      $(for f in $SUP_FIELDS; do printf %s\\n "<option value=\"$f\">$(l10n $f)</option>"; done)
-    </select
-    ><button class="item" type="submit" name="action" value="addfield">$(l10n edit_addfield)</button>
-    <button class="item" type="submit" name="action" value="update">$(l10n edit_update)</button>
-    <input type="checkbox" id="delete"><label class="item" for="delete">$(l10n edit_delete)</label>
-      <button class="item" type="submit" name="action" value="delete">$(l10n edit_delete)</button>
-    <button class="item" type="submit" name="action" value="cancel">$(l10n edit_cancel)</button>
-  </div>
-  <input type="hidden" name="UID" value="$values[UID]"/>
-</form>
-END_HTML