diff options
author | Dave Arter <davea@mysociety.org> | 2016-10-19 14:47:28 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-10-19 14:47:28 +0100 |
commit | 4df7c01eb718bd51db1cc6078623e7b381a66d82 (patch) | |
tree | d1b11e3a846dbdf785b14230022d0d9c578e0a41 | |
parent | 9756df6ab27f96d4f466ee98722baaf7e751c34f (diff) | |
parent | 6b0712422ee13384da68f5cae8ef2f5274aa6318 (diff) |
Merge branch 'issues/forcouncils/66-priority-description'
-rwxr-xr-x | bin/update-schema | 1 | ||||
-rw-r--r-- | db/downgrade_0047---0046.sql | 6 | ||||
-rw-r--r-- | db/schema.sql | 1 | ||||
-rw-r--r-- | db/schema_0047-response-priorities-add-description.sql | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/ResponsePriority.pm | 6 | ||||
-rw-r--r-- | t/app/controller/admin.t | 2 | ||||
-rw-r--r-- | templates/web/base/admin/category-checkboxes.html | 18 | ||||
-rw-r--r-- | templates/web/base/admin/responsepriorities/edit.html | 21 | ||||
-rw-r--r-- | templates/web/base/admin/responsepriorities/list.html | 14 | ||||
-rw-r--r-- | templates/web/base/admin/template_edit.html | 21 | ||||
-rw-r--r-- | web/js/fixmystreet-admin.js | 7 |
13 files changed, 78 insertions, 28 deletions
diff --git a/bin/update-schema b/bin/update-schema index 500e771f1..479a55c8e 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -194,6 +194,7 @@ else { # By querying the database schema, we can see where we're currently at # (assuming schema change files are never half-applied, which should be the case) sub get_db_version { + return '0047' if column_exists('response_priorities', 'description'); return '0046' if column_exists('users', 'extra'); return '0045' if table_exists('response_priorities'); return '0044' if table_exists('contact_response_templates'); diff --git a/db/downgrade_0047---0046.sql b/db/downgrade_0047---0046.sql new file mode 100644 index 000000000..2f07c44ea --- /dev/null +++ b/db/downgrade_0047---0046.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE response_priorities + DROP COLUMN description; + +COMMIT; diff --git a/db/schema.sql b/db/schema.sql index fe45fb4aa..d3bb5040e 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -134,6 +134,7 @@ CREATE TABLE response_priorities ( body_id int references body(id) not null, deleted boolean not null default 'f', name text not null, + description text, unique(body_id, name) ); diff --git a/db/schema_0047-response-priorities-add-description.sql b/db/schema_0047-response-priorities-add-description.sql new file mode 100644 index 000000000..1aa856d75 --- /dev/null +++ b/db/schema_0047-response-priorities-add-description.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE response_priorities + ADD COLUMN description TEXT; + +COMMIT; diff --git a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm index ce17390d9..032e593c6 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm @@ -69,6 +69,7 @@ sub edit : Path : Args(2) { if ($c->req->method eq 'POST') { $priority->deleted( $c->get_param('deleted') ? 1 : 0 ); $priority->name( $c->get_param('name') ); + $priority->description( $c->get_param('description') ); $priority->update_or_insert; my @live_contact_ids = map { $_->id } @live_contacts; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 855732f83..13fd74807 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -681,7 +681,7 @@ sub response_priorities { return $self->result_source->schema->resultset('ResponsePriority')->search( { 'me.body_id' => $self->bodies_str_ids, - 'contact.category' => $self->category, + 'contact.category' => [ $self->category, undef ], }, { order_by => 'name', diff --git a/perllib/FixMyStreet/DB/Result/ResponsePriority.pm b/perllib/FixMyStreet/DB/Result/ResponsePriority.pm index d312fbcea..6bc8474fa 100644 --- a/perllib/FixMyStreet/DB/Result/ResponsePriority.pm +++ b/perllib/FixMyStreet/DB/Result/ResponsePriority.pm @@ -24,6 +24,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0 }, "deleted", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "description", + { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint("response_priorities_body_id_name_key", ["body_id", "name"]); @@ -47,8 +49,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-07 11:01:40 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B1swGtQzC3qRa0LUM4IyzA +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-10-17 16:37:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wok3cPA7cPjG4e9lnc1PIg __PACKAGE__->many_to_many( contacts => 'contact_response_priorities', 'contact' ); diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 7ba84b652..a0e013459 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1453,6 +1453,7 @@ subtest "response priorities can be added" => sub { my $fields = { name => "Cat 1A", + description => "Fixed within 24 hours", deleted => undef, "contacts[".$oxfordshirecontact->id."]" => 1, }; @@ -1466,6 +1467,7 @@ subtest "response priorities can be listed" => sub { $mech->get_ok( "/admin/responsepriorities/" . $oxfordshire->id ); $mech->content_contains( $oxfordshire->response_priorities->first->name ); + $mech->content_contains( $oxfordshire->response_priorities->first->description ); }; subtest "response priorities are limited by body" => sub { diff --git a/templates/web/base/admin/category-checkboxes.html b/templates/web/base/admin/category-checkboxes.html new file mode 100644 index 000000000..63acd4112 --- /dev/null +++ b/templates/web/base/admin/category-checkboxes.html @@ -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> diff --git a/templates/web/base/admin/responsepriorities/edit.html b/templates/web/base/admin/responsepriorities/edit.html index 89f41a069..4d838eed2 100644 --- a/templates/web/base/admin/responsepriorities/edit.html +++ b/templates/web/base/admin/responsepriorities/edit.html @@ -14,18 +14,17 @@ <input type="text" name="name" class="required form-control" size="30" value="[% rp.name | 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> + <strong>[% loc('Description:') %] </strong> + <input type="text" name="description" class="form-control" size="30" value="[% rp.description | html %]"> </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 %]> diff --git a/templates/web/base/admin/responsepriorities/list.html b/templates/web/base/admin/responsepriorities/list.html index c893a4c70..4c05ca14d 100644 --- a/templates/web/base/admin/responsepriorities/list.html +++ b/templates/web/base/admin/responsepriorities/list.html @@ -4,13 +4,25 @@ <thead> <tr> <th> [% loc('Name') %] </th> + <th> [% loc('Description') %] </th> + <th> [% loc('Categories') %] </th> <th> </th> </tr> </thead> <tbody> [% FOR p IN response_priorities %] <tr [% 'class="is-deleted"' IF p.deleted %]> - <td> [% p.name %] </td> + <td> [% p.name | html %] </td> + <td> [% p.description | html %] </td> + <td> + [% UNLESS p.contacts.size %] + <em>[% loc('All categories') %]</em> + [% ELSE %] + [% FOR contact IN p.contacts %] + [% contact.category %][% ',' UNLESS loop.last %] + [% END %] + [% END %] + </td> <td> <a href="[% c.uri_for('', body.id, p.id) %]" class="btn">[% loc('Edit') %]</a> </td> </tr> [% END %] diff --git a/templates/web/base/admin/template_edit.html b/templates/web/base/admin/template_edit.html index 8ce3c28dd..b2e734756 100644 --- a/templates/web/base/admin/template_edit.html +++ b/templates/web/base/admin/template_edit.html @@ -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') %]" > diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index 8191fc254..0323b1742 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -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(){ |