Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight bulk edit tools and include guidance #252

Merged
merged 5 commits into from Apr 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/assets/javascripts/govuk.js
Expand Up @@ -59,6 +59,11 @@

GOVUK.startAll = function() {
GOVUK.start();
GOVUK.startBootstrapComponents();
}

GOVUK.startBootstrapComponents = function() {
$('[data-toggle="tooltip"]').tooltip();
}

// Google Analytics event tracking
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/modules/selectable_table.js
Expand Up @@ -142,10 +142,12 @@

function resetSubmitButtons() {
element.find('.js-submit-form').removeClass('disabled').button('reset');
element.find('.js-submit-container').addClass('buttons-enabled');
}

function disableSubmitButtons() {
element.find('.js-submit-form').addClass('disabled');
element.find('.js-submit-container').removeClass('buttons-enabled');
}
}
};
Expand Down
15 changes: 15 additions & 0 deletions app/assets/stylesheets/base.css.scss
Expand Up @@ -315,6 +315,10 @@ thead .table-header-secondary td {
overflow: hidden;
width: 40px;

tbody & {
background-color: #ccc;
}

label {
height: 300px;
width: 100%;
Expand All @@ -329,6 +333,11 @@ thead .table-header-secondary td {
}
}

.selectable-row-helper {
border-bottom: 1px dotted #999;
cursor: help;
}

/* Slightly different spacing for table headers */
.table-header-secondary .selectable-row {
vertical-align: top;
Expand All @@ -343,6 +352,12 @@ thead .table-header-secondary td {
background-color: #fffbcc; /* yellow highlight */
}

/* Specific to mappings selectable table
Ensures the tooltip only displays whilst the buttons are disabled */
.buttons-enabled + .tooltip {
display: none !important;
}

/* ==========================================================================
Common content patterns
========================================================================== */
Expand Down
4 changes: 3 additions & 1 deletion app/views/mappings/_mappings_table.html.erb
Expand Up @@ -12,7 +12,9 @@
<thead>
<tr class="table-header">
<% if current_user.can_edit_site?(site) %>
<th></th>
<th scope="col">
<span class="selectable-row-helper" data-toggle="tooltip" data-placement="bottom" title="Use checkboxes to select mappings you want to edit, and edit them using the ‘Archive’, ‘Redirect’ or ‘Tag’ buttons">Edit</span>
</th>
<% end %>
<th class="mapping-type-column" scope="col">Type</th>
<th scope="col">
Expand Down
2 changes: 1 addition & 1 deletion app/views/mappings/_mappings_table_header.html.erb
Expand Up @@ -24,7 +24,7 @@
<%= submit_tag "Edit selected", class: 'btn btn-default bold' %>
</div>
<% end %>
<div class="if-no-js-hide btn-group">
<div class="if-no-js-hide js-submit-container btn-group" data-toggle="tooltip" title="Select mappings using checkboxes then edit them with these buttons." data-placement="right">
<a href="#redirect-paths" class="btn btn-default js-submit-form disabled" data-type="301" data-loading-text="Loading…" title="Redirect the paths you’ve selected to a new URL">Redirect</a>
<a href="#archive-paths" class="btn btn-default js-submit-form disabled" data-type="410" data-loading-text="Loading…" title="Archive the paths you’ve selected">Archive</a>
<a href="#tag-paths" class="btn btn-default js-submit-form disabled" data-type="tag" data-loading-text="Loading…" title="Tag the paths you’ve selected">Tag</a>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mappings/edit.html.erb
@@ -1,7 +1,7 @@
<% breadcrumb(:edit_mapping, @mapping) %>

<%= content_for :page_title, 'Edit mapping' %>
<h1 class="page-title">
<h1 class="page-title-with-border">
<span class="small"><%= @site.default_host.hostname %></span>
Edit mapping
</h1>
Expand Down
3 changes: 0 additions & 3 deletions app/views/sites/_transition_status.html.erb
Expand Up @@ -8,6 +8,3 @@
<i data-toggle="tooltip" title="Site is partially redirected via an aka domain" class="glyphicon glyphicon-question-sign"></i>
</span>
<% end %>
<script>
$('[data-toggle]').tooltip();
</script>
2 changes: 0 additions & 2 deletions app/views/style/index.html.erb
Expand Up @@ -144,8 +144,6 @@
</tr>
</tbody>
</table>

<script>GOVUK.SelectableTable.setup();</script>
</ul>
</div>
<hr>
Expand Down
17 changes: 13 additions & 4 deletions spec/javascripts/spec/selectable_table.spec.js
Expand Up @@ -27,9 +27,11 @@ describe('A selectable table module', function() {
<thead>\
<tr>\
<th>\
<input type="checkbox" class="js-toggle-all disabled" />\
<input type="radio" value="type" />\
<a href="#" class="js-submit-form" data-type="type">Submit form hook</a>\
<div class="js-submit-container">\
<input type="checkbox" class="js-toggle-all disabled" />\
<input type="radio" value="type" />\
<a href="#" class="js-submit-form" data-type="type">Submit form hook</a>\
</div>\
</th>\
</tr>\
</thead>\
Expand Down Expand Up @@ -80,7 +82,12 @@ describe('A selectable table module', function() {
tableWithSelection = $('<table>\
<thead>\
<tr>\
<th><input type="checkbox" class="js-toggle-all disabled" /></th>\
<th>\
<div class="js-submit-container">\
<input type="checkbox" class="js-toggle-all disabled" />\
<a href="#" class="js-submit-form" data-type="type">Submit form hook</a>\
</div>\
</th>\
</tr>\
</thead>\
<tbody>\
Expand Down Expand Up @@ -116,6 +123,7 @@ describe('A selectable table module', function() {

it('enables the form submit buttons', function() {
expect(tableWithSelection.find('.js-submit-form.disabled').length).toBe(0);
expect(tableWithSelection.find('.buttons-enabled').length).toBe(1);
});

});
Expand Down Expand Up @@ -288,6 +296,7 @@ describe('A selectable table module', function() {
it('disables the submit form buttons to prevent multiple ajax requests', function() {
table.find('.js-submit-form').click();
expect(table.find('.js-submit-form.disabled').length).toBe(1);
expect(table.find('.buttons-enabled').length).toBe(0);
});

});
Expand Down