}
.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 {
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;
# 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)]
]
[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"