Add support for boolean type customfields

This commit is contained in:
Ivan Nieto Vivanco 2022-03-21 18:48:42 -06:00
parent 7cbcd2d95c
commit 7571c0b850
3 changed files with 11 additions and 1 deletions

View file

@ -189,6 +189,12 @@ class Asset extends Depreciable
} }
} }
foreach ($this->model->fieldset->fields as $field){
if($field->format == 'BOOLEAN'){
$this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN);
}
}
return parent::save($params); return parent::save($params);
} }

View file

@ -447,7 +447,9 @@
@endcan @endcan
@else @else
@if (($field->format=='URL') && ($asset->{$field->db_column_name()}!='')) @if (($field->format=='BOOLEAN') && ($asset->{$field->db_column_name()}!=''))
{!! ($asset->{$field->db_column_name()} == 1) ? "<span class='fas fa-check-circle' style='color:green' />" : "<span class='fas fa-times-circle' style='color:red' />" !!}
@elseif (($field->format=='URL') && ($asset->{$field->db_column_name()}!=''))
<a href="{{ $asset->{$field->db_column_name()} }}" target="_new">{{ $asset->{$field->db_column_name()} }}</a> <a href="{{ $asset->{$field->db_column_name()} }}" target="_new">{{ $asset->{$field->db_column_name()} }}</a>
@elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!='')) @elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!=''))
{{ \App\Helpers\Helper::getFormattedDateObject($asset->{$field->db_column_name()}, 'date', false) }} {{ \App\Helpers\Helper::getFormattedDateObject($asset->{$field->db_column_name()}, 'date', false) }}

View file

@ -438,6 +438,8 @@
if ((row.custom_fields[field_column_plain].field_format) && (row.custom_fields[field_column_plain].value)) { if ((row.custom_fields[field_column_plain].field_format) && (row.custom_fields[field_column_plain].value)) {
if (row.custom_fields[field_column_plain].field_format=='URL') { if (row.custom_fields[field_column_plain].field_format=='URL') {
return '<a href="' + row.custom_fields[field_column_plain].value + '" target="_blank" rel="noopener">' + row.custom_fields[field_column_plain].value + '</a>'; return '<a href="' + row.custom_fields[field_column_plain].value + '" target="_blank" rel="noopener">' + row.custom_fields[field_column_plain].value + '</a>';
}else if (row.custom_fields[field_column_plain].field_format=='BOOLEAN') {
return (row.custom_fields[field_column_plain].value == 1) ? "<span class='fas fa-check-circle' style='color:green' />" : "<span class='fas fa-times-circle' style='color:red' />";
} else if (row.custom_fields[field_column_plain].field_format=='EMAIL') { } else if (row.custom_fields[field_column_plain].field_format=='EMAIL') {
return '<a href="mailto:' + row.custom_fields[field_column_plain].value + '">' + row.custom_fields[field_column_plain].value + '</a>'; return '<a href="mailto:' + row.custom_fields[field_column_plain].value + '">' + row.custom_fields[field_column_plain].value + '</a>';
} }