From: paul Date: Fri, 13 Oct 2017 10:34:37 +0000 (+0000) Subject: interface for combined filters X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=8144adb77a33850bca9c60f0b040b39f4a5da91f;p=lobster interface for combined filters svn path=/trunk/; revision=157 --- diff --git a/actions/filter_card.sh b/actions/filter_card.sh index b5ce333..cc0f912 100755 --- a/actions/filter_card.sh +++ b/actions/filter_card.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014, 2017 Paul Hänsch # # This file is part of Confetti. # @@ -19,25 +19,15 @@ cgi_post -case "${_POST[choice]}"; in - new_filter) - for n in '' {0..100}; do - debug "N: $n; ${_POST[filter$n]}" - [ -z "${_POST[filter$n]+x}" ] && break - filterval="${_POST[filter$n]}" - filtertype="${_POST[filtertype$n]}" - filter="${filtertype}:${filterval}${filter+^${filter}}" - done - order="${_POST[order]}" - echo -n "Location: ?p=cards&filter=$filter&filtertype=advanced&order=$order\n\n" - ;; - #new_filter) - # filter="${_POST[filter]}" - # filtertype="${_POST[filtertype]}" - # order="${_POST[order]}" - # echo -n "Location: ?p=cards&filter=$filter&filtertype=$filtertype&order=$order\n\n" - # ;; - *) - echo -n "Location: ?p=cards\n\n" - ;; -esac +if [ "${_POST[choice]}" = new_filter ]; then + filter="$( + for n in filter{0..100}; do + # [ -z "${_POST[$n]:+x}" ] && break + printf %s "${_POST[$n]}" + done \ + | sed -r 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; s;^\^;;; s;\^[^:]*:$;;;' + )" + printf 'Location: ?p=cards&order=%s&filter=%s\n\n' "${_POST[order]}" "$filter" +else + printf 'Location: ?p=cards\n\n' +fi diff --git a/pages/cards.sh b/pages/cards.sh index 506022f..b836f6b 100755 --- a/pages/cards.sh +++ b/pages/cards.sh @@ -76,7 +76,7 @@ listcards() { *:*) expr="${each%%:*}"'(\;[^\n]+)*:[^\n]*'"(${each#*:})";; *) expr="(${each})";; esac - filterex='/(^|\n)'"${expr}"'/{'"${filterex}"'}' + filterex='/(^|\n)'"${expr}"'/I{'"${filterex}"'}' done for file in "${_DATA}/vcard/"*.vcf; do diff --git a/static/cards.css b/static/cards.css index 002e66b..981a667 100644 --- a/static/cards.css +++ b/static/cards.css @@ -1,5 +1,5 @@ /* -# Copyright 2014 - 2016 Paul Hänsch +# Copyright 2014 - 2017 Paul Hänsch # # This file is part of Confetti. # @@ -66,7 +66,8 @@ .filter fieldset.item { padding-left: 0; } .filter fieldset.item legend { display: none; } -.filter fieldset.item input[type=text] { +.filter fieldset.item input[type=text], +.filter fieldset.item fieldset.categories { background-color: #FFF; border: 1px solid #000; margin-top: -1px; @@ -83,6 +84,18 @@ 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 { + display: none; +} +.filter fieldset.item input[type=radio][value="CATEGORIES:"]:checked + label + input[type=text] + fieldset.categories { + display: block; +} +.filter fieldset.item fieldset.categories a { + font-size: .875em; + line-height: 1.625em; + color: #44C; +} .newcard { display: block; diff --git a/templates/cards.html.sh b/templates/cards.html.sh index 377ccf8..bf84eee 100755 --- a/templates/cards.html.sh +++ b/templates/cards.html.sh @@ -1,4 +1,4 @@ -# Copyright 2014 - 2016 Paul Hänsch +# Copyright 2014 - 2017 Paul Hänsch # # This file is part of Confetti. # @@ -15,47 +15,84 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . +setchecked() { + printf 'checked="checked"' +} check_type(){ - #[ "${_GET[filtertype]}" = "$1" ] && echo 'checked="checked"' - [ "${_GET[filter]%%:*}" = "$1" ] && echo 'checked="checked"' + [ "${_GET[filter]%%:*}" = "$1" ] && setchecked } check_order(){ - [ "${_GET[order]}" = "$1" ] && echo 'checked="checked"' + [ "${_GET[order]}" = "$1" ] && setchecked } +filter_item() { cat < -

$(l10n filter_label)

-
- $(l10n filter_item): - - + $(l10n filter_item): + - - + + - - + + - - + - - + + - - + + - - - + -->
+EOF +} + +cat < +

$(l10n filter_label)

+ + + $( + n=0; m="$(list_categories |wc -l)" + printf '%s\n' "${_GET[filter]}" |tr '^' '\n' \ + | while read filter; do + [ -n "$filter" ] && filter_item "${filter%%:*}" "${filter#*:}" "$n" + n=$((n + 3 + m)) + done + filter_item any '' "$n" + )
$(l10n filter_order): diff --git a/templates/text_cards.sh b/templates/text_cards.sh index be2efa7..aaa6832 100755 --- a/templates/text_cards.sh +++ b/templates/text_cards.sh @@ -93,6 +93,7 @@ item_name[label_join]="Anm." item_name[label_leave]="Abm." item_name[edit]="Bearbeiten" +item_name[edit_categories]="Kategorien Bearbeiten" item_name[vcf_export]="Vcard Exportieren" item_name[control]="Aktionen" item_name[edit_update]="Daten übernehmen"