Evaluate if a custom field is a Date to present it with the correct format

This commit is contained in:
Ivan Nieto Vivanco 2022-06-07 18:00:46 -05:00
parent 7faaa4ce24
commit 740f27198f
2 changed files with 16 additions and 4 deletions

View file

@ -98,6 +98,14 @@ class AssetsTransformer
$decrypted = Helper::gracefulDecrypt($field, $asset->{$field->convertUnicodeDbSlug()});
$value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));
if ($field->format == 'DATE'){
if (Gate::allows('superadmin')){
$value = Helper::getFormattedDateObject($value)['formatted'];
} else {
$value = strtoupper(trans('admin/custom_fields/general.encrypted'));
}
}
$fields_array[$field->name] = [
'field' => e($field->convertUnicodeDbSlug()),
'value' => e($value),
@ -105,14 +113,18 @@ class AssetsTransformer
];
} else {
$value = $asset->{$field->convertUnicodeDbSlug()};
if ($field->format == 'DATE'){
$value = Helper::getFormattedDateObject($value)['formatted'];
}
$fields_array[$field->name] = [
'field' => e($field->convertUnicodeDbSlug()),
'value' => e($asset->{$field->convertUnicodeDbSlug()}),
'value' => e($value),
'field_format' => $field->format,
];
}
$array['custom_fields'] = $fields_array;
}
} else {

View file

@ -465,7 +465,7 @@
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') {
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') {
} 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') {
return '<a href="mailto:' + row.custom_fields[field_column_plain].value + '">' + row.custom_fields[field_column_plain].value + '</a>';