From 5bda73f151d9c1f2f0c43b41b291745c80c45830 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 8 Aug 2023 08:18:40 +0100 Subject: [PATCH 1/9] Ugh - messing with the blade layout Signed-off-by: snipe --- resources/views/settings/localization.blade.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/views/settings/localization.blade.php b/resources/views/settings/localization.blade.php index 6e126dee6..d7ec45a92 100644 --- a/resources/views/settings/localization.blade.php +++ b/resources/views/settings/localization.blade.php @@ -38,7 +38,7 @@
-
+
@@ -52,17 +52,22 @@
+
{{ Form::label('time_display_format', trans('general.time_and_date_display')) }}
-
+
{!! Form::date_display_format('date_display_format', Request::old('date_display_format', $setting->date_display_format), 'select2') !!} - +
+
{!! Form::time_display_format('time_display_format', Request::old('time_display_format', $setting->time_display_format), 'select2') !!} - {!! $errors->first('time_display_format', '') !!} +
+ {!! $errors->first('time_display_format', '') !!} +
+

The date shown in the drop-down is just an example to display the different date formats. It is not meant to reflect today's date.

From bd4061e02355c05cb4ad3b7c47102e04552b1918 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 8 Aug 2023 08:18:56 +0100 Subject: [PATCH 2/9] Change text on dropdown Signed-off-by: snipe --- resources/macros/macros.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 3f3c3c23f..625984daf 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -63,7 +63,7 @@ Form::macro('date_display_format', function ($name = 'date_display_format', $sel } $select = ''; From 41479b1ec7b552938ca575806d5e2f3eea813102 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 10 Aug 2023 16:35:10 -0700 Subject: [PATCH 3/9] Allow permissions in the user factory to be chained --- database/factories/UserFactory.php | 242 ++++++----------------------- 1 file changed, 50 insertions(+), 192 deletions(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index db1322461..07affb200 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -81,11 +81,7 @@ class UserFactory extends Factory public function superuser() { - return $this->state(function () { - return [ - 'permissions' => '{"superuser":"1"}', - ]; - }); + return $this->appendPermission(['superuser' => '1']); } public function admin() @@ -102,342 +98,204 @@ class UserFactory extends Factory public function viewAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.view":"1"}', - ]; - }); + return $this->appendPermission(['assets.view' => '1']); } public function createAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.create":"1"}', - ]; - }); + return $this->appendPermission(['assets.create' => '1']); } public function editAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.edit":"1"}', - ]; - }); + return $this->appendPermission(['assets.edit' => '1']); } public function deleteAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.delete":"1"}', - ]; - }); + return $this->appendPermission(['assets.delete' => '1']); } public function checkinAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.checkin":"1"}', - ]; - }); + return $this->appendPermission(['assets.checkin' => '1']); } public function checkoutAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.checkout":"1"}', - ]; - }); + return $this->appendPermission(['assets.checkout' => '1']); } public function viewRequestableAssets() { - return $this->state(function () { - return [ - 'permissions' => '{"assets.view.requestable":"1"}', - ]; - }); + return $this->appendPermission(['assets.view.requestable' => '1']); } public function viewAccessories() { - return $this->state(function () { - return [ - 'permissions' => '{"accessories.view":"1"}', - ]; - }); + return $this->appendPermission(['accessories.view' => '1']); } public function createAccessories() { - return $this->state(function () { - return [ - 'permissions' => '{"accessories.create":"1"}', - ]; - }); + return $this->appendPermission(['accessories.create' => '1']); } public function editAccessories() { - return $this->state(function () { - return [ - 'permissions' => '{"accessories.edit":"1"}', - ]; - }); + return $this->appendPermission(['accessories.edit' => '1']); } public function deleteAccessories() { - return $this->state(function () { - return [ - 'permissions' => '{"accessories.delete":"1"}', - ]; - }); + return $this->appendPermission(['accessories.delete' => '1']); } public function checkinAccessories() { - return $this->state(function () { - return [ - 'permissions' => '{"accessories.checkin":"1"}', - ]; - }); + return $this->appendPermission(['accessories.checkin' => '1']); } public function checkoutAccessories() { - return $this->state(function () { - return [ - 'permissions' => '{"accessories.checkout":"1"}', - ]; - }); + return $this->appendPermission(['accessories.checkout' => '1']); } public function viewConsumables() { - return $this->state(function () { - return [ - 'permissions' => '{"consumables.view":"1"}', - ]; - }); + return $this->appendPermission(['consumables.view' => '1']); } public function createConsumables() { - return $this->state(function () { - return [ - 'permissions' => '{"consumables.create":"1"}', - ]; - }); + return $this->appendPermission(['consumables.create' => '1']); } public function editConsumables() { - return $this->state(function () { - return [ - 'permissions' => '{"consumables.edit":"1"}', - ]; - }); + return $this->appendPermission(['consumables.edit' => '1']); } public function deleteConsumables() { - return $this->state(function () { - return [ - 'permissions' => '{"consumables.delete":"1"}', - ]; - }); + return $this->appendPermission(['consumables.delete' => '1']); } public function checkinConsumables() { - return $this->state(function () { - return [ - 'permissions' => '{"consumables.checkin":"1"}', - ]; - }); + return $this->appendPermission(['consumables.checkin' => '1']); } public function checkoutConsumables() { - return $this->state(function () { - return [ - 'permissions' => '{"consumables.checkout":"1"}', - ]; - }); + return $this->appendPermission(['consumables.checkout' => '1']); } public function viewDepartments() { - return $this->state(function () { - return [ - 'permissions' => '{"departments.view":"1"}', - ]; - }); + return $this->appendPermission(['departments.view' => '1']); } public function viewLicenses() { - return $this->state(function () { - return [ - 'permissions' => '{"licenses.view":"1"}', - ]; - }); + return $this->appendPermission(['licenses.view' => '1']); } public function createLicenses() { - return $this->state(function () { - return [ - 'permissions' => '{"licenses.create":"1"}', - ]; - }); + return $this->appendPermission(['licenses.create' => '1']); } public function editLicenses() { - return $this->state(function () { - return [ - 'permissions' => '{"licenses.edit":"1"}', - ]; - }); + return $this->appendPermission(['licenses.edit' => '1']); } public function deleteLicenses() { - return $this->state(function () { - return [ - 'permissions' => '{"licenses.delete":"1"}', - ]; - }); + return $this->appendPermission(['licenses.delete' => '1']); } public function checkoutLicenses() { - return $this->state(function () { - return [ - 'permissions' => '{"licenses.checkout":"1"}', - ]; - }); + return $this->appendPermission(['licenses.checkout' => '1']); } public function viewKeysLicenses() { - return $this->state(function () { - return [ - 'permissions' => '{"licenses.keys":"1"}', - ]; - }); + return $this->appendPermission(['licenses.keys' => '1']); } public function viewComponents() { - return $this->state(function () { - return [ - 'permissions' => '{"components.view":"1"}', - ]; - }); + return $this->appendPermission(['components.view' => '1']); } public function createComponents() { - return $this->state(function () { - return [ - 'permissions' => '{"components.create":"1"}', - ]; - }); + return $this->appendPermission(['components.create' => '1']); } public function editComponents() { - return $this->state(function () { - return [ - 'permissions' => '{"components.edit":"1"}', - ]; - }); + return $this->appendPermission(['components.edit' => '1']); } public function deleteComponents() { - return $this->state(function () { - return [ - 'permissions' => '{"components.delete":"1"}', - ]; - }); + return $this->appendPermission(['components.delete' => '1']); } public function checkinComponents() { - return $this->state(function () { - return [ - 'permissions' => '{"components.checkin":"1"}', - ]; - }); + return $this->appendPermission(['components.checkin' => '1']); } public function checkoutComponents() { - return $this->state(function () { - return [ - 'permissions' => '{"components.checkout":"1"}', - ]; - }); + return $this->appendPermission(['components.checkout' => '1']); } public function viewUsers() { - return $this->state(function () { - return [ - 'permissions' => '{"users.view":"1"}', - ]; - }); + return $this->appendPermission(['users.view' => '1']); } public function createUsers() { - return $this->state(function () { - return [ - 'permissions' => '{"users.create":"1"}', - ]; - }); + return $this->appendPermission(['users.create' => '1']); } public function editUsers() { - return $this->state(function () { - return [ - 'permissions' => '{"users.edit":"1"}', - ]; - }); + return $this->appendPermission(['users.edit' => '1']); } public function deleteUsers() { - return $this->state(function () { - return [ - 'permissions' => '{"users.delete":"1"}', - ]; - }); + return $this->appendPermission(['users.delete' => '1']); } public function canEditOwnLocation() { - return $this->state(function () { - return [ - 'permissions' => '{"self.edit_location":"1"}', - ]; - }); + return $this->appendPermission(['self.edit_location' => '1']); } public function canViewReports() { - return $this->state(function () { + return $this->appendPermission(['reports.view' => '1']); + } + + private function appendPermission(array $permission) + { + return $this->state(function ($currentState) use ($permission) { return [ - 'permissions' => '{"reports.view":"1"}', + 'permissions' => json_encode( + array_merge( + json_decode($currentState['permissions'], true), + $permission + ) + ), ]; }); } From 5b86c0236640fb60b29c131b5955720035862cb7 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 10 Aug 2023 16:55:44 -0700 Subject: [PATCH 4/9] Set permissions to empty object in user factory --- database/factories/UserFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 07affb200..1416ec461 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -30,7 +30,7 @@ class UserFactory extends Factory 'locale' => 'en', 'notes' => 'Created by DB seeder', 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password - 'permissions' => '{"user":"0"}', + 'permissions' => '{}', 'phone' => $this->faker->phoneNumber(), 'state' => $this->faker->stateAbbr(), 'username' => $this->faker->username(), From a0d57746353ddffaa6abce19796cb4a8db8a895c Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 14 Aug 2023 10:42:17 -0700 Subject: [PATCH 5/9] adds translations to status label type column --- app/Models/Statuslabel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.php index 0f8a0b607..66f22ada9 100755 --- a/app/Models/Statuslabel.php +++ b/app/Models/Statuslabel.php @@ -74,14 +74,14 @@ class Statuslabel extends SnipeModel public function getStatuslabelType() { if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) { - return 'pending'; + return trans('admin/statuslabels/table.pending'); } elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) { - return 'archived'; + return trans('admin/statuslabels/table.archived'); } elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) { - return 'undeployable'; + return trans('admin/statuslabels/table.undeployable'); } - return 'deployable'; + return trans('admin/statuslabels/table.deployable'); } /** From 6b94ef6adc5c65d4f6338edc9e49aff5f0cf2274 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 14 Aug 2023 12:13:01 -0700 Subject: [PATCH 6/9] fixes the statuslabeltypeforatter instead of the model --- app/Models/Statuslabel.php | 8 ++++---- package-lock.json | 4 ++-- resources/views/statuslabels/index.blade.php | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.php index 66f22ada9..0f8a0b607 100755 --- a/app/Models/Statuslabel.php +++ b/app/Models/Statuslabel.php @@ -74,14 +74,14 @@ class Statuslabel extends SnipeModel public function getStatuslabelType() { if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) { - return trans('admin/statuslabels/table.pending'); + return 'pending'; } elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) { - return trans('admin/statuslabels/table.archived'); + return 'archived'; } elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) { - return trans('admin/statuslabels/table.undeployable'); + return 'undeployable'; } - return trans('admin/statuslabels/table.deployable'); + return 'deployable'; } /** diff --git a/package-lock.json b/package-lock.json index 649581f94..234e74450 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17392,7 +17392,7 @@ "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "optional": true }, "picocolors": { @@ -18500,7 +18500,7 @@ "rgbcolor": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", - "integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==", + "integrity": "sha1-1lBezbMEplldom+ktDMHMGd1lF0=", "optional": true }, "rimraf": { diff --git a/resources/views/statuslabels/index.blade.php b/resources/views/statuslabels/index.blade.php index 1f24d32d9..21ba2d794 100755 --- a/resources/views/statuslabels/index.blade.php +++ b/resources/views/statuslabels/index.blade.php @@ -111,25 +111,39 @@ } function statusLabelTypeFormatter (row, value) { + switch (value.type) { case 'deployed': text_color = 'blue'; icon_style = 'fa-circle'; + trans = '{{ strtolower(trans('general.deployed')) }}'; break; case 'deployable': text_color = 'green'; icon_style = 'fa-circle'; + trans = '{{ strtolower(trans('admin/hardware/general.deployable')) }}'; + break; case 'pending': text_color = 'orange'; icon_style = 'fa-circle'; + trans = '{{ strtolower(trans('general.deployed')) }}'; + + break; + case 'undeployable': + text_color = 'orange'; + icon_style = 'fa-circle'; + trans ='{{ trans('admin/statuslabels/table.undeployable') }}'; + break; default: text_color = 'red'; icon_style = 'fa-times'; + trans = '{{ strtolower(trans('general.archived')) }}'; + } - var typename_lower = value.type; + var typename_lower = trans; var typename = typename_lower.charAt(0).toUpperCase() + typename_lower.slice(1); return ' ' + typename; From 4446b2311d98c3c48c957296c6c7e589bc1e89aa Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 14 Aug 2023 12:14:15 -0700 Subject: [PATCH 7/9] remove unnecessary changes --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 234e74450..649581f94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17392,7 +17392,7 @@ "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", "optional": true }, "picocolors": { @@ -18500,7 +18500,7 @@ "rgbcolor": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", - "integrity": "sha1-1lBezbMEplldom+ktDMHMGd1lF0=", + "integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==", "optional": true }, "rimraf": { From c3356ab76586b6fcc52313dacf8a240faa7bec69 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 14 Aug 2023 12:20:46 -0700 Subject: [PATCH 8/9] fixed translation choice and color choice --- resources/views/statuslabels/index.blade.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/resources/views/statuslabels/index.blade.php b/resources/views/statuslabels/index.blade.php index 21ba2d794..7fdf4fc9a 100755 --- a/resources/views/statuslabels/index.blade.php +++ b/resources/views/statuslabels/index.blade.php @@ -113,11 +113,6 @@ function statusLabelTypeFormatter (row, value) { switch (value.type) { - case 'deployed': - text_color = 'blue'; - icon_style = 'fa-circle'; - trans = '{{ strtolower(trans('general.deployed')) }}'; - break; case 'deployable': text_color = 'green'; icon_style = 'fa-circle'; @@ -127,11 +122,11 @@ case 'pending': text_color = 'orange'; icon_style = 'fa-circle'; - trans = '{{ strtolower(trans('general.deployed')) }}'; + trans = '{{ strtolower(trans('general.pending')) }}'; break; case 'undeployable': - text_color = 'orange'; + text_color = 'red'; icon_style = 'fa-circle'; trans ='{{ trans('admin/statuslabels/table.undeployable') }}'; From 9820ab34d70dcc3d8470107927ccdf28040e07f2 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 14 Aug 2023 22:44:29 +0100 Subject: [PATCH 9/9] =?UTF-8?q?Use=20today=E2=80=99s=20date=20for=20date?= =?UTF-8?q?=20format=20selectlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- resources/macros/macros.php | 6 +++--- resources/views/settings/localization.blade.php | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 625984daf..43dc2cc2e 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -59,11 +59,11 @@ Form::macro('date_display_format', function ($name = 'date_display_format', $sel ]; foreach ($formats as $format) { - $date_display_formats[$format] = Carbon::parse(date('Y').'-'.date('m').'-25')->format($format); + $date_display_formats[$format] = Carbon::parse(date('Y-m-d'))->format($format); } - $select = ''; foreach ($date_display_formats as $format => $date_display_format) { - $select .= ' '; + $select .= ' '; } $select .= ''; diff --git a/resources/views/settings/localization.blade.php b/resources/views/settings/localization.blade.php index d7ec45a92..a74387b32 100644 --- a/resources/views/settings/localization.blade.php +++ b/resources/views/settings/localization.blade.php @@ -58,17 +58,15 @@
{{ Form::label('time_display_format', trans('general.time_and_date_display')) }}
-
+
{!! Form::date_display_format('date_display_format', Request::old('date_display_format', $setting->date_display_format), 'select2') !!}
{!! Form::time_display_format('time_display_format', Request::old('time_display_format', $setting->time_display_format), 'select2') !!} +
+ + {!! $errors->first('time_display_format', '
') !!} -
- {!! $errors->first('time_display_format', '') !!} -
-

The date shown in the drop-down is just an example to display the different date formats. It is not meant to reflect today's date.

-