]> git.plutz.net Git - lobster/commitdiff
reenabled filter dialog
authorPaul Hänsch <paul@plutz.net>
Mon, 4 Feb 2019 17:11:28 +0000 (18:11 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 4 Feb 2019 17:11:28 +0000 (18:11 +0100)
cards/cards.css
cards/filter_card.sh
cards/main.cgi
cards/widgets.sh

index 981a667e217e69876d4f24170ddabedefff137c4..9515e835233f20cb988d081e38de8148759cc0d9 100644 (file)
@@ -39,7 +39,8 @@
 }
 .filter input[type="text"] {
   width: 100%;
-  margin-bottom: .5em;
+  height: 2em;
+  margin-bottom: 1em;
 }
 .filter fieldset {
   position: relative;
   border: 1px solid #000;
   border-bottom-color: #FFF;
 }
-.filter fieldset.item input[type=radio][value="CATEGORIES:"]:checked + label + input[type=text],
-.filter fieldset.item input[type=radio][value="CATEGORIES:"] + label + input[type=text] + fieldset.categories {
+.filter fieldset.item input[type=radio][value="CATEGORIES"]:checked + label + input[type=text],
+.filter fieldset.item input[type=radio][value="CATEGORIES"] + label + input[type=text] + fieldset.categories {
   display: none;
 }
-.filter fieldset.item input[type=radio][value="CATEGORIES:"]:checked + label + input[type=text] + fieldset.categories {
+.filter fieldset.item input[type=radio][value="CATEGORIES"]:checked + label + input[type=text] + fieldset.categories {
   display: block;
 }
 .filter fieldset.item fieldset.categories a {
index d09adabc07cf5f23c8b9d5925cf296835f3cb09a..9c79459fab9fe4b84dda311bd7e70c8d876c8caa 100755 (executable)
 if [ "$(POST choice)" = new_filter ]; then
   filter="$(
     seq 0 100 |while read n; do
-      printf %s "$(POST filter$n)"
+      filter_type="$(POST "filter_type${n}")"
+      filter_text="$(POST "filter_text${n}")"
+      [ ! "$filter_type" -a ! "$filter_text"  ] && break
+      if [ "$filter_type" = CATEGORIES ]; then
+        printf '^CATEGORIES:'
+        seq 0 $(POST_COUNT filter_cat$n) |while read m; do
+          printf '|%s' "$(POST filter_cat$n $m)"
+        done
+      else
+        printf '^%s:%s' "$filter_type" "$filter_text"
+      fi
     done | sed -r \
            's;\|+;\|;g;   s;\^+;\^;g;   s;:\|;:;g;
             :X;   s;\^[^:]*:\^;\^;g;   /\^[^:]*:\^/bX;
index 6cdc8f21a4498bcd8d37c9011ee1ab37a82e5c7c..bfc574f25d50998a8af7bd31b88c7f20ce58b64d 100755 (executable)
@@ -19,7 +19,7 @@ order="$(GET order)"
 printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
 
 $_EXEC/cgilite/html-sh.sed <<EOF
-[!DOCTYPE HTML]
+[!DOCTYPE XHTML]
 [html [head
   [title Cards]
   [link rel="stylesheet" type="text/css" href="/style.css"]
index 5a80ae71ca127ad66e65c6c1f686659d1eceed45..76057a6a61f6968cc6b40b9bd05b162745ec69d1 100755 (executable)
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
+list_categories() {
+  grep -vxE '^[        ]*$' "${_DATA}/mappings/categories"
+}
+
 w_filter_item() {
+n=$3
 cat <<EOF
   [fieldset .item
     [legend $(l10n filter_item):]
-    [input type="hidden" name="filter${n}" value="^"]
 
     $(for field in any name street zip TEL BDAY CATEGORIES; do
-      printf '[input id="%s%i" type="radio" name="filter%i" value="%s" %s]
-              [label for="%s%i" %s]' \
-              "$field" "$n" "$((n + 1))" "$field" "$([ "$1" = "$field" ] && printf checked )" \
+      printf '[input id="%s%i" type="radio" 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$((n + 2))" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
+    [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
     [fieldset .categories
-      $(m=3; list_categories | while read cat; do
-          printf '[label [checkbox "filter%i" "|%s" %s] %s ]' \
-                 "$((n + m))" "$(HTML "$cat")" \
-                 "$(printf %s "$cat" |grep -qEx "$2" && printf checked )" \
+      $(list_categories | while read cat; do
+          printf '[label [checkbox "filter_cat%i" "|%s" %s] %s ]' \
+                 "$n" "$(HTML "$cat")" \
+                 "$(printf %s "$cat" |grep -qxEe "$2" && printf checked )" \
                  "$(HTML "$cat")"
-          m=$((m + 1))
       done)
       [a href="?p=categories" $(l10n edit_categories)]
     ]
@@ -48,14 +51,13 @@ w_filter_diag(){
     [h1 $(l10n filter_label)]
     [input type="hidden" name="page" value="cards"]
   
-    $(
-    n=0; m="$(list_categories |wc -l)"
-    printf '%s\n' "$filter" |tr '^' '\n' \
-    | while read filter; do
-      [ -n "$filter" ] && w_filter_item "${filter%%:*}" "${filter#*:}" "$n"
-      n=$((n + 3 + m))
-    done
-    w_filter_item any '' "$n"
+    $(n=0; filter="${filter}^"
+      while [ "${filter#^}" ]; do
+        fil="${filter%%^*}" filter="${filter#*^}"
+        w_filter_item "${fil%%:*}" "${fil#*:}" $n
+        n=$((n + 1))
+      done
+      w_filter_item any '' $n
     )
   
     [fieldset class="order"