From 7c77e03c5ac280c7cfab23614835c94d57b1ce68 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 18:08:15 -0700 Subject: [PATCH 01/10] Initial rework of locations display Signed-off-by: snipe --- app/Models/Location.php | 18 + resources/views/locations/view.blade.php | 316 ++++++++++-------- .../partials/asset-bulk-actions.blade.php | 2 +- .../partials/users-bulk-actions.blade.php | 19 ++ resources/views/users/index.blade.php | 20 +- 5 files changed, 214 insertions(+), 161 deletions(-) create mode 100644 resources/views/partials/users-bulk-actions.blade.php diff --git a/app/Models/Location.php b/app/Models/Location.php index a85c8905e0..07ca6c8a18 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -103,6 +103,7 @@ class Location extends SnipeModel return $this->hasMany(\App\Models\User::class, 'location_id'); } + public function assets() { return $this->hasMany(\App\Models\Asset::class, 'location_id') @@ -129,6 +130,23 @@ class Location extends SnipeModel return $this->hasMany(\App\Models\Asset::class, 'rtd_location_id'); } + public function consumables() + { + return $this->hasMany(\App\Models\Consumable::class, 'location_id'); + } + + public function components() + { + return $this->hasMany(\App\Models\Component::class, 'location_id'); + } + + public function accessories() + { + return $this->hasMany(\App\Models\Accessory::class, 'location_id'); + } + + + public function parent() { return $this->belongsTo(self::class, 'parent_id', 'id') diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 771538df5e..cd9bafc733 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -15,178 +15,212 @@ -
-
-
-

{{ trans('general.assets') }}

-
-
-
+
+

{{ trans('general.assets') }}

- - @include('partials.asset-bulk-actions') - -
- - -
+ -
-
-
+
+ -
-
-
-

{{ trans('general.accessories') }}

-
-
-
-
- +
+
-
+ +
+
-
- - -
-
-
-

{{ trans('general.consumables') }}

-
-
-
-
- - $location->id]) }}" + data-export-options='{ "fileName": "export-locations-{{ str_slug($location->name) }}-consumables-{{ date('Y-m-d') }}", "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> -
+ -
-
-
+ + -
-
-
-

{{ trans('general.components') }}

-
-
-
-
+
- $location->id])}}" + data-export-options='{ "fileName": "export-locations-{{ str_slug($location->name) }}-components-{{ date('Y-m-d') }}", "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> -
-
-
-
- + +
+ + +
diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index 4a24a34ced..62b185a7b4 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -1,4 +1,4 @@ -
+
{{ Form::open([ 'method' => 'POST', 'route' => ['hardware/bulkedit'], diff --git a/resources/views/partials/users-bulk-actions.blade.php b/resources/views/partials/users-bulk-actions.blade.php new file mode 100644 index 0000000000..ab66462159 --- /dev/null +++ b/resources/views/partials/users-bulk-actions.blade.php @@ -0,0 +1,19 @@ +{{ Form::open([ + 'method' => 'POST', + 'route' => ['users/bulkedit'], + 'class' => 'form-inline', + 'id' => 'bulkForm']) }} + +@if (request('status')!='deleted') + @can('delete', \App\Models\User::class) +
+ + + +
+ @endcan +@endif \ No newline at end of file diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index 82d3d81a87..f3a51a6a5d 100755 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -38,26 +38,8 @@
- {{ Form::open([ - 'method' => 'POST', - 'route' => ['users/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} - - @if (request('status')!='deleted') - @can('delete', \App\Models\User::class) -
- - - -
- @endcan - @endif + @include('partials.users-bulk-actions') Date: Sun, 5 Jun 2022 20:13:51 -0700 Subject: [PATCH 02/10] Additional JS tweaking Signed-off-by: snipe --- resources/views/locations/view.blade.php | 4 ++- .../partials/asset-bulk-actions.blade.php | 4 +-- .../views/partials/bootstrap-table.blade.php | 34 +++++++++++++------ .../partials/users-bulk-actions.blade.php | 10 +++--- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index cd9bafc733..5108688853 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -98,6 +98,8 @@ data-show-refresh="true" data-sort-order="asc" data-toolbar="#toolbar" + data-bulk-action-id="#bulkEditButton" + data-bulk-form-id="#usersBulkForm" id="usersTable" class="table table-striped snipe-table" data-url="{{route('api.users.index', ['location_id' => $location->id])}}" @@ -126,7 +128,7 @@ data-show-export="true" data-show-refresh="true" data-sort-order="asc" - data-toolbar="#toolbar" + data-toolbar="#assetToolbar" id="assetsListingTable" class="table table-striped snipe-table" data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}" diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index 62b185a7b4..cf75fcfcd8 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -1,9 +1,9 @@ -
+
{{ Form::open([ 'method' => 'POST', 'route' => ['hardware/bulkedit'], 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + 'id' => 'assetToolbar']) }}
\ No newline at end of file From 9b54077409765e559f1f5c638c4fd87079ce46aa Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 21:02:19 -0700 Subject: [PATCH 03/10] Additional tweaks to BS tables partial Signed-off-by: snipe --- .../views/partials/bootstrap-table.blade.php | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 126162b872..f2036db60b 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -114,11 +114,12 @@ // These methods dynamically add/remove hidden input values in the bulk actions form $('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) { - var buttonName = $(this).data('bulk-action-id'); - var formName = this; + var buttonName = $(this).data('bulk-button-id'); + var formName = $(this).data('bulk-form-id'); + var tableId = $(this).data('id-table'); $(buttonName).removeAttr('disabled'); - $(formName).prepend(''); + $(formName).prepend(''); }); $('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) { @@ -126,44 +127,48 @@ }); + $('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) { + + var buttonName = $(this).data('bulk-button-id'); + $(buttonName).removeAttr('disabled'); + var formName = $(this).data('bulk-form-id'); + var tableId = $(this).data('id-table'); + + for (var i in rowsAfter) { + $(formName).prepend(''); + } + }); + + // Handle whether or not the edit button should be disabled $('.snipe-table').on('uncheck.bs.table', function () { - var buttonName = $(this).data('bulk-action-id'); + var buttonName = $(this).data('bulk-button-id'); console.log('Something was unchecked'); - console.log($('.snipe-table').bootstrapTable('getSelections').length); + console.log($(this).bootstrapTable('getSelections').length); + console.log(buttonName); - if ($('.snipe-table').bootstrapTable('getSelections').length == 0) { - console.log('length is 0'); + var formName = $(this).data('id'); + + if ($(this).bootstrapTable('getSelections').length == 0) { $(buttonName).attr('disabled', 'disabled'); } }); $('.snipe-table').on('uncheck-all.bs.table', function (event, rowsAfter, rowsBefore) { - var buttonName = $(this).data('bulk-action-id'); + var buttonName = $(this).data('bulk-button-id'); $(buttonName).attr('disabled', 'disabled'); - console.log('all are unchecked'); + var tableId = $(this).data('id-table'); for (var i in rowsBefore) { - $( "#checkbox_" + rowsBefore[i].id).remove(); + $( tableId + "_checkbox_" + rowsBefore[i].id).remove(); } }); - $('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) { - var buttonName = $(this).data('bulk-action-id'); - $(buttonName).removeAttr('disabled'); - var formName = this; - console.log('check all fired'); - - for (var i in rowsAfter) { - // console.log(rowsAfter[i].id); - $(formName).prepend(''); - } - }); From 880828379e94612eac2e2bc2b5eb55b7fb39013a Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 21:02:51 -0700 Subject: [PATCH 04/10] Update bulki partials with new values Signed-off-by: snipe --- resources/views/partials/asset-bulk-actions.blade.php | 6 +++--- resources/views/partials/users-bulk-actions.blade.php | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index cf75fcfcd8..2adb62c996 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -1,9 +1,9 @@ -
+
{{ Form::open([ 'method' => 'POST', 'route' => ['hardware/bulkedit'], 'class' => 'form-inline', - 'id' => 'assetToolbar']) }} + 'id' => 'assetsBulkForm']) }}
\ No newline at end of file diff --git a/resources/views/partials/users-bulk-actions.blade.php b/resources/views/partials/users-bulk-actions.blade.php index e19c54c519..016f549214 100644 --- a/resources/views/partials/users-bulk-actions.blade.php +++ b/resources/views/partials/users-bulk-actions.blade.php @@ -1,4 +1,4 @@ -
+
{{ Form::open([ 'method' => 'POST', 'route' => ['users/bulkedit'], @@ -10,12 +10,13 @@
- +
@endcan @endif + {{ Form::close() }}
\ No newline at end of file From 4db9892f8cf00f131febb1134b2b5dc1dcd92134 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 21:03:12 -0700 Subject: [PATCH 05/10] Use partial in overdue audit screen Signed-off-by: snipe --- resources/views/hardware/audit-overdue.blade.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/resources/views/hardware/audit-overdue.blade.php b/resources/views/hardware/audit-overdue.blade.php index a2511add9c..38d7d7935b 100644 --- a/resources/views/hardware/audit-overdue.blade.php +++ b/resources/views/hardware/audit-overdue.blade.php @@ -23,11 +23,7 @@
- {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + @include('partials.asset-bulk-actions')
@@ -45,7 +41,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsAuditListingTable" class="table table-striped snipe-table" data-url="{{ route('api.asset.to-audit', ['audit' => 'overdue']) }}" From 5326ebd136f30beb6c6ba8d045ff3428e6064287 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 21:03:45 -0700 Subject: [PATCH 06/10] =?UTF-8?q?Removed=20toolbar=20div=20we=20weren?= =?UTF-8?q?=E2=80=99t=20using?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- resources/views/components/index.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/components/index.blade.php b/resources/views/components/index.blade.php index 1b905ebff8..203609dcfe 100644 --- a/resources/views/components/index.blade.php +++ b/resources/views/components/index.blade.php @@ -21,7 +21,6 @@
Date: Sun, 5 Jun 2022 21:03:56 -0700 Subject: [PATCH 07/10] Update views with additional data fields Signed-off-by: snipe --- resources/views/account/requestable-assets.blade.php | 4 +++- resources/views/hardware/audit-due.blade.php | 4 +++- resources/views/hardware/index.blade.php | 4 +++- resources/views/locations/view.blade.php | 10 ++++++---- resources/views/models/index.blade.php | 11 +++++++---- resources/views/models/view.blade.php | 4 +++- resources/views/reports/asset.blade.php | 1 - resources/views/users/index.blade.php | 4 +++- resources/views/users/view.blade.php | 4 +++- 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/resources/views/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index 4ed4ae2740..27aad2c979 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -47,7 +47,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsListingTable" class="table table-striped snipe-table" data-url="{{ route('api.assets.requestable', ['requestable' => true]) }}"> diff --git a/resources/views/hardware/audit-due.blade.php b/resources/views/hardware/audit-due.blade.php index 644f2f69c0..cbbeb2fee6 100644 --- a/resources/views/hardware/audit-due.blade.php +++ b/resources/views/hardware/audit-due.blade.php @@ -43,7 +43,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsAuditListingTable" class="table table-striped snipe-table" data-url="{{ route('api.asset.to-audit', ['audit' => 'due']) }}" diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index 094c9fc1be..78abec91e4 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -84,7 +84,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsListingTable" class="table table-striped snipe-table" data-url="{{ route('api.assets.index', diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 5108688853..13448b2b13 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -90,15 +90,15 @@ data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}" data-cookie-id-table="usersTable" data-pagination="true" - data-id-table="usersTable" + data-id-table="#usersTable" data-search="true" data-side-pagination="server" data-show-columns="true" data-show-export="true" data-show-refresh="true" data-sort-order="asc" - data-toolbar="#toolbar" - data-bulk-action-id="#bulkEditButton" + data-toolbar="#userBulkEditToolbar" + data-bulk-button-id="#bulkUserEditButton" data-bulk-form-id="#usersBulkForm" id="usersTable" class="table table-striped snipe-table" @@ -128,7 +128,9 @@ data-show-export="true" data-show-refresh="true" data-sort-order="asc" - data-toolbar="#assetToolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsListingTable" class="table table-striped snipe-table" data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}" diff --git a/resources/views/models/index.blade.php b/resources/views/models/index.blade.php index bcc1d5f6fe..a8ca6a3072 100755 --- a/resources/views/models/index.blade.php +++ b/resources/views/models/index.blade.php @@ -35,22 +35,23 @@
+ {{ Form::open([ 'method' => 'POST', 'route' => ['models.bulkedit.index'], 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + 'id' => 'modelsBulkForm']) }}
@if (Request::get('status')!='deleted') -
+
- +
@endif
@@ -63,7 +64,9 @@ data-show-footer="true" data-side-pagination="server" data-show-columns="true" - data-toolbar="#toolbar" + data-toolbar="#modelsBulkEditToolbar" + data-bulk-button-id="#bulkModelsEditButton" + data-bulk-form-id="#modelsBulkForm" data-show-export="true" data-show-refresh="true" data-sort-order="asc" diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 3a4ddca44a..0027f61cd2 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -56,7 +56,9 @@ data-search="true" data-side-pagination="server" data-show-columns="true" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" data-show-export="true" data-show-refresh="true" data-sort-order="asc" diff --git a/resources/views/reports/asset.blade.php b/resources/views/reports/asset.blade.php index fd78405aa0..b70d69efe9 100644 --- a/resources/views/reports/asset.blade.php +++ b/resources/views/reports/asset.blade.php @@ -22,7 +22,6 @@
Date: Sun, 5 Jun 2022 21:11:50 -0700 Subject: [PATCH 08/10] Use translation string for model editing Signed-off-by: snipe --- resources/views/models/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/models/index.blade.php b/resources/views/models/index.blade.php index a8ca6a3072..8cda15ca40 100755 --- a/resources/views/models/index.blade.php +++ b/resources/views/models/index.blade.php @@ -51,7 +51,7 @@ - + @endif
From 89f45d3d05ee9f6cc579f72ae91f7c8115bf7eb7 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 21:16:29 -0700 Subject: [PATCH 09/10] Removed extra console logs and unused variable Signed-off-by: snipe --- resources/views/partials/bootstrap-table.blade.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index f2036db60b..9a63ca58bd 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -145,12 +145,6 @@ var buttonName = $(this).data('bulk-button-id'); - console.log('Something was unchecked'); - console.log($(this).bootstrapTable('getSelections').length); - console.log(buttonName); - - var formName = $(this).data('id'); - if ($(this).bootstrapTable('getSelections').length == 0) { $(buttonName).attr('disabled', 'disabled'); } From b26a4ad333c48b83c59be1fd5d69e615975b86ea Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 5 Jun 2022 21:35:57 -0700 Subject: [PATCH 10/10] Added missing headers Signed-off-by: snipe --- resources/views/locations/view.blade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 13448b2b13..cd203fb909 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -172,6 +172,8 @@
+

{{ trans('general.consumables') }}

+
- +

{{ trans('general.components') }}