From af681d8190a8fad64d783ec7af4d629a65f26d52 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 11 Jul 2023 16:12:43 -0700 Subject: [PATCH 01/21] Display message and update checkbox depending on EULA status --- resources/views/categories/edit.blade.php | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php index 813e8463e9..0fa705a72b 100755 --- a/resources/views/categories/edit.blade.php +++ b/resources/views/categories/edit.blade.php @@ -73,10 +73,12 @@ {{ Form::checkbox('checkin_email', '1', old('checkin_email', $item->checkin_email), ['aria-label'=>'checkin_email']) }} {{ trans('admin/categories/general.checkin_email') }} + + An email will be sent to the user because a EULA is set for this category. + - @include ('partials.forms.edit.image-upload', ['image_path' => app('categories_upload_path')]) @@ -109,3 +111,31 @@ @stop + +@section('moar_scripts') + +@stop From 44d8b2fd5ea8f414c01c03c7c50ea3330b0ced77 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 11 Jul 2023 16:36:03 -0700 Subject: [PATCH 02/21] Handle default eula checkbox --- resources/views/categories/edit.blade.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php index 0fa705a72b..57ea808fd4 100755 --- a/resources/views/categories/edit.blade.php +++ b/resources/views/categories/edit.blade.php @@ -114,24 +114,31 @@ @section('moar_scripts') +{{-- @if (! old('checkin_email', $item->checkin_email))--}} +{{-- handleEulaChange();--}} +{{-- @endif--}} +{{-- });--}} +{{-- --}} @stop diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php new file mode 100644 index 0000000000..2116f2f615 --- /dev/null +++ b/resources/views/livewire/category-edit-form.blade.php @@ -0,0 +1,55 @@ +
+ +
+ +
+ {{ Form::textarea('eula_text', null, array('wire:model.lazy' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text')) }} +

{!! trans('admin/categories/general.eula_text_help') !!}

+

{!! trans('admin/settings/general.eula_markdown') !!}

+ {!! $errors->first('eula_text', '') !!} +
+
+ + +
+
+ @if ($defaultEulaText!='') + + @else + + @endif +
+
+ + +
+
+ +
+
+ + +
+
+ + @if ($this->displayEmailMessage) +
+ + {{ $this->emailMessage }} +
+ @endif +
+
+
From 105c94aea999ab2fba10db9abb665258bd365b3e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 11:36:20 -0700 Subject: [PATCH 09/21] Implement toggling message when email will be sent --- app/Http/Livewire/CategoryEditForm.php | 13 +++++++------ .../views/livewire/category-edit-form.blade.php | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index de5d0e5522..342046b1c1 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -6,8 +6,6 @@ use Livewire\Component; class CategoryEditForm extends Component { -// public bool $displayEmailMessage = false; - public bool $checkinEmail; public $defaultEulaText; @@ -33,14 +31,17 @@ class CategoryEditForm extends Component return view('livewire.category-edit-form'); } - public function getDisplayEmailMessageProperty(): bool + public function getShouldDisplayEmailMessageProperty(): bool { - return false; + return $this->eulaText || $this->useDefaultEula; } public function getEmailMessageProperty(): string { - // @todo: - return ''; + if ($this->useDefaultEula) { + return trans('admin/categories/general.email_will_be_sent_due_to_global_eula'); + } + + return trans('admin/categories/general.email_will_be_sent_due_to_category_eula'); } } diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index 2116f2f615..fb54c125e2 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -44,7 +44,7 @@ {{ Form::checkbox('checkin_email', '1', null, ['wire:model' => 'checkinEmail', 'aria-label'=>'checkin_email']) }} {{ trans('admin/categories/general.checkin_email') }} - @if ($this->displayEmailMessage) + @if ($this->shouldDisplayEmailMessage)
{{ $this->emailMessage }} From dee6ebf8e0836a0ab1f23b2b07a767bc87e46337 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 12:58:07 -0700 Subject: [PATCH 10/21] Scaffold component test --- app/Http/Livewire/CategoryEditForm.php | 11 +++-------- tests/Feature/Livewire/CategoryEditFormTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 tests/Feature/Livewire/CategoryEditFormTest.php diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index 342046b1c1..4f08c7b5bd 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -6,26 +6,21 @@ use Livewire\Component; class CategoryEditForm extends Component { - public bool $checkinEmail; + public $checkinEmail; public $defaultEulaText; public $eulaText; - public bool $requireAcceptance; + public $requireAcceptance; - public bool $useDefaultEula; + public $useDefaultEula; public function mount() { } - public function updated($a, $b) - { -// dd($a, $b); - } - public function render() { return view('livewire.category-edit-form'); diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php new file mode 100644 index 0000000000..5d658889f0 --- /dev/null +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -0,0 +1,15 @@ +assertStatus(200); + } +} From 269414e4f237cfa61790189f30d8e1bb90bb60d5 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 16:04:01 -0700 Subject: [PATCH 11/21] Automatically check the send email to user checkbox in certain conditions --- app/Http/Livewire/CategoryEditForm.php | 11 +++- .../Feature/Livewire/CategoryEditFormTest.php | 56 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index 4f08c7b5bd..2cba9a220d 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -18,7 +18,9 @@ class CategoryEditForm extends Component public function mount() { - + if ($this->eulaText || $this->useDefaultEula) { + $this->checkinEmail = true; + } } public function render() @@ -26,6 +28,13 @@ class CategoryEditForm extends Component return view('livewire.category-edit-form'); } + public function updated($property, $value) + { + if (in_array($property, ['eulaText', 'useDefaultEula']) && ($this->eulaText || $this->useDefaultEula)) { + $this->checkinEmail = (bool)$value; + } + } + public function getShouldDisplayEmailMessageProperty(): bool { return $this->eulaText || $this->useDefaultEula; diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php index 5d658889f0..753a74bca0 100644 --- a/tests/Feature/Livewire/CategoryEditFormTest.php +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -12,4 +12,60 @@ class CategoryEditFormTest extends TestCase { Livewire::test(CategoryEditForm::class)->assertStatus(200); } + + public function testSendEmailCheckboxIsCheckedOnLoadWhenSendEmailIsExistingSetting() + { + Livewire::test(CategoryEditForm::class, [ + 'checkinEmail' => true, + 'eulaText' => '', + 'useDefaultEula' => false, + ])->assertSet('checkinEmail', true); + } + + public function testSendEmailCheckboxIsCheckedOnLoadWhenCategoryEulaSet() + { + Livewire::test(CategoryEditForm::class, [ + 'checkinEmail' => false, + 'eulaText' => 'Some Content', + 'useDefaultEula' => false, + ])->assertSet('checkinEmail', true); + } + + public function testSendEmailCheckboxIsCheckedOnLoadWhenUsingDefaultEula() + { + Livewire::test(CategoryEditForm::class, [ + 'checkinEmail' => false, + 'eulaText' => '', + 'useDefaultEula' => true, + ])->assertSet('checkinEmail', true); + } + + public function testSendEmailCheckBoxIsUncheckedOnLoadWhenSendEmailIsFalseNoCategoryEulaSetAndNotUsingDefaultEula() + { + Livewire::test(CategoryEditForm::class, [ + 'checkinEmail' => false, + 'eulaText' => '', + 'useDefaultEula' => false, + ])->assertSet('checkinEmail', false); + } + + public function testSendEmailCheckboxIsCheckedWhenCategoryEulaEntered() + { + Livewire::test(CategoryEditForm::class, [ + 'checkinEmail' => false, + 'useDefaultEula' => false, + ])->assertSet('checkinEmail', false) + ->set('eulaText', 'Some Content') + ->assertSet('checkinEmail', true); + } + + public function testSendEmailCheckboxCheckedWhenUseDefaultEulaSelected() + { + Livewire::test(CategoryEditForm::class, [ + 'checkinEmail' => false, + 'useDefaultEula' => false, + ])->assertSet('checkinEmail', false) + ->set('useDefaultEula', true) + ->assertSet('checkinEmail', true); + } } From 64000344358f72fb5ec79edf6693b6880e99bf78 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 16:06:59 -0700 Subject: [PATCH 12/21] Improve variable name --- app/Http/Livewire/CategoryEditForm.php | 8 +++--- .../livewire/category-edit-form.blade.php | 2 +- .../Feature/Livewire/CategoryEditFormTest.php | 28 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index 2cba9a220d..d69c09971a 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -6,20 +6,20 @@ use Livewire\Component; class CategoryEditForm extends Component { - public $checkinEmail; - public $defaultEulaText; public $eulaText; public $requireAcceptance; + public $sendCheckInEmail; + public $useDefaultEula; public function mount() { if ($this->eulaText || $this->useDefaultEula) { - $this->checkinEmail = true; + $this->sendCheckInEmail = true; } } @@ -31,7 +31,7 @@ class CategoryEditForm extends Component public function updated($property, $value) { if (in_array($property, ['eulaText', 'useDefaultEula']) && ($this->eulaText || $this->useDefaultEula)) { - $this->checkinEmail = (bool)$value; + $this->sendCheckInEmail = (bool)$value; } } diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index fb54c125e2..e49d9cc0fa 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -41,7 +41,7 @@
@if ($this->shouldDisplayEmailMessage) diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php index 753a74bca0..448e61cee6 100644 --- a/tests/Feature/Livewire/CategoryEditFormTest.php +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -16,56 +16,56 @@ class CategoryEditFormTest extends TestCase public function testSendEmailCheckboxIsCheckedOnLoadWhenSendEmailIsExistingSetting() { Livewire::test(CategoryEditForm::class, [ - 'checkinEmail' => true, + 'sendCheckInEmail' => true, 'eulaText' => '', 'useDefaultEula' => false, - ])->assertSet('checkinEmail', true); + ])->assertSet('sendCheckInEmail', true); } public function testSendEmailCheckboxIsCheckedOnLoadWhenCategoryEulaSet() { Livewire::test(CategoryEditForm::class, [ - 'checkinEmail' => false, + 'sendCheckInEmail' => false, 'eulaText' => 'Some Content', 'useDefaultEula' => false, - ])->assertSet('checkinEmail', true); + ])->assertSet('sendCheckInEmail', true); } public function testSendEmailCheckboxIsCheckedOnLoadWhenUsingDefaultEula() { Livewire::test(CategoryEditForm::class, [ - 'checkinEmail' => false, + 'sendCheckInEmail' => false, 'eulaText' => '', 'useDefaultEula' => true, - ])->assertSet('checkinEmail', true); + ])->assertSet('sendCheckInEmail', true); } public function testSendEmailCheckBoxIsUncheckedOnLoadWhenSendEmailIsFalseNoCategoryEulaSetAndNotUsingDefaultEula() { Livewire::test(CategoryEditForm::class, [ - 'checkinEmail' => false, + 'sendCheckInEmail' => false, 'eulaText' => '', 'useDefaultEula' => false, - ])->assertSet('checkinEmail', false); + ])->assertSet('sendCheckInEmail', false); } public function testSendEmailCheckboxIsCheckedWhenCategoryEulaEntered() { Livewire::test(CategoryEditForm::class, [ - 'checkinEmail' => false, + 'sendCheckInEmail' => false, 'useDefaultEula' => false, - ])->assertSet('checkinEmail', false) + ])->assertSet('sendCheckInEmail', false) ->set('eulaText', 'Some Content') - ->assertSet('checkinEmail', true); + ->assertSet('sendCheckInEmail', true); } public function testSendEmailCheckboxCheckedWhenUseDefaultEulaSelected() { Livewire::test(CategoryEditForm::class, [ - 'checkinEmail' => false, + 'sendCheckInEmail' => false, 'useDefaultEula' => false, - ])->assertSet('checkinEmail', false) + ])->assertSet('sendCheckInEmail', false) ->set('useDefaultEula', true) - ->assertSet('checkinEmail', true); + ->assertSet('sendCheckInEmail', true); } } From e12935f7fac10d5f3cd391f67fdd791499376898 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 16:18:57 -0700 Subject: [PATCH 13/21] Disable eula textarea when using global eula --- app/Http/Livewire/CategoryEditForm.php | 5 +++++ resources/views/livewire/category-edit-form.blade.php | 2 +- tests/Feature/Livewire/CategoryEditFormTest.php | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index d69c09971a..e51130e6ab 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -48,4 +48,9 @@ class CategoryEditForm extends Component return trans('admin/categories/general.email_will_be_sent_due_to_category_eula'); } + + public function getEulaTextDisabledProperty() + { + return $this->useDefaultEula; + } } diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index e49d9cc0fa..10c33bde48 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -3,7 +3,7 @@
- {{ Form::textarea('eula_text', null, array('wire:model.lazy' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text')) }} + {{ Form::textarea('eula_text', null, ['wire:model.lazy' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }}

{!! trans('admin/categories/general.eula_text_help') !!}

{!! trans('admin/settings/general.eula_markdown') !!}

{!! $errors->first('eula_text', '') !!} diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php index 448e61cee6..20399c6c60 100644 --- a/tests/Feature/Livewire/CategoryEditFormTest.php +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -59,13 +59,14 @@ class CategoryEditFormTest extends TestCase ->assertSet('sendCheckInEmail', true); } - public function testSendEmailCheckboxCheckedWhenUseDefaultEulaSelected() + public function testSendEmailCheckboxCheckedAndEulaTextDisabledWhenUseDefaultEulaSelected() { Livewire::test(CategoryEditForm::class, [ 'sendCheckInEmail' => false, 'useDefaultEula' => false, ])->assertSet('sendCheckInEmail', false) ->set('useDefaultEula', true) - ->assertSet('sendCheckInEmail', true); + ->assertSet('sendCheckInEmail', true) + ->assertSet('eulaTextDisabled', true); } } From 48979ce177742a44c054e81f0390bbe937b8f338 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 16:52:56 -0700 Subject: [PATCH 14/21] Disable send email when it should not be modified --- app/Http/Livewire/CategoryEditForm.php | 9 +++++++-- resources/views/livewire/category-edit-form.blade.php | 2 +- tests/Feature/Livewire/CategoryEditFormTest.php | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index e51130e6ab..695bc589ae 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -30,8 +30,8 @@ class CategoryEditForm extends Component public function updated($property, $value) { - if (in_array($property, ['eulaText', 'useDefaultEula']) && ($this->eulaText || $this->useDefaultEula)) { - $this->sendCheckInEmail = (bool)$value; + if (in_array($property, ['eulaText', 'useDefaultEula'])) { + $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula; } } @@ -53,4 +53,9 @@ class CategoryEditForm extends Component { return $this->useDefaultEula; } + + public function getSendCheckInEmailDisabledProperty() + { + return $this->eulaText || $this->useDefaultEula; + } } diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index 10c33bde48..634b457116 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -41,7 +41,7 @@
@if ($this->shouldDisplayEmailMessage) diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php index 20399c6c60..f151a8f0be 100644 --- a/tests/Feature/Livewire/CategoryEditFormTest.php +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -59,7 +59,7 @@ class CategoryEditFormTest extends TestCase ->assertSet('sendCheckInEmail', true); } - public function testSendEmailCheckboxCheckedAndEulaTextDisabledWhenUseDefaultEulaSelected() + public function testSendEmailCheckboxCheckedAndDisabledAndEulaTextDisabledWhenUseDefaultEulaSelected() { Livewire::test(CategoryEditForm::class, [ 'sendCheckInEmail' => false, @@ -67,6 +67,8 @@ class CategoryEditFormTest extends TestCase ])->assertSet('sendCheckInEmail', false) ->set('useDefaultEula', true) ->assertSet('sendCheckInEmail', true) - ->assertSet('eulaTextDisabled', true); + ->assertSet('eulaTextDisabled', true) + ->assertSet('sendCheckInEmailDisabled', true); + } } } From 896f038054417eb8068f3f0e89884b32831ff7d6 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 17:03:56 -0700 Subject: [PATCH 15/21] Set send email back to original value when eulas cleared --- app/Http/Livewire/CategoryEditForm.php | 11 +++++++--- resources/views/categories/edit.blade.php | 2 +- .../Feature/Livewire/CategoryEditFormTest.php | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index 695bc589ae..c42f04803d 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -10,14 +10,17 @@ class CategoryEditForm extends Component public $eulaText; + public $originalSendCheckInEmailValue; + public $requireAcceptance; public $sendCheckInEmail; - public $useDefaultEula; public function mount() { + $this->originalSendCheckInEmailValue = $this->sendCheckInEmail; + if ($this->eulaText || $this->useDefaultEula) { $this->sendCheckInEmail = true; } @@ -30,9 +33,11 @@ class CategoryEditForm extends Component public function updated($property, $value) { - if (in_array($property, ['eulaText', 'useDefaultEula'])) { - $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula; + if (! in_array($property, ['eulaText', 'useDefaultEula'])) { + return; } + + $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? true : $this->originalSendCheckInEmailValue; } public function getShouldDisplayEmailMessageProperty(): bool diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php index c9a3c06142..cde53cd3fd 100755 --- a/resources/views/categories/edit.blade.php +++ b/resources/views/categories/edit.blade.php @@ -24,10 +24,10 @@
diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php index f151a8f0be..270cd9efbe 100644 --- a/tests/Feature/Livewire/CategoryEditFormTest.php +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -70,5 +70,27 @@ class CategoryEditFormTest extends TestCase ->assertSet('eulaTextDisabled', true) ->assertSet('sendCheckInEmailDisabled', true); } + + public function testSendEmailCheckboxEnabledAndSetToOriginalValueWhenNoCategoryEulaAndNotUsingGlobalEula() + { + Livewire::test(CategoryEditForm::class, [ + 'eulaText' => 'Some Content', + 'sendCheckInEmail' => false, + 'useDefaultEula' => true, + ]) + ->set('useDefaultEula', false) + ->set('eulaText', '') + ->assertSet('sendCheckInEmail', false) + ->assertSet('sendCheckInEmailDisabled', false); + + Livewire::test(CategoryEditForm::class, [ + 'eulaText' => 'Some Content', + 'sendCheckInEmail' => true, + 'useDefaultEula' => true, + ]) + ->set('useDefaultEula', false) + ->set('eulaText', '') + ->assertSet('sendCheckInEmail', true) + ->assertSet('sendCheckInEmailDisabled', false); } } From 2e7aa01abe4a6d998e91208a4d6cdee81db72757 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 17:45:39 -0700 Subject: [PATCH 16/21] Pass checkin_email value to backend even when unchecked --- resources/views/livewire/category-edit-form.blade.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index 634b457116..09eef82bf1 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -50,6 +50,9 @@ {{ $this->emailMessage }}
@endif + @if ($this->sendCheckInEmailDisabled) + + @endif
From 3fd0853fd05ed43292224455a4d26a381438f7b6 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 18:02:56 -0700 Subject: [PATCH 17/21] Ensure eula field enabled when not using default eula --- app/Http/Livewire/CategoryEditForm.php | 6 +++--- tests/Feature/Livewire/CategoryEditFormTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index c42f04803d..21f0fa5c24 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -22,7 +22,7 @@ class CategoryEditForm extends Component $this->originalSendCheckInEmailValue = $this->sendCheckInEmail; if ($this->eulaText || $this->useDefaultEula) { - $this->sendCheckInEmail = true; + $this->sendCheckInEmail = 1; } } @@ -37,7 +37,7 @@ class CategoryEditForm extends Component return; } - $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? true : $this->originalSendCheckInEmailValue; + $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? 1 : $this->originalSendCheckInEmailValue; } public function getShouldDisplayEmailMessageProperty(): bool @@ -56,7 +56,7 @@ class CategoryEditForm extends Component public function getEulaTextDisabledProperty() { - return $this->useDefaultEula; + return (bool) $this->useDefaultEula; } public function getSendCheckInEmailDisabledProperty() diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php index 270cd9efbe..26719e4041 100644 --- a/tests/Feature/Livewire/CategoryEditFormTest.php +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -93,4 +93,13 @@ class CategoryEditFormTest extends TestCase ->assertSet('sendCheckInEmail', true) ->assertSet('sendCheckInEmailDisabled', false); } + + public function testEulaFieldEnabledOnLoadWhenNotUsingDefaultEula() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'eulaText' => '', + 'useDefaultEula' => false, + ])->assertSet('eulaTextDisabled', false); + } } From cbe5a9bc8a8e7a62a1386bfe42e51239d261efab Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 18:03:09 -0700 Subject: [PATCH 18/21] Persist eula text even when field is disabled --- resources/views/livewire/category-edit-form.blade.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index 09eef82bf1..046adbc80b 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -8,6 +8,9 @@

{!! trans('admin/settings/general.eula_markdown') !!}

{!! $errors->first('eula_text', '') !!}
+ @if ($this->eulaTextDisabled) + + @endif
From b70a5280f97e0df01dc6e316e8c910523222d376 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 18:04:21 -0700 Subject: [PATCH 19/21] Remove unneed jquery --- resources/views/categories/edit.blade.php | 52 ----------------------- 1 file changed, 52 deletions(-) diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php index cde53cd3fd..1ef3b7aa6a 100755 --- a/resources/views/categories/edit.blade.php +++ b/resources/views/categories/edit.blade.php @@ -62,56 +62,4 @@ -@stop - -@section('moar_scripts') -{{-- --}} @stop From d019e62d3952756586a6baabf7824947885f2ab4 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 18:22:40 -0700 Subject: [PATCH 20/21] Remove lazy from eula field to avoid race condition --- resources/views/livewire/category-edit-form.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php index 046adbc80b..33b41b71e9 100644 --- a/resources/views/livewire/category-edit-form.blade.php +++ b/resources/views/livewire/category-edit-form.blade.php @@ -3,7 +3,7 @@
- {{ Form::textarea('eula_text', null, ['wire:model.lazy' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }} + {{ Form::textarea('eula_text', null, ['wire:model' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }}

{!! trans('admin/categories/general.eula_text_help') !!}

{!! trans('admin/settings/general.eula_markdown') !!}

{!! $errors->first('eula_text', '') !!} From ae9cf1e5b6fa4004035490bd881975068f6bbadf Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 2 Aug 2023 18:24:32 -0700 Subject: [PATCH 21/21] Formatting --- app/Http/Livewire/CategoryEditForm.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php index 21f0fa5c24..05a1fe9d45 100644 --- a/app/Http/Livewire/CategoryEditForm.php +++ b/app/Http/Livewire/CategoryEditForm.php @@ -15,6 +15,7 @@ class CategoryEditForm extends Component public $requireAcceptance; public $sendCheckInEmail; + public $useDefaultEula; public function mount() @@ -56,7 +57,7 @@ class CategoryEditForm extends Component public function getEulaTextDisabledProperty() { - return (bool) $this->useDefaultEula; + return (bool)$this->useDefaultEula; } public function getSendCheckInEmailDisabledProperty()