Add basic checkbox support to new grids.

Also:

 * Add 'creatable', 'editable' etc. to master view class.
 * Add styles for warning/notice grid rows.
 * Misc. other tweaks.
This commit is contained in:
Lance Edgar 2015-08-14 15:30:38 -05:00
parent e79531fda8
commit d2b065a8fc
13 changed files with 229 additions and 71 deletions

View file

@ -44,7 +44,6 @@ p {
}
.right {
float: right;
text-align: right;
}

View file

@ -133,18 +133,46 @@
* tbody
******************************/
.newgrid table tbody td {
.newgrid tbody td {
padding: 5px 6px;
}
.newgrid table tbody tr:nth-child(odd) {
.newgrid.selectable tbody td {
cursor: default;
}
.newgrid tbody tr:nth-child(odd) {
background-color: #e0e0e0;
}
.newgrid table tbody tr.hovering {
.newgrid tbody tr.hovering {
background-color: #bbbbbb;
}
.newgrid tbody tr.notice {
background-color: #fd6;
}
.newgrid tbody tr.notice:nth-child(odd) {
background-color: #fe8;
}
.newgrid tbody tr.notice.hovering {
background-color: #ec7;
}
.newgrid tbody tr.warning {
background-color: #fcc;
}
.newgrid tbody tr.warning:nth-child(odd) {
background-color: #ebb;
}
.newgrid tbody tr.warning.hovering {
background-color: #daa;
}
/******************************
* main actions

View file

@ -115,6 +115,29 @@
$(this).removeClass('hovering');
});
// Do some extra stuff for grids with checkboxes.
if (this.grid.hasClass('selectable')) {
// (Un-)Check all rows when clicking check-all box in header.
this.element.on('click', 'thead th.checkbox input', function() {
var checked = $(this).prop('checked');
that.grid.find('tbody td.checkbox input').prop('checked', checked);
});
// Select current row when clicked, unless clicking checkbox
// (since that already does select the row) or a link (since
// that does something completely different).
this.element.on('click', 'tbody td.checkbox input', function(event) {
event.stopPropagation();
});
this.element.on('click', 'tbody a', function(event) {
event.stopPropagation();
});
this.element.on('click', 'tbody tr', function() {
$(this).find('td.checkbox input').click();
});
}
// Show 'more' actions when user hovers over 'more' link.
this.element.on('mouseenter', '.actions a.more', function() {
that.grid.find('.actions div.more').hide();

View file

@ -112,11 +112,6 @@ $(function() {
$('input[type=submit]').button();
$('input[type=reset]').button();
/*
* Enhance new-style grids.
*/
$('.newgrid-wrapper').gridwrapper();
/*
* When filter labels are clicked, (un)check the associated checkbox.
*/