mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Set send email back to original value when eulas cleared
This commit is contained in:
parent
48979ce177
commit
896f038054
|
@ -10,14 +10,17 @@ class CategoryEditForm extends Component
|
||||||
|
|
||||||
public $eulaText;
|
public $eulaText;
|
||||||
|
|
||||||
|
public $originalSendCheckInEmailValue;
|
||||||
|
|
||||||
public $requireAcceptance;
|
public $requireAcceptance;
|
||||||
|
|
||||||
public $sendCheckInEmail;
|
public $sendCheckInEmail;
|
||||||
|
|
||||||
public $useDefaultEula;
|
public $useDefaultEula;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$this->originalSendCheckInEmailValue = $this->sendCheckInEmail;
|
||||||
|
|
||||||
if ($this->eulaText || $this->useDefaultEula) {
|
if ($this->eulaText || $this->useDefaultEula) {
|
||||||
$this->sendCheckInEmail = true;
|
$this->sendCheckInEmail = true;
|
||||||
}
|
}
|
||||||
|
@ -30,9 +33,11 @@ class CategoryEditForm extends Component
|
||||||
|
|
||||||
public function updated($property, $value)
|
public function updated($property, $value)
|
||||||
{
|
{
|
||||||
if (in_array($property, ['eulaText', 'useDefaultEula'])) {
|
if (! in_array($property, ['eulaText', 'useDefaultEula'])) {
|
||||||
$this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? true : $this->originalSendCheckInEmailValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShouldDisplayEmailMessageProperty(): bool
|
public function getShouldDisplayEmailMessageProperty(): bool
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<livewire:category-edit-form
|
<livewire:category-edit-form
|
||||||
:checkin-email="old('checkin_email', $item->checkin_email)"
|
|
||||||
:default-eula-text="$snipeSettings->default_eula_text"
|
:default-eula-text="$snipeSettings->default_eula_text"
|
||||||
:eula-text="old('eula_text', $item->eula_text)"
|
:eula-text="old('eula_text', $item->eula_text)"
|
||||||
:require-acceptance="old('require_acceptance', $item->require_acceptance)"
|
:require-acceptance="old('require_acceptance', $item->require_acceptance)"
|
||||||
|
:send-check-in-email="old('checkin_email', $item->checkin_email)"
|
||||||
:use-default-eula="old('use_default_eula', $item->use_default_eula)"
|
:use-default-eula="old('use_default_eula', $item->use_default_eula)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -70,5 +70,27 @@ class CategoryEditFormTest extends TestCase
|
||||||
->assertSet('eulaTextDisabled', true)
|
->assertSet('eulaTextDisabled', true)
|
||||||
->assertSet('sendCheckInEmailDisabled', 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue