]> git.plutz.net Git - confetti/blob - cards/widgets.sh
reenabled filter dialog
[confetti] / cards / widgets.sh
1 # Copyright 2014 - 2019 Paul Hänsch
2 #
3 # This file is part of Confetti.
4
5 # Confetti is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # Confetti is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Affero General Public License for more details.
14
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
17
18 list_categories() {
19   grep -vxE '^[         ]*$' "${_DATA}/mappings/categories"
20 }
21
22 w_filter_item() {
23 n=$3
24 cat <<EOF
25   [fieldset .item
26     [legend $(l10n filter_item):]
27
28     $(for field in any name street zip TEL BDAY CATEGORIES; do
29       printf '[input id="%s%i" type="radio" name="filter_type%i" value="%s" %s]
30               [label for="%s%i" %s ]' \
31               "$field" "$n" "$n" "$field" "$([ "$1" = "$field" ] && printf checked )" \
32               "$field" "$n" "$(l10n filter_$field)"
33     done)
34     [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
35     [fieldset .categories
36       $(list_categories | while read cat; do
37           printf '[label [checkbox "filter_cat%i" "|%s" %s] %s ]' \
38                  "$n" "$(HTML "$cat")" \
39                  "$(printf %s "$cat" |grep -qxEe "$2" && printf checked )" \
40                  "$(HTML "$cat")"
41       done)
42       [a href="?p=categories" $(l10n edit_categories)]
43     ]
44   ]
45 EOF
46 }
47
48 w_filter_diag(){
49   cat <<EOF
50   [form .filter action="?action=filter_card" method="POST"
51     [h1 $(l10n filter_label)]
52     [input type="hidden" name="page" value="cards"]
53   
54     $(n=0; filter="${filter}^"
55       while [ "${filter#^}" ]; do
56         fil="${filter%%^*}" filter="${filter#*^}"
57         w_filter_item "${fil%%:*}" "${fil#*:}" $n
58         n=$((n + 1))
59       done
60       w_filter_item any '' $n
61     )
62   
63     [fieldset class="order"
64       [legend $(l10n filter_order):]
65       [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
66       [label [radio "order" "lastname"  $( [ "$order" = lastname  ] && printf checked )] $(l10n filter_lastname)]
67       [label [radio "order" "bdate"     $( [ "$order" = bdate     ] && printf checked )] $(l10n filter_bdate)]
68     ]
69     [button type="submit" name="choice" value="new_filter" $(l10n filter_apply)]
70     [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
71   ]
72 EOF
73 }
74
75 # listcards |grep ${edit:+-v} "$edit" \
76 # | while read card; do
77 #   "${_EXEC}"/cgilite/html-sh.sed <<-ENDCARD
78 #       [div #${card} .card
79 #         $(view_card "$card")[!--
80 #         --][div .control
81 #           [a "?action=edit_card&card=${card}" .item $(l10n edit)]
82 #           [a "?action=export_vcard&card=${card}".item $(l10n vcf_export)]
83 #           ${profile_medical:+[a "?action=new_prescription&client=${card}" .item $(l10n new_prescription)]}
84 #       ]]
85 #       ENDCARD
86 # done
87