support for maniupulating vcard categories
authorpaul <paul@plutz.net>
Wed, 11 Oct 2017 16:16:33 +0000 (16:16 +0000)
committerpaul <paul@plutz.net>
Wed, 11 Oct 2017 16:16:33 +0000 (16:16 +0000)
svn path=/trunk/; revision=151

pages/cards.sh
templates/edit_card.sh
templates/view_card.sh

index b9254ff..b0e7e94 100755 (executable)
@@ -58,6 +58,11 @@ list_hi_companies(){
   | sort -u
 }
 
+list_categories() {
+  catfile="${_DATA}/mappings/categories"
+  sort -u "$catfile"
+}
+
 listcards() {
   case "${_GET[filtertype]}" in
     any)
index b3af045..741a312 100755 (executable)
@@ -27,6 +27,16 @@ check_gen() {
 check_a() {
   egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked
 }
+check_c() {
+  for n in CATEGORIES CATEGORIES{0..100}; do
+    if [ -n "${values[$n]+x}" ]; then
+      [ "${values[$n]}" = "$1" ] && setchecked && break
+    else
+      break
+    fi
+  done
+}
+
 teltype() {
   cat <<-EOF
        <select class="item phonetype" name="phonetype">
@@ -141,6 +151,11 @@ if [ "$PROFILE" = circus ]; then
            printf '<label><input type="checkbox" name="attendance" value="%s" %s/>%s</label>' \
              "$(attribsafe "$each")" "$(check_a "$each")" "$(htmlsafe "$cname")"
          done)
+          <h3>$(l10n CATEGORIES)</h3>
+          $(list_categories |while read each; do
+            printf '<label><input type="checkbox" name="CATEGORIES" value="%s" %s/>%s</label>' \
+              "$(attribsafe "$each")" "$(check_c "$each")" "$(htmlsafe "$each")"
+          done)
        </div>
        END_HTML
 elif [ "$PROFILE" = medical ]; then
index 3319e07..9728d8f 100755 (executable)
@@ -94,7 +94,10 @@ if [ "$PROFILE" = circus ]; then
     cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")"
     printf '   <li><a class="item attendance" href="?p=courses#%s">%s</a></li>' "$each" "$(htmlsafe $cname)"
   done
-  printf '</ul></div>'
+  printf '</ul>'
+  list_items CATEGORIES
+  printf '</div>'
+
 elif [ "$PROFILE" = medical ]; then
   list_items ADR
   list_items URL