mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Automatically check the send email to user checkbox in certain conditions
This commit is contained in:
parent
dee6ebf8e0
commit
269414e4f2
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue