From 07336bbc6a9f0b7000cc513970118539d526636e Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 25 Apr 2023 15:51:36 -0700 Subject: [PATCH 01/15] Added `auto_add_to_fieldsets` field Signed-off-by: snipe --- app/Models/CustomField.php | 3 ++ ..._25_085912_add_autoadd_to_customfields.php | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 database/migrations/2023_04_25_085912_add_autoadd_to_customfields.php diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index fcab5b25ff..b39650e74b 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -52,6 +52,7 @@ class CustomField extends Model 'name' => 'required|unique:custom_fields', 'element' => 'required|in:text,listbox,textarea,checkbox,radio', 'field_encrypted' => 'nullable|boolean', + 'auto_add_to_fieldsets' => 'boolean', ]; /** @@ -69,6 +70,8 @@ class CustomField extends Model 'show_in_email', 'is_unique', 'display_in_user_view', + 'auto_add_to_fieldsets', + ]; /** diff --git a/database/migrations/2023_04_25_085912_add_autoadd_to_customfields.php b/database/migrations/2023_04_25_085912_add_autoadd_to_customfields.php new file mode 100644 index 0000000000..918bec9c5c --- /dev/null +++ b/database/migrations/2023_04_25_085912_add_autoadd_to_customfields.php @@ -0,0 +1,34 @@ +boolean('auto_add_to_fieldsets')->nullable()->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('custom_fields', function (Blueprint $table) { + if (Schema::hasColumn('custom_fields', 'auto_add_to_fieldsets')) { + $table->dropColumn('auto_add_to_fieldsets'); + } + }); + } +} From 4954b50280164f683481e3258e46977fc1abd64a Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 25 Apr 2023 15:57:46 -0700 Subject: [PATCH 02/15] Added new strings Signed-off-by: snipe --- resources/lang/en/admin/custom_fields/general.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/lang/en/admin/custom_fields/general.php b/resources/lang/en/admin/custom_fields/general.php index 9dae380aa5..1923aa7f4a 100644 --- a/resources/lang/en/admin/custom_fields/general.php +++ b/resources/lang/en/admin/custom_fields/general.php @@ -49,4 +49,6 @@ return [ 'unique' => 'Unique', 'display_in_user_view' => 'Allow the checked out user to view these values in their View Assigned Assets page', 'display_in_user_view_table' => 'Visible to User', + 'auto_add_to_fieldsets' => 'Automatically add this to every new fieldset', + 'add_to_preexisting_fieldsets' => 'Add to any existing fieldsets', ]; From 4e3ccb74bc1d5d9afdc49b60befa966eec96a488 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 25 Apr 2023 15:59:19 -0700 Subject: [PATCH 03/15] Fixed slightly weird padding Signed-off-by: snipe --- resources/views/custom_fields/index.blade.php | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.php index 0ad8511183..ba95199ead 100644 --- a/resources/views/custom_fields/index.blade.php +++ b/resources/views/custom_fields/index.blade.php @@ -178,26 +178,29 @@ + {{ Form::open(array('route' => array('fields.destroy', $field->id), 'method' => 'delete', 'style' => 'display:inline-block')) }} @can('update', $field) - - - {{ trans('button.edit') }} - + + + {{ trans('button.edit') }} + @endcan + @can('delete', $field) - {{ Form::open(array('route' => array('fields.destroy', $field->id), 'method' => 'delete', 'style' => 'display:inline-block')) }} - @if($field->fieldset->count()>0) - - @else - - @endif - {{ Form::close() }} + + @if($field->fieldset->count()>0) + + @else + + @endif + @endcan + {{ Form::close() }} From 4a063d23b96b11709ea081dfd3105fb3415ee4f3 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 25 Apr 2023 19:36:52 -0700 Subject: [PATCH 04/15] =?UTF-8?q?We=20don=E2=80=99t=20actually=20use=20thi?= =?UTF-8?q?s=20test=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- tests/Unit/CustomFieldTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/Unit/CustomFieldTest.php b/tests/Unit/CustomFieldTest.php index dbf96c55f8..d5704d8aa3 100644 --- a/tests/Unit/CustomFieldTest.php +++ b/tests/Unit/CustomFieldTest.php @@ -13,12 +13,6 @@ class CustomFieldTest extends TestCase public function testFormat() { $customfield = CustomField::factory()->make(['format' => 'IP']); - $values = [ - 'name' => $customfield->name, - 'format' => $customfield->format, - 'element' => $customfield->element, - ]; - $this->assertEquals($customfield->getAttributes()['format'], CustomField::PREDEFINED_FORMATS['IP']); //this seems undocumented... $this->assertEquals($customfield->format, 'IP'); } From 6cd3cfe1eaddf2bfd531f6bcdc6be82ecf222200 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 25 Apr 2023 20:57:03 -0700 Subject: [PATCH 05/15] Added new field to factory Signed-off-by: snipe --- database/factories/CustomFieldFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/factories/CustomFieldFactory.php b/database/factories/CustomFieldFactory.php index bfa41b4d8d..adcca9cae1 100644 --- a/database/factories/CustomFieldFactory.php +++ b/database/factories/CustomFieldFactory.php @@ -25,6 +25,7 @@ class CustomFieldFactory extends Factory 'name' => $this->faker->catchPhrase(), 'format' => '', 'element' => 'text', + 'auto_add_to_fieldsets' => '0', ]; } From 67212f9d57561892b948f97d81bea28ad55ee4f1 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 25 Apr 2023 20:59:29 -0700 Subject: [PATCH 06/15] Changed layout, added fieldsets Signed-off-by: snipe --- .../views/custom_fields/fields/edit.blade.php | 131 +++++++++++++----- 1 file changed, 95 insertions(+), 36 deletions(-) diff --git a/resources/views/custom_fields/fields/edit.blade.php b/resources/views/custom_fields/fields/edit.blade.php index 8e025e4b6b..0b6a1c45c0 100644 --- a/resources/views/custom_fields/fields/edit.blade.php +++ b/resources/views/custom_fields/fields/edit.blade.php @@ -1,8 +1,9 @@ -@php - use App\Models\CustomField; -@endphp +@extends('layouts/default', [ + 'helpText' => trans('admin/custom_fields/general.about_fieldsets_text'), + 'helpPosition' => 'right', + 'topSubmit' => true, +]) -@extends('layouts/default') {{-- Page title --}} @section('title') @@ -21,24 +22,28 @@ {{-- Page content --}} @section('content') -
-
- @if ($field->id) - {{ Form::open(['route' => ['fields.update', $field->id], 'class'=>'form-horizontal']) }} - {{ method_field('PUT') }} - @else - {{ Form::open(['route' => 'fields.store', 'class'=>'form-horizontal']) }} - @endif + @if ($field->id) + {{ Form::open(['route' => ['fields.update', $field->id], 'class'=>'form-horizontal']) }} + {{ method_field('PUT') }} + @else + {{ Form::open(['route' => 'fields.store', 'class'=>'form-horizontal']) }} + @endif + @csrf +
+
+ +
+
-