Skip to content

Commit

Permalink
Refactor template/priority category checkboxes into own template
Browse files Browse the repository at this point in the history
 - Also adds add select all/none UI
 - Adds admin hint for empty category list behaviour
  • Loading branch information
davea committed Oct 19, 2016
1 parent 58684be commit 255d42b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
18 changes: 18 additions & 0 deletions templates/web/base/admin/category-checkboxes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<p>
<strong>[% loc('Categories:') %]</strong>
</p>
<ul>
<li>
[% loc('Select:') %]
<a href="#" data-select-all>[% loc('all') %]</a> /
<a href="#" data-select-none>[% loc('none') %]</a>
</li>
[% FOR contact IN contacts %]
<li>
<label>
<input type="checkbox" name="contacts[[% contact.id %]]" [% 'checked' IF contact.active %]/>
[% contact.category %]
</label>
</li>
[% END %]
</ul>
21 changes: 8 additions & 13 deletions templates/web/base/admin/responsepriorities/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@
<strong>[% loc('Description:') %] </strong>
<input type="text" name="description" class="form-control" size="30" value="[% rp.description | html %]">
</p>
<p>
<strong>[% loc('Categories:') %]</strong>
<ul>
[% FOR contact IN contacts %]
<li>
<label>
<input type="checkbox" name="contacts[[% contact.id %]]" [% 'checked' IF contact.active %]/>
[% contact.category %]
</label>
</li>
[% END %]
</ul>
</p>

<div class="admin-hint">
<p>
[% loc('If you only want this priority to be an option for specific categories, pick them here. By default they will show for all categories.') %]
</p>
</div>
[% INCLUDE 'admin/category-checkboxes.html' %]

<p>
<label>
<input type="checkbox" name="deleted" id="deleted" value="1"[% ' checked' IF rp.deleted %]>
Expand Down
21 changes: 8 additions & 13 deletions templates/web/base/admin/template_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@
<input type="checkbox" name="auto_response" [% 'checked' IF rt.auto_response %] />
</label>
</p>
<p>
<strong>[% loc('Categories:') %]</strong>
<ul>
[% FOR contact IN contacts %]
<li>
<label>
<input type="checkbox" name="contacts[[% contact.id %]]" [% 'checked' IF contact.active %]/>
[% contact.category %]
</label>
</li>
[% END %]
</ul>
</p>

<div class="admin-hint">
<p>
[% loc('If you only want this template to be an option for specific categories, pick them here. By default they will show for all categories.') %]
</p>
</div>
[% INCLUDE 'admin/category-checkboxes.html' %]

<p>
<input type="hidden" name="token" value="[% csrf_token %]" >
<input type="submit" class="btn" name="Edit templates" value="[% rt.id ? loc('Save changes') : loc('Create template') %]" >
Expand Down
7 changes: 7 additions & 0 deletions web/js/fixmystreet-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ $(function(){
});
}

// Some lists of checkboxes have 'select all/none' links at the top
$("a[data-select-none], a[data-select-all]").click(function(e) {
e.preventDefault();
var checked = $(this).filter('[data-select-all]').length > 0;
$(this).closest("ul").find('input[type=checkbox]').prop('checked', checked);
});


// admin hints: maybe better implemented as tooltips?
$(".admin-hint").on('click', function(){
Expand Down

0 comments on commit 255d42b

Please sign in to comment.