Disable send email when it should not be modified

This commit is contained in:
Marcus Moore 2023-08-02 16:52:56 -07:00
parent e12935f7fa
commit 48979ce177
No known key found for this signature in database
3 changed files with 12 additions and 5 deletions

View file

@ -30,8 +30,8 @@ class CategoryEditForm extends Component
public function updated($property, $value) public function updated($property, $value)
{ {
if (in_array($property, ['eulaText', 'useDefaultEula']) && ($this->eulaText || $this->useDefaultEula)) { if (in_array($property, ['eulaText', 'useDefaultEula'])) {
$this->sendCheckInEmail = (bool)$value; $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula;
} }
} }
@ -53,4 +53,9 @@ class CategoryEditForm extends Component
{ {
return $this->useDefaultEula; return $this->useDefaultEula;
} }
public function getSendCheckInEmailDisabledProperty()
{
return $this->eulaText || $this->useDefaultEula;
}
} }

View file

@ -41,7 +41,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('checkin_email', '1', null, ['wire:model' => 'sendCheckInEmail', 'aria-label'=>'checkin_email']) }} {{ Form::checkbox('checkin_email', '1', null, ['wire:model' => 'sendCheckInEmail', 'aria-label'=>'checkin_email', 'disabled' => $this->sendCheckInEmailDisabled]) }}
{{ trans('admin/categories/general.checkin_email') }} {{ trans('admin/categories/general.checkin_email') }}
</label> </label>
@if ($this->shouldDisplayEmailMessage) @if ($this->shouldDisplayEmailMessage)

View file

@ -59,7 +59,7 @@ class CategoryEditFormTest extends TestCase
->assertSet('sendCheckInEmail', true); ->assertSet('sendCheckInEmail', true);
} }
public function testSendEmailCheckboxCheckedAndEulaTextDisabledWhenUseDefaultEulaSelected() public function testSendEmailCheckboxCheckedAndDisabledAndEulaTextDisabledWhenUseDefaultEulaSelected()
{ {
Livewire::test(CategoryEditForm::class, [ Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false, 'sendCheckInEmail' => false,
@ -67,6 +67,8 @@ class CategoryEditFormTest extends TestCase
])->assertSet('sendCheckInEmail', false) ])->assertSet('sendCheckInEmail', false)
->set('useDefaultEula', true) ->set('useDefaultEula', true)
->assertSet('sendCheckInEmail', true) ->assertSet('sendCheckInEmail', true)
->assertSet('eulaTextDisabled', true); ->assertSet('eulaTextDisabled', true)
->assertSet('sendCheckInEmailDisabled', true);
}
} }
} }