mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Uncheck a couple boxes by default to match existing behavior
This commit is contained in:
parent
861ef6312e
commit
1630392953
|
@ -48,13 +48,13 @@ class ReportTemplate extends Model
|
|||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function checkmarkValue(string $fieldName): string
|
||||
public function checkmarkValue(string $fieldName, string $fallbackValue = '1'): string
|
||||
{
|
||||
// Assuming we're using the null object pattern, and an empty model
|
||||
// was passed to the view when showing the default report page,
|
||||
// return 1 so that checkboxes are checked by default.
|
||||
// return the fallback value so that checkboxes are checked by default.
|
||||
if (is_null($this->id)) {
|
||||
return '1';
|
||||
return $fallbackValue;
|
||||
}
|
||||
|
||||
// Return the field's value if it exists and return 0
|
||||
|
|
|
@ -407,13 +407,13 @@
|
|||
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
<label class="form-control">
|
||||
{{ Form::checkbox('exclude_archived', '1', $template->checkmarkValue('exclude_archived')) }}
|
||||
{{ Form::checkbox('exclude_archived', '1', $template->checkmarkValue('exclude_archived', '0')) }}
|
||||
{{ trans('general.exclude_archived') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
<label class="form-control">
|
||||
{{ Form::checkbox('use_bom', '1', $template->checkmarkValue('use_bom')) }}
|
||||
{{ Form::checkbox('use_bom', '1', $template->checkmarkValue('use_bom', '0')) }}
|
||||
{{ trans('general.bom_remark') }}
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
@ -69,6 +69,7 @@ class ReportTemplateTest extends TestCase
|
|||
$this->assertEquals('1', $template->checkmarkValue('is_a_checkbox_field'));
|
||||
$this->assertEquals('0', $template->checkmarkValue('non_existent_key'));
|
||||
$this->assertEquals('0', $template->checkmarkValue('is_checkbox_field_with_zero'));
|
||||
$this->assertEquals('0', (new ReportTemplate)->checkmarkValue('non_existent_key', '0'));
|
||||
}
|
||||
|
||||
public function testParsingTextValue()
|
||||
|
|
Loading…
Reference in a new issue