]> git.plutz.net Git - confetti/blob - templates/categories.html.sh
generate name field from available information
[confetti] / templates / categories.html.sh
1 # Copyright 2015 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 cat_listing(){
19   list_categories | while read cat; do
20     cat <<-END
21         <li>${cat}<button type="submit" name="remove" value="${cat}">$(l10n cat_remove)</button></li>
22         END
23   done
24 }
25
26 list_catsel(){
27   card="$1"
28   cats="$(get_categories $card)"
29
30   list_categories |while read cat; do
31   cat <<-END
32         <li><label><input type="checkbox" name="$card" value="$cat"
33         $(printf %s "$cats" |grep -qF "$cat" && printf %s 'checked="checked"')>${cat}</label></li>
34         END
35   done
36 }
37
38 display_catsel(){
39   card="$1"
40   cat <<-END
41         <li><h2>$(get_name "$card")</h2><ul>$(list_catsel "$card")</ul></li>
42         END
43 }
44
45 cat <<EOF
46 <form class="categories" action="?action=edit_categories" method="POST">
47   <h1>$(l10n categories_label)</h1>
48   <input type="hidden" name="page" value="categories"/>
49   <ul>
50     $(cat_listing)
51     <li>
52       <input type="text" name="newcat" placeholder="$(l10n cat_newlabel)">
53       <button type="submit" name="add" value="add">$(l10n cat_add)</button>
54     </li>
55   </ul>
56 </form>
57
58 <form class="namelist" action="?action=update_categories" method="POST">
59   <fieldset>
60     <button type="submit" name="submit" value="submit">$(l10n cat_update)</button>
61   </fieldset>
62   <ul class="namelist">
63     $(listcards |while read card; do display_catsel "$card"; done )
64   </ul>
65   <fieldset>
66     <button type="submit" name="submit" value="submit">$(l10n cat_update)</button>
67   </fieldset>
68 </form>
69
70 EOF
71