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); } }