mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Possible fix for asset model editing when no custom fieldset is associated
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
476e17055b
commit
bbb0d1be17
|
@ -19,15 +19,24 @@ class CustomFieldSetDefaultValuesForModel extends Component
|
||||||
{
|
{
|
||||||
$this->model = AssetModel::find($this->model_id); // It's possible to do some clever route-model binding here, but let's keep it simple, shall we?
|
$this->model = AssetModel::find($this->model_id); // It's possible to do some clever route-model binding here, but let's keep it simple, shall we?
|
||||||
$this->fieldset_id = $this->model->fieldset_id;
|
$this->fieldset_id = $this->model->fieldset_id;
|
||||||
|
|
||||||
|
$this->fields = null;
|
||||||
|
|
||||||
|
if ($fieldset = CustomFieldset::find($this->fieldset_id)) {
|
||||||
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
||||||
$this->add_default_values = ( $this->model->defaultValues->count() > 0);
|
}
|
||||||
|
|
||||||
|
$this->add_default_values = ($this->model->defaultValues->count() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatedFieldsetId()
|
public function updatedFieldsetId()
|
||||||
{
|
{
|
||||||
|
if (CustomFieldset::find($this->fieldset_id)) {
|
||||||
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.custom-field-set-default-values-for-model');
|
return view('livewire.custom-field-set-default-values-for-model');
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if( $this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}
|
@if ($this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}
|
||||||
<div>
|
<div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@if ($fields)
|
||||||
@foreach ($fields as $field)
|
@foreach ($fields as $field)
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue