From 2c4d853a5b7e900a44c3bb1915e764f380a283ed Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 7 Oct 2024 11:36:28 +0300 Subject: [PATCH] datetimeShort ref --- .../Espo/Resources/layouts/Email/list.json | 2 +- .../Resources/layouts/Email/listSmall.json | 6 ++-- .../Resources/metadata/entityDefs/Email.json | 3 +- client/res/templates/fields/date/detail.tpl | 1 + client/res/templates/fields/date/list.tpl | 2 +- .../fields/datetime-short/detail.tpl | 14 -------- .../templates/fields/datetime-short/list.tpl | 6 ---- client/src/views/email/fields/date-sent.js | 34 +++++++++++++++++++ client/src/views/fields/date.js | 4 +++ client/src/views/fields/datetime-short.js | 28 ++++++++++++--- 10 files changed, 69 insertions(+), 31 deletions(-) delete mode 100644 client/res/templates/fields/datetime-short/detail.tpl delete mode 100644 client/res/templates/fields/datetime-short/list.tpl create mode 100644 client/src/views/email/fields/date-sent.js diff --git a/application/Espo/Resources/layouts/Email/list.json b/application/Espo/Resources/layouts/Email/list.json index bd19f9c254..2aa2f15656 100644 --- a/application/Espo/Resources/layouts/Email/list.json +++ b/application/Espo/Resources/layouts/Email/list.json @@ -2,5 +2,5 @@ {"name": "personStringData", "width":18, "notSortable": true, "noLabel": true}, {"name": "subject", "link": true, "notSortable": true}, {"name": "parent", "notSortable": true, "width": 21}, - {"name": "dateSent", "view": "views/fields/datetime-short", "notSortable": true, "width": 10, "align": "right"} + {"name": "dateSent", "notSortable": true, "width": 10, "align": "right"} ] diff --git a/application/Espo/Resources/layouts/Email/listSmall.json b/application/Espo/Resources/layouts/Email/listSmall.json index 96bb959a9e..50d32b797e 100644 --- a/application/Espo/Resources/layouts/Email/listSmall.json +++ b/application/Espo/Resources/layouts/Email/listSmall.json @@ -1,5 +1,5 @@ [ - {"name":"personStringData", "width":20, "notSortable": true, "customLabel": ""}, - {"name":"subject", "link":true, "notSortable": true}, - {"name":"dateSent", "view": "views/fields/datetime-short", "notSortable": true, "width": 16, "align": "right"} + {"name":"personStringData", "width":20, "notSortable": true, "noLabel": true}, + {"name":"subject", "link": true, "notSortable": true}, + {"name":"dateSent", "notSortable": true, "width": 16, "align": "right"} ] diff --git a/application/Espo/Resources/metadata/entityDefs/Email.json b/application/Espo/Resources/metadata/entityDefs/Email.json index d0c7304dc5..bee51b6603 100644 --- a/application/Espo/Resources/metadata/entityDefs/Email.json +++ b/application/Espo/Resources/metadata/entityDefs/Email.json @@ -404,7 +404,8 @@ "type": "datetime", "customizationDisabled": true, "layoutDefaultSidePanelDisabled": true, - "massUpdateDisabled": true + "massUpdateDisabled": true, + "view": "views/email/fields/date-sent" }, "deliveryDate": { "type": "datetime", diff --git a/client/res/templates/fields/date/detail.tpl b/client/res/templates/fields/date/detail.tpl index 504e3406ec..7501cc5c7d 100644 --- a/client/res/templates/fields/date/detail.tpl +++ b/client/res/templates/fields/date/detail.tpl @@ -1,5 +1,6 @@ {{#if dateValue ~}} {{dateValue}} {{~/if}} diff --git a/client/res/templates/fields/date/list.tpl b/client/res/templates/fields/date/list.tpl index 0c194cfcf7..4209bc43f8 100644 --- a/client/res/templates/fields/date/list.tpl +++ b/client/res/templates/fields/date/list.tpl @@ -1,6 +1,6 @@ {{#if dateValue~}} {{dateValue}} {{~/if}} diff --git a/client/res/templates/fields/datetime-short/detail.tpl b/client/res/templates/fields/datetime-short/detail.tpl deleted file mode 100644 index 93ae12cc60..0000000000 --- a/client/res/templates/fields/datetime-short/detail.tpl +++ /dev/null @@ -1,14 +0,0 @@ -{{#if dateValue ~}} - {{dateValue}} -{{~/if}} - -{{#if isNone}} -{{translate 'None'}} -{{/if}} - -{{#if isLoading}} - -{{/if}} diff --git a/client/res/templates/fields/datetime-short/list.tpl b/client/res/templates/fields/datetime-short/list.tpl deleted file mode 100644 index 4c03cfbde0..0000000000 --- a/client/res/templates/fields/datetime-short/list.tpl +++ /dev/null @@ -1,6 +0,0 @@ -{{#if dateValue~}} - {{dateValue}} -{{~/if}} diff --git a/client/src/views/email/fields/date-sent.js b/client/src/views/email/fields/date-sent.js new file mode 100644 index 0000000000..8840439645 --- /dev/null +++ b/client/src/views/email/fields/date-sent.js @@ -0,0 +1,34 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM – Open Source CRM application. + * Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko + * Website: https://www.espocrm.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +import DatetimeShortFieldView from 'views/fields/datetime-short'; + +export default class extends DatetimeShortFieldView { + + shortInDetailMode = false +} diff --git a/client/src/views/fields/date.js b/client/src/views/fields/date.js index 13131925fb..58cd690207 100644 --- a/client/src/views/fields/date.js +++ b/client/src/views/fields/date.js @@ -165,6 +165,10 @@ class DateFieldView extends BaseFieldView { } } + if (this.isListMode()) { + data.titleDateValue = data.dateValue; + } + // noinspection JSValidateTypes return data; } diff --git a/client/src/views/fields/datetime-short.js b/client/src/views/fields/datetime-short.js index 242d7368c2..d31354cd01 100644 --- a/client/src/views/fields/datetime-short.js +++ b/client/src/views/fields/datetime-short.js @@ -33,21 +33,39 @@ import moment from 'moment'; class DatetimeShortFieldView extends DatetimeFieldView { - listTemplate = 'fields/datetime-short/list' - detailTemplate = 'fields/datetime-short/detail' + /** + * @protected + * @type {boolean} + */ + shortInListMode = true + + /** + * @protected + * @type {boolean} + */ + shortInDetailMode = true data() { const data = super.data(); - if (this.mode === this.MODE_LIST || this.mode === this.MODE_DETAIL) { - data.fullDateValue = super.getDateStringValue(); + if (this.toApplyShort()) { + data.titleDateValue = super.getDateStringValue(); } return data; } + /** + * @private + * @return {boolean} + */ + toApplyShort() { + return this.shortInListMode && this.mode === this.MODE_LIST || + this.shortInDetailMode && this.mode === this.MODE_DETAIL; + } + getDateStringValue() { - if (!(this.mode === this.MODE_LIST || this.mode === this.MODE_DETAIL)) { + if (!this.toApplyShort()) { return super.getDateStringValue(); }