EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
full refresh on header title click
Yuri Kuznetsov4336344d405a
diff --git a/client/src/views/detail.js b/client/src/views/detail.jsindex 89e122c87f..451204e280 100644--- a/client/src/views/detail.js+++ b/client/src/views/detail.js@@ -152,6 +152,8 @@ class DetailView extends MainView {this.initFollowButtons();this.initStarButtons();this.initRedirect();++ this.addActionHandler('fullRefresh', () => this.actionFullRefresh());}/** @inheritDoc */@@ -572,10 +574,17 @@ class DetailView extends MainView {title.style.textDecoration = 'line-through';}+ if (this.getRecordView().getMode() === 'detail') {+ title.title = this.translate('clickToRefresh', 'messages');+ title.dataset.action = 'fullRefresh';+ title.style.cursor = 'pointer';+ }+const scopeLabel = this.getLanguage().translate(this.scope, 'scopeNamesPlural');let root = document.createElement('span');root.text = scopeLabel;+ root.style.userSelect = 'none';if (!this.rootLinkDisabled) {const a = document.createElement('a');@@ -585,6 +594,7 @@ class DetailView extends MainView {a.text = scopeLabel;root = document.createElement('span');+ root.style.userSelect = 'none';root.append(a);}@@ -708,6 +718,35 @@ class DetailView extends MainView {this.modesView.showMode(mode);}++ /**+ * @protected+ */+ async actionFullRefresh() {+ if (this.getRecordMode() === 'edit') {+ return;+ }++ Espo.Ui.notify(' ... ');++ await this.model.fetch();++ this.model.trigger('update-all');++ Espo.Ui.notify();+ }++ /**+ * @private+ * @return {'detail'|'edit'}+ */+ getRecordMode() {+ if (this.getRecordView().getMode) {+ return this.getRecordView().getMode();+ }++ return 'detail';+ }}export default DetailView;diff --git a/client/src/views/list-with-categories.js b/client/src/views/list-with-categories.jsindex a873be5b63..8152c92555 100644--- a/client/src/views/list-with-categories.js+++ b/client/src/views/list-with-categories.js@@ -758,20 +758,23 @@ class ListWithCategories extends ListView {return super.getHeader();}- let rootUrl = '#' + this.scope;+ let rootUrl = `#${this.scope}`;if (this._primaryFilter) {- rootUrl += '/list/primaryFilter=' + this.getHelper().escapeString(this._primaryFilter);+ const filterPart = this.getHelper().escapeString(this._primaryFilter);++ rootUrl += `/list/primaryFilter=${filterPart}`;}- const $root = $('<a>')- .attr('href', rootUrl)- .addClass('action')- .text(this.translate(this.scope, 'scopeNamesPlural'))- .addClass('action')- .attr('data-action', 'openCategory');+ const root = document.createElement('a');+ root.href = rootUrl;+ root.textContent = this.translate(this.scope, 'scopeNamesPlural');+ root.dataset.action = 'openCategory';+ root.classList.add('action');+ root.style.userSelect = 'none';- const list = [$root];+ /** @type {*[]} */+ const list = [root];const currentName = this.nestedCategoriesCollection.categoryData.name;const upperId = this.nestedCategoriesCollection.categoryData.upperId;@@ -782,26 +785,35 @@ class ListWithCategories extends ListView {}if (upperId) {- let url = rootUrl + '/' + 'list/categoryId=' + this.getHelper().escapeString(upperId);+ const upperIdPart = this.getHelper().escapeString(upperId);++ let url = `${rootUrl}/list/categoryId=${upperIdPart}`;if (this._primaryFilter) {- url += '&primaryFilter=' + this.getHelper().escapeString(this._primaryFilter);+ const filterPart = this.getHelper().escapeString(this._primaryFilter);++ url += `&primaryFilter=${filterPart}`;}- const $folder = $('<a>')- .attr('href', url)- .text(upperName)- .addClass('action')- .attr('data-action', 'openCategory')- .attr('data-id', upperId)- .attr('data-name', upperName);+ const folder = document.createElement('a');+ folder.href = url;+ folder.textContent = upperName;+ folder.classList.add('action');+ folder.dataset.action = 'openCategory';+ folder.dataset.id = upperId;+ folder.dataset.name = upperName;+ folder.style.userSelect = 'none';- list.push($folder);+ list.push(folder);}- const $last = $('<span>').text(currentName);+ const last = document.createElement('span');+ last.textContent = currentName;+ last.dataset.action = 'fullRefresh';+ last.style.cursor = 'pointer';+ last.style.userSelect = 'none';- list.push($last);+ list.push(last);return this.buildHeaderHtml(list);}diff --git a/client/src/views/list.js b/client/src/views/list.jsindex a6d4902ef0..0a47f51e8a 100644--- a/client/src/views/list.js+++ b/client/src/views/list.js@@ -254,6 +254,8 @@ class ListView extends MainView {if (this._fromAdmin || this._primaryFilter) {this.keepCurrentRootUrl = true;}++ this.addActionHandler('fullRefresh', () => this.actionFullRefresh());}setupFinal() {@@ -720,32 +722,42 @@ class ListView extends MainView {* @inheritDoc*/getHeader() {- const $root = $('<span>')- .text(this.getLanguage().translate(this.scope, 'scopeNamesPlural'));-if (this._fromAdmin) {- const $root = $('<a>')- .attr('href', '#Admin')- .text(this.translate('Administration', 'labels', 'Admin'));+ const root = document.createElement('a');+ root.href = '#Admin';+ root.textContent = this.translate('Administration', 'labels', 'Admin');+ root.style.userSelect = 'none';- const $scope = $('<span>')- .text(this.getLanguage().translate(this.scope, 'scopeNamesPlural'));+ const scope = document.createElement('span');+ scope.textContent = this.getLanguage().translate(this.scope, 'scopeNamesPlural');+ scope.dataset.action = 'fullRefresh';+ scope.style.cursor = 'pointer';+ scope.style.userSelect = 'none';- return this.buildHeaderHtml([$root, $scope]);+ return this.buildHeaderHtml([root, scope]);}- const headerIconHtml = this.getHeaderIconHtml();+ const root = document.createElement('span');+ root.textContent = this.getLanguage().translate(this.scope, 'scopeNamesPlural');++ root.title = this.translate('clickToRefresh', 'messages');+ root.dataset.action = 'fullRefresh';+ root.style.cursor = 'pointer';+ root.style.userSelect = 'none';++ const iconHtml = this.getHeaderIconHtml();- if (headerIconHtml) {- $root.prepend(headerIconHtml);+ if (iconHtml) {+ root.insertAdjacentHTML('afterbegin', iconHtml);}if (this._primaryFilter) {const label = this.translate(this._primaryFilter, 'presetFilters', this.entityType);- $root.append(' · ' + label);++ root.insertAdjacentHTML('afterend', ' · ' + label);}- return this.buildHeaderHtml([$root]);+ return this.buildHeaderHtml([root]);}/**@@ -973,6 +985,17 @@ class ListView extends MainView {handleShortcutKeyControlArrowRight(e) {this.getRecordView().trigger('request-page', 'next');}++ /**+ * @protected+ */+ async actionFullRefresh() {+ Espo.Ui.notify(' ... ');++ await this.collection.fetch();++ Espo.Ui.notify();+ }}export default ListView;