From 74a891afbb2d86bdbca6baa824a710c4a8dcd168 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 27 Sep 2023 15:58:01 -0700 Subject: [PATCH 01/21] WIP: Render select box for field options in label engine --- .../label2-field-definitions.blade.php | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/resources/views/partials/label2-field-definitions.blade.php b/resources/views/partials/label2-field-definitions.blade.php index 6522b951d8..5bc473418f 100644 --- a/resources/views/partials/label2-field-definitions.blade.php +++ b/resources/views/partials/label2-field-definitions.blade.php @@ -304,7 +304,52 @@ - + {{----}} + @@ -331,4 +376,4 @@ > - \ No newline at end of file + From 518ae28a374aef744327b5b5fe7a26b9340adb24 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 27 Sep 2023 16:20:26 -0700 Subject: [PATCH 02/21] Improve option display values --- .../label2-field-definitions.blade.php | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/resources/views/partials/label2-field-definitions.blade.php b/resources/views/partials/label2-field-definitions.blade.php index 5bc473418f..fcdc97bc56 100644 --- a/resources/views/partials/label2-field-definitions.blade.php +++ b/resources/views/partials/label2-field-definitions.blade.php @@ -305,49 +305,49 @@ {{----}} - - - - - - - - - + + + + + + + + - - - - + + + + - + - + - + - - + + - - - + + + - - + + From a4a25ab9d0e1e3257d25e4974f3c0237d3d73281 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 27 Sep 2023 16:35:44 -0700 Subject: [PATCH 03/21] Remove a couple fields --- resources/views/partials/label2-field-definitions.blade.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/views/partials/label2-field-definitions.blade.php b/resources/views/partials/label2-field-definitions.blade.php index fcdc97bc56..73ee3935b6 100644 --- a/resources/views/partials/label2-field-definitions.blade.php +++ b/resources/views/partials/label2-field-definitions.blade.php @@ -304,13 +304,10 @@ - {{----}} diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index 46ce4fe610..a6edd29154 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -216,7 +216,7 @@ {{ Form::label('label2_fields', trans('admin/settings/general.label2_fields')) }}
- @include('partials.label2-field-definitions', [ 'name' => 'label2_fields', 'value' => old('label2_fields', $setting->label2_fields) ]) + @include('partials.label2-field-definitions', [ 'name' => 'label2_fields', 'value' => old('label2_fields', $setting->label2_fields), 'customFields' => $customFields ]) {!! $errors->first('label2_fields', '') !!}

{{ trans('admin/settings/general.label2_fields_help') }}

From 4675f02349bd6bdadc02a43e256ec083e6302bb3 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 28 Sep 2023 11:35:20 -0700 Subject: [PATCH 05/21] Format assigned to field --- app/Models/Labels/FieldOption.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Models/Labels/FieldOption.php b/app/Models/Labels/FieldOption.php index 76427accaf..2f874ec389 100644 --- a/app/Models/Labels/FieldOption.php +++ b/app/Models/Labels/FieldOption.php @@ -14,6 +14,14 @@ class FieldOption { public function getValue(Asset $asset) { $dataPath = collect(explode('.', $this->dataSource)); + + // assignedTo directly on the asset is a special case where + // we want to avoid returning the property directly + // and instead return the entity's presented name. + if ($dataPath[0] === 'assignedTo'){ + return $asset->assignedTo->present()->fullName(); + } + return $dataPath->reduce(function ($myValue, $path) { try { return $myValue ? $myValue->{$path} : ${$myValue}; } catch (\Exception $e) { return $myValue; } @@ -46,4 +54,4 @@ class FieldOption { return $option; } } -} \ No newline at end of file +} From 36638feac4619745d53229a88616d861fffe59a7 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 28 Sep 2023 11:37:02 -0700 Subject: [PATCH 06/21] Add assigned to as option --- resources/views/partials/label2-field-definitions.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/partials/label2-field-definitions.blade.php b/resources/views/partials/label2-field-definitions.blade.php index 710edda621..9ca4f191de 100644 --- a/resources/views/partials/label2-field-definitions.blade.php +++ b/resources/views/partials/label2-field-definitions.blade.php @@ -313,6 +313,7 @@ + From 3aa256ec021d7351fd07b472a927a1b432d96799 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 28 Sep 2023 12:33:20 -0700 Subject: [PATCH 07/21] Ensure non-checked out items can be displayed --- app/Models/Labels/FieldOption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Labels/FieldOption.php b/app/Models/Labels/FieldOption.php index 2f874ec389..7e45cc0ce7 100644 --- a/app/Models/Labels/FieldOption.php +++ b/app/Models/Labels/FieldOption.php @@ -19,7 +19,7 @@ class FieldOption { // we want to avoid returning the property directly // and instead return the entity's presented name. if ($dataPath[0] === 'assignedTo'){ - return $asset->assignedTo->present()->fullName(); + return $asset->assignedTo ? $asset->assignedTo->present()->fullName() : null; } return $dataPath->reduce(function ($myValue, $path) { From ed77e8768c7cc17c0292cce2ca448340876c9d41 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 28 Sep 2023 12:33:27 -0700 Subject: [PATCH 08/21] Re-order options --- .../partials/label2-field-definitions.blade.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/resources/views/partials/label2-field-definitions.blade.php b/resources/views/partials/label2-field-definitions.blade.php index 9ca4f191de..21aa7a0cf9 100644 --- a/resources/views/partials/label2-field-definitions.blade.php +++ b/resources/views/partials/label2-field-definitions.blade.php @@ -307,17 +307,16 @@