A free open source IT asset/license management system
Handle bulk check and uncheck
snipe3594ec9905af
diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.phpindex 2cdad5e6bf..267b68a56c 100755--- a/resources/views/hardware/index.blade.php+++ b/resources/views/hardware/index.blade.php@@ -60,13 +60,18 @@<div class="row"><div class="col-md-12">+@if (Request::get('status')!='Deleted')- {{ Form::open([- 'method' => 'POST',- 'route' => ['hardware/bulkedit'],- 'class' => 'form-inline',- 'id' => 'bulkForm']) }}+++<div id="toolbar">+ {{ Form::open([+ 'method' => 'POST',+ 'route' => ['hardware/bulkedit'],+ 'class' => 'form-inline',+ 'id' => 'bulkForm']) }}+<label for="bulk_actions"><span class="sr-only">Bulk Actions</span></label><select name="bulk_actions" class="form-control select2" aria-label="bulk_actions">@@ -76,10 +81,9 @@</select><button class="btn btn-primary" id="bulkEdit" disabled>Go</button>-+ {{ Form::close() }}</div>- {{ Form::close() }}-+@endif<tablediff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex 1799241501..7ad14bf905 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -80,18 +80,7 @@$('[data-toggle="tooltip"]').tooltip(); // Needed to attach tooltips after ajax call}- });-- $('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) {- $('#bulkEdit').before('<input id="checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');- });--- $('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {- $( "#checkbox_" + $element.id).remove();- });--+ });});@@ -107,25 +96,47 @@}- // Handle whether or not the edit button should be disabled- $('.snipe-table').on('check.bs.table', function () {+ // These methods dynamically add/remove hidden input values in the bulk actions form+ $('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) {$('#bulkEdit').removeAttr('disabled');+ $('#bulkEdit').prepend('<input id="checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');});- $('.snipe-table').on('check-all.bs.table', function () {- $('#bulkEdit').removeAttr('disabled');+ $('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {+ $( "#checkbox_" + $element.id).remove();});++ // Handle whether or not the edit button should be disabled$('.snipe-table').on('uncheck.bs.table', function () {if ($('.snipe-table').bootstrapTable('getSelections').length == 0) {$('#bulkEdit').attr('disabled', 'disabled');}});- $('.snipe-table').on('uncheck-all.bs.table', function (e, row) {+ $('.snipe-table').on('uncheck-all.bs.table', function (event, rowsAfter, rowsBefore) {$('#bulkEdit').attr('disabled', 'disabled');+ //console.dir(rowsBefore);++ for (var i in rowsBefore) {+ $( "#checkbox_" + rowsBefore[i].id).remove();+ }++ });++ $('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) {++ $('#bulkEdit').removeAttr('disabled');+ //console.dir(rowsAfter);++ for (var i in rowsAfter) {+ // console.log(rowsAfter[i].id);+ $('#bulkEdit').prepend('<input id="checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');+ }});++// This only works for model index pages because it uses the row's model IDfunction genericRowLinkFormatter(destination) {return function (value,row) {