Merge pull request #11272 from inietov/fixes/date_localization_in_customfields

Fixes #8143 Date localization not working on custom fields
This commit is contained in:
snipe 2022-06-13 19:47:20 -07:00 committed by GitHub
commit 20a0c4e3b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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),
@ -107,15 +115,19 @@ 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,
'element' => $field->element,
];
}
$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>';