]> git.plutz.net Git - lobster/commitdiff
basic editing functions
authorpaul <paul@plutz.net>
Wed, 6 Nov 2013 02:34:31 +0000 (02:34 +0000)
committerpaul <paul@plutz.net>
Wed, 6 Nov 2013 02:34:31 +0000 (02:34 +0000)
svn path=/trunk/; revision=15

templates/attendees.html.sh
templates/view_attendee.sh

index c481c61c9077f24fc40661286e87da344ae9d2f8..a4e6b52e09db67374d0199c71fb83786e9dc12da 100644 (file)
@@ -35,8 +35,15 @@ cat <<EOF
 
 <div class="cardlist">
   $(listcards |while read card; do
-    echo '<div class="card">'
-    view_attendee "$card"
+    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)
 </div>
index 1e02e3db017c1845f1a753927c91d73e8029ccbd..01fb3f0383565c3f9baa56a26aac6b1eb2367705 100755 (executable)
@@ -73,6 +73,23 @@ 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"
@@ -96,3 +113,25 @@ 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
+}