]> git.plutz.net Git - confetti/commitdiff
separeted text view and edit section
authorpaul <paul@plutz.net>
Wed, 6 Nov 2013 12:21:02 +0000 (12:21 +0000)
committerpaul <paul@plutz.net>
Wed, 6 Nov 2013 12:21:02 +0000 (12:21 +0000)
svn path=/trunk/; revision=16

templates/attendees.html.sh
templates/edit_attendee.sh [new file with mode: 0755]
templates/text_attendee.sh [new file with mode: 0755]
templates/view_attendee.sh

index a4e6b52e09db67374d0199c71fb83786e9dc12da..c97bc463e7c13183759c0d06c123be44a173a57c 100644 (file)
@@ -1,4 +1,6 @@
+. ${_EXEC}/templates/text_attendee.sh
 . ${_EXEC}/templates/view_attendee.sh
+. ${_EXEC}/templates/edit_attendee.sh
 
 check(){
   [ "$_GET[\"filtertype\"]" = "$1" ] && echo 'checked="checked"'
@@ -11,15 +13,15 @@ cat <<EOF
     <span class="label">Filter:</span>
     <input type="hidden" name="page" value="attendees"/>
     <input type="text" name="filter" value="$_GET["filter"]"/><br/>
-    <input type="radio" name="filtertype" value="any" $(check any)>Alles</input>
-    <input type="radio" name="filtertype" value="name" $(check name)>Name</input>
-    <input type="radio" name="filtertype" value="street" $(check street)>Straße</input>
-    <input type="radio" name="filtertype" value="zip" $(check zip)>PLZ.</input>
-    <input type="radio" name="filtertype" value="telephone" $(check telephone)>Telefon</input>
-    <input type="radio" name="filtertype" value="birth" $(check birth)>Geburtsjahr</input>
-    <input type="radio" name="filtertype" value="course" $(check course)>Kurs</input><br/>
-    <button type="submit" name="action" value="new_filter">Filtern</button>
-    <button type="submit" name="action" value="del_filter">Filter löschen</button>
+    <input type="radio" name="filtertype" value="any" $(check any)>$(l10n filter_all)</input>
+    <input type="radio" name="filtertype" value="name" $(check name)>$(l10n filter_name)</input>
+    <input type="radio" name="filtertype" value="street" $(check street)>$(l10n filter_street)</input>
+    <input type="radio" name="filtertype" value="zip" $(check zip)>$(l10n filter_zip)</input>
+    <input type="radio" name="filtertype" value="telephone" $(check telephone)>$(l10n filter_phone)</input>
+    <input type="radio" name="filtertype" value="birth" $(check birth)>$(l10n filter_birthyear)</input>
+    <input type="radio" name="filtertype" value="course" $(check course)>$(l10n filter_course)</input><br/>
+    <button type="submit" name="action" value="new_filter">$(l10n filter_apply)</button>
+    <button type="submit" name="action" value="del_filter">$(l10n filter_cancel)</button>
   </div>
 </form>
 </div>
@@ -34,18 +36,28 @@ cat <<EOF
 </div>
 
 <div class="cardlist">
-  $(listcards |while read card; do
-    id="vcf_$card"
-    echo '<div id="'"$id"'" class="card">'
-    if [ "$_GET[\"edit\"]" = "$id" ]; then
-      debug "Edit: $card"
-      edit_attendee "$card"
-    else
-      echo '<p class="control"><a href="?page=attendees&edit='"$id"'#'"$id"'">Bearbeiten</a></p>'
-      view_attendee "$card"
-    fi
-    echo '</div>'
-  done)
+$(listcards |while read card; do
+  id="vcf_$card"
+  if [ "$_GET[\"edit\"]" = "$id" ]; then cat <<x_EOF
+  <div id="${id}" class="card">
+    <form action="/?page=attendees#${id}" method="POST">
+      <input type="hidden" name="page" value="attendees"/>
+      <input type="hidden" name="card" value="${id}"/>
+      $(edit_attendee "$card")
+      <br /><button type="submit" name="action" value="update">$(l10n edit_update)</button>
+      <br /><button type="submit" name="action" value="cancel">$(l10n edit_cancel)</button>
+    </form>
+  </div>
+x_EOF
+  debug "Edit: $card"
+  else cat <<x_EOF
+  <div id="${id}" class="card">
+    <p class="control"><a href="?page=attendees&edit=${id}#${id}">$(l10n edit)</a></p>
+    $(view_attendee "$card")
+  </div>
+x_EOF
+  fi
+done)
 </div>
 
 EOF
diff --git a/templates/edit_attendee.sh b/templates/edit_attendee.sh
new file mode 100755 (executable)
index 0000000..f2acb9f
--- /dev/null
@@ -0,0 +1,38 @@
+edit_card_item() {
+  case "$key" in
+    BEGIN|VERSION|END);;
+    PHOTO)
+      echo "<img class=\"PHOTO\" src=\"data:image/$tag[TYPE];base64,$value\"/>"
+      ;;
+    *)
+      echo -n "<span class=\"item\"><span class=\"KEY\">$(l10n "$key")"
+      [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
+      echo ":</span>"
+      ;|
+    *)
+      echo "<input class=\"VALUE\" name=\"$key\" value=\"$value\" /></item>"
+      ;;
+  esac
+}
+
+edit_attendee() {
+  cardfile="$1"
+  unset key
+  vcf_parse "$cardfile" |while read -r line; do
+    declare -A tag
+    case "$line" in
+      value*) eval "$line";;
+      tag*)   eval "$line";;
+      key*)
+        if [ -z "$key" ]; then
+          eval "$line"
+        else
+          edit_card_item
+          eval "$line"
+         unset value
+         unset tag
+        fi
+      ;;
+    esac
+  done
+}
diff --git a/templates/text_attendee.sh b/templates/text_attendee.sh
new file mode 100755 (executable)
index 0000000..6ce0466
--- /dev/null
@@ -0,0 +1,59 @@
+declare -A item_name
+
+item_name[PHOTO]="Foto"
+item_name[LOGO]="Logo"
+item_name[FN]="Voller Name"
+item_name[SOUND]="Aussprache"
+item_name[GENDER]="Geschlecht"
+item_name[KIND]="Typ"
+item_name[TITLE]="Beruf"
+item_name[ROLE]="Position"
+item_name[ORG]="Organisation"
+item_name[MEMBER]="Mitglied"
+item_name[CATEGORIES]="Kategorien"
+item_name[ANNIVERSARY]="Jubiläum"
+item_name[BDAY]="Geburtstag"
+item_name[EMAIL]="E-Mail"
+item_name[TEL]="Telefon"
+item_name[IMPP]="Chat"
+item_name[ADR]="Anschrift"
+item_name[URL]="Webseite"
+item_name[LANG]="Sprache"
+item_name[NOTE]="Notiz"
+
+item_name[RELATED]="Kontakte"
+
+item_name[BEGIN]=""
+item_name[CALADRURI]=""
+item_name[CALURI]=""
+item_name[CLASS]=""
+item_name[CLIENTPIDMAP]=""
+item_name[END]=""
+item_name[FBURL]=""
+item_name[GEO]=""
+item_name[MAILER]=""
+item_name[NAME]=""
+item_name[PRODID]=""
+item_name[PROFILE]=""
+item_name[REV]=""
+item_name[SORT-STRING]=""
+item_name[SOURCE]=""
+item_name[TZ]=""
+item_name[UID]=""
+item_name[VERSION]=""
+item_name[XML]=""
+
+item_name[edit]="Bearbeiten"
+item_name[filter_all]="Alles"
+item_name[filter_name]="Name"
+item_name[filter_street]="Straße"
+item_name[filter_zip]="PLZ."
+item_name[filter_phone]="Telefon"
+item_name[filter_birthyear]="Geburtsjahr"
+item_name[filter_course]="Kurs"
+item_name[filter_apply]="Filtern"
+item_name[filter_cancel]="Filter löschen"
+
+l10n() {
+  [ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
+}
index 01fb3f0383565c3f9baa56a26aac6b1eb2367705..5b7c77237bcf1a41e99725fd861c29ef7d4ef63d 100755 (executable)
@@ -1,52 +1,3 @@
-declare -A item_name
-
-item_name[PHOTO]="Foto"
-item_name[LOGO]="Logo"
-item_name[FN]="Voller Name"
-item_name[SOUND]="Aussprache"
-item_name[GENDER]="Geschlecht"
-item_name[KIND]="Typ"
-item_name[TITLE]="Beruf"
-item_name[ROLE]="Position"
-item_name[ORG]="Organisation"
-item_name[MEMBER]="Mitglied"
-item_name[CATEGORIES]="Kategorien"
-item_name[ANNIVERSARY]="Jubiläum"
-item_name[BDAY]="Geburtstag"
-item_name[EMAIL]="E-Mail"
-item_name[TEL]="Telefon"
-item_name[IMPP]="Chat"
-item_name[ADR]="Anschrift"
-item_name[URL]="Webseite"
-item_name[LANG]="Sprache"
-item_name[NOTE]="Notiz"
-
-item_name[RELATED]="Kontakte"
-
-item_name[BEGIN]=""
-item_name[CALADRURI]=""
-item_name[CALURI]=""
-item_name[CLASS]=""
-item_name[CLIENTPIDMAP]=""
-item_name[END]=""
-item_name[FBURL]=""
-item_name[GEO]=""
-item_name[MAILER]=""
-item_name[NAME]=""
-item_name[PRODID]=""
-item_name[PROFILE]=""
-item_name[REV]=""
-item_name[SORT-STRING]=""
-item_name[SOURCE]=""
-item_name[TZ]=""
-item_name[UID]=""
-item_name[VERSION]=""
-item_name[XML]=""
-
-l10n() {
-  [ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
-}
-
 view_card_item() {
   case "$key" in
     BEGIN|VERSION|END);;
@@ -73,23 +24,6 @@ view_card_item() {
   esac
 }
 
-edit_card_item() {
-  case "$key" in
-    BEGIN|VERSION|END);;
-    PHOTO)
-      echo "<img class=\"PHOTO\" src=\"data:image/$tag[TYPE];base64,$value\"/>"
-      ;;
-    *)
-      echo -n "<span class=\"item\"><span class=\"KEY\">$(l10n "$key")"
-      [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
-      echo ":</span>"
-      ;|
-    *)
-      echo "<input class=\"VALUE\" name=\"$key\" value=\"$value\" /></item>"
-      ;;
-  esac
-}
-
 view_attendee() {  #Parameter: Cardfile
   cardfile="$1"
   cachefile="cache/vcf_$(basename "$cardfile").cache"
@@ -113,25 +47,3 @@ view_attendee() {  #Parameter: Cardfile
     esac
   done |tee "$cachefile"
 }
-
-edit_attendee() {
-  cardfile="$1"
-  unset key
-  vcf_parse "$cardfile" |while read -r line; do
-    declare -A tag
-    case "$line" in
-      value*) eval "$line";;
-      tag*)   eval "$line";;
-      key*)
-        if [ -z "$key" ]; then
-          eval "$line"
-        else
-          edit_card_item
-          eval "$line"
-         unset value
-         unset tag
-        fi
-      ;;
-    esac
-  done
-}