]> git.plutz.net Git - confetti/blob - cards/widgets.sh
refactoring card display
[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 w_filter_item() {
19 cat <<EOF
20   [fieldset .item
21     [legend $(l10n filter_item):]
22     [input type="hidden" name="filter${n}" value="^"]
23
24     $(for field in any name street zip TEL BDAY CATEGORIES; do
25       printf '[input id="%s%i" type="radio" name="filter%i" value="%s" %s]
26               [label for="%s%i" %s]' \
27               "$field" "$n" "$((n + 1))" "$field" "$([ "$1" = "$field" ] && printf checked )" \
28               "$field" "$n" "$(l10n filter_$field)"
29     done)
30     [input type="text" name="filter$((n + 2))" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
31     [fieldset .categories
32       $(m=3; list_categories | while read cat; do
33           printf '[label [checkbox "filter%i" "|%s" %s] %s ]' \
34                  "$((n + m))" "$(HTML "$cat")" \
35                  "$(printf %s "$cat" |grep -qEx "$2" && printf checked )" \
36                  "$(HTML "$cat")"
37           m=$((m + 1))
38       done)
39       [a href="?p=categories" $(l10n edit_categories)]
40     ]
41   ]
42 EOF
43 }
44
45 w_filter_diag(){
46   cat <<EOF
47   [form .filter action="?action=filter_card" method="POST"
48     [h1 $(l10n filter_label)]
49     [input type="hidden" name="page" value="cards"]
50   
51     $(
52     n=0; m="$(list_categories |wc -l)"
53     printf '%s\n' "$filter" |tr '^' '\n' \
54     | while read filter; do
55       [ -n "$filter" ] && w_filter_item "${filter%%:*}" "${filter#*:}" "$n"
56       n=$((n + 3 + m))
57     done
58     w_filter_item any '' "$n"
59     )
60   
61     [fieldset class="order"
62       [legend $(l10n filter_order):]
63       [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
64       [label [radio "order" "lastname"  $( [ "$order" = lastname  ] && printf checked )] $(l10n filter_lastname)]
65       [label [radio "order" "bdate"     $( [ "$order" = bdate     ] && printf checked )] $(l10n filter_bdate)]
66     ]
67     [button type="submit" name="choice" value="new_filter" $(l10n filter_apply)]
68     [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
69   ]
70 EOF
71 }
72
73 # listcards |grep ${edit:+-v} "$edit" \
74 # | while read card; do
75 #   "${_EXEC}"/cgilite/html-sh.sed <<-ENDCARD
76 #       [div #${card} .card
77 #         $(view_card "$card")[!--
78 #         --][div .control
79 #           [a "?action=edit_card&card=${card}" .item $(l10n edit)]
80 #           [a "?action=export_vcard&card=${card}".item $(l10n vcf_export)]
81 #           ${profile_medical:+[a "?action=new_prescription&client=${card}" .item $(l10n new_prescription)]}
82 #       ]]
83 #       ENDCARD
84 # done
85