X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=cards%2Fwidgets.sh;fp=cards%2Fwidgets.sh;h=c0c05946b1c594272d034a33081e351444873df9;hp=0000000000000000000000000000000000000000;hb=76c1e7bff1a8604ef2ef7da5d274d0db0e639139;hpb=90288ab07bb1ec83a91581fadc674a87a250a853 diff --git a/cards/widgets.sh b/cards/widgets.sh new file mode 100755 index 0000000..c0c0594 --- /dev/null +++ b/cards/widgets.sh @@ -0,0 +1,277 @@ +# Copyright 2014 - 2019, 2021 Paul Hänsch +# +# This file is part of Confetti. +# +# Confetti is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Confetti is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Confetti. If not, see . + +list_categories() { + grep -vxE '^[ ]*$' "${_DATA}/mappings/categories" +} + +list_courses() { + local file name cachefile="${_DATA}/cache/courses.ui.cache" + if [ $cachefile -nt "${_DATA}/ical" ]; then + cat "$cachefile" + else + for file in "$_DATA/ical"/*.ics; do + name="$(pdi_value "$(pdi_load "$file")" SUMMARY |HTML)" + printf '%s %s\n' "$file" "$name" + done \ + | sort -k2 |tee "$cachefile" + fi +} + +w_filter_item() { +n=$3 +cat <%s' \ + "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" + done + printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" + ;; + TEL) printf '[h3 %s]' "$(l10n "$item")" + seq 1 $cnt |while read c; do + printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \ + "$item" $c "$item" $c "$item" $c "$(l10n delete)" + teltype="$(pdi_attrib "$card" TEL $c TYPE)" + printf '[select .item .teltype name="teltype" + [option value="" disabled="disabled" %s %s] + [option value="HOME" %s %s] + [option value="WORK" %s %s] + [option value="CELL" %s %s] + [option value="FAX" %s %s] + ]\n' \ + "$([ "$teltype" = '' ] && printf 'selected="selected"')" "$(l10n teltype)" \ + "$([ "$teltype" = 'HOME' ] && printf 'selected="selected"')" "$(l10n TYPE=HOME)" \ + "$([ "$teltype" = 'WORK' ] && printf 'selected="selected"')" "$(l10n TYPE=WORK)" \ + "$([ "$teltype" = 'CELL' ] && printf 'selected="selected"')" "$(l10n TYPE=CELL)" \ + "$([ "$teltype" = 'FAX' ] && printf 'selected="selected"')" "$(l10n TYPE=FAX)" + + printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ + "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" + done + printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" + ;; + *)printf '[h3 %s]' "$(l10n "$item")" + seq 1 $cnt |while read c; do + printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \ + "$item" $c "$item" $c "$item" $c "$(l10n delete)" + printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \ + "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")" + done + printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)" + ;; + esac + done +}