From 740f27198fda435920371e01bfa9e566d905d931 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 7 Jun 2022 18:00:46 -0500 Subject: [PATCH] Evaluate if a custom field is a Date to present it with the correct format --- app/Http/Transformers/AssetsTransformer.php | 18 +++++++++++++++--- .../views/partials/bootstrap-table.blade.php | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 742c8013d9..3af439d12e 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -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 { diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 9a63ca58bd..5a84c4fdf8 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -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 '' + row.custom_fields[field_column_plain].value + ''; - }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) ? "" : ""; } else if (row.custom_fields[field_column_plain].field_format=='EMAIL') { return '' + row.custom_fields[field_column_plain].value + '';