Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsov4ee79811bcb9
diff --git a/client/modules/crm/src/views/call/fields/contacts.js b/client/modules/crm/src/views/call/fields/contacts.js
index e9e27b7174..b583b7fa77 100644
--- a/client/modules/crm/src/views/call/fields/contacts.js
+++ b/client/modules/crm/src/views/call/fields/contacts.js
@@ -26,48 +26,48 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/call/fields/contacts', ['crm:views/meeting/fields/contacts'], function (Dep) {
+import AttendeesFieldView from 'modules/crm/views/meeting/fields/attendees';
- return Dep.extend({
+export default class extends AttendeesFieldView {
- getAttributeList: function () {
- let list = Dep.prototype.getAttributeList.call(this);
+ getAttributeList() {
+ return [
+ ...super.getAttributeList(),
+ 'phoneNumbersMap',
+ ]
+ }
- list.push('phoneNumbersMap');
+ getDetailLinkHtml(id, name) {
+ const html = super.getDetailLinkHtml(id, name);
- return list;
- },
+ const key = this.foreignScope + '_' + id;
+ const phoneNumbersMap = this.model.get('phoneNumbersMap') || {};
- getDetailLinkHtml: function (id, name) {
- let html = Dep.prototype.getDetailLinkHtml.call(this, id, name);
+ if (!(key in phoneNumbersMap)) {
+ return html;
+ }
- let key = this.foreignScope + '_' + id;
- let phoneNumbersMap = this.model.get('phoneNumbersMap') || {};
+ const number = phoneNumbersMap[key];
- if (!(key in phoneNumbersMap)) {
- return html;
- }
+ const $item = $(html);
- let number = phoneNumbersMap[key];
+ // @todo Format phone number.
- let $item = $(html);
+ $item
+ .append(
+ ' ',
+ $('<span>').addClass('text-muted middle-dot'),
+ ' ',
+ $('<a>')
+ .attr('href', 'tel:' + number)
+ .attr('data-phone-number', number)
+ .attr('data-action', 'dial')
+ .addClass('small')
+ .text(number)
+ )
- $item
- .append(
- ' ',
- $('<span>').addClass('text-muted middle-dot'),
- ' ',
- $('<a>')
- .attr('href', 'tel:' + number)
- .attr('data-phone-number', number)
- .attr('data-action', 'dial')
- .addClass('small')
- .text(number)
- )
-
- return $('<div>')
- .append($item)
- .get(0).outerHTML;
- },
- });
-});
+ return $('<div>')
+ .append($item)
+ .get(0).outerHTML;
+ }
+}
diff --git a/client/modules/crm/src/views/call/fields/leads.js b/client/modules/crm/src/views/call/fields/leads.js
index 8d68be73e7..07d5f34725 100644
--- a/client/modules/crm/src/views/call/fields/leads.js
+++ b/client/modules/crm/src/views/call/fields/leads.js
@@ -26,43 +26,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/call/fields/leads', ['crm:views/meeting/fields/attendees', 'crm:views/call/fields/contacts'],
-function (Dep, Contacts) {
+import ContactsFieldView from 'modules/crm/views/call/fields/contacts';
- return Dep.extend({
-
- getAttributeList: function () {
- let list = Dep.prototype.getAttributeList.call(this);
-
- list.push('phoneNumbersMap');
-
- return list;
- },
-
- getDetailLinkHtml: function (id, name) {
- return Contacts.prototype.getDetailLinkHtml.call(this, id, name);
- },
-
- getDetailLinkHtml1: function (id, name) {
- var html = Dep.prototype.getDetailLinkHtml.call(this, id, name);
-
- var key = this.foreignScope + '_' + id;
- var number = null;
- var phoneNumbersMap = this.model.get('phoneNumbersMap') || {};
- if (key in phoneNumbersMap) {
- number = phoneNumbersMap[key];
- var innerHtml = $(html).html();
-
- innerHtml += (
- ' <span class="text-muted middle-dot"></span> ' +
- '<a href="tel:' + number + '" class="small" data-phone-number="' + number + '" data-action="dial">' +
- number + '</a>'
- );
-
- html = '<div>' + innerHtml + '</div>';
- }
-
- return html;
- },
- });
-});
+export default class extends ContactsFieldView {}
diff --git a/client/modules/crm/src/views/call/record/edit-small.js b/client/modules/crm/src/views/call/record/edit-small.js
index 0dbd3fcea5..8836d2c7b1 100644
--- a/client/modules/crm/src/views/call/record/edit-small.js
+++ b/client/modules/crm/src/views/call/record/edit-small.js
@@ -26,9 +26,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/call/record/edit-small', ['views/record/edit'], function (Dep) {
+import EditRecordView from 'views/record/edit';
- return Dep.extend({
-
- });
-});
+export default class extends EditRecordView {}
diff --git a/client/modules/crm/src/views/call/record/list.js b/client/modules/crm/src/views/call/record/list.js
index e3fffe773e..fef2475c9d 100644
--- a/client/modules/crm/src/views/call/record/list.js
+++ b/client/modules/crm/src/views/call/record/list.js
@@ -26,119 +26,111 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/call/record/list', ['views/record/list'], function (Dep) {
+import ListRecordView from 'views/record/list';
- return Dep.extend({
+export default class extends ListRecordView {
- rowActionsView: 'crm:views/call/record/row-actions/default',
+ rowActionsView = 'modules/crm/views/call/record/row-actions/default'
- setup: function () {
- Dep.prototype.setup.call(this);
+ setup() {
+ super.setup();
- if (
- this.getAcl().checkScope(this.entityType, 'edit') &&
- this.getAcl().checkField(this.entityType, 'status', 'edit')
- ) {
- this.massActionList.push('setHeld');
- this.massActionList.push('setNotHeld');
- }
- },
-
- actionSetHeld: function (data) {
- let id = data.id;
+ if (
+ this.getAcl().checkScope(this.entityType, 'edit') &&
+ this.getAcl().checkField(this.entityType, 'status', 'edit')
+ ) {
+ this.massActionList.push('setHeld');
+ this.massActionList.push('setNotHeld');
+ }
+ }
- if (!id) {
- return;
- }
+ /**
+ * @protected
+ * @param {Record} data
+ */
+ async actionSetHeld(data) {
+ const id = data.id;
- var model = this.collection.get(id);
+ if (!id) {
+ return;
+ }
- if (!model) {
- return;
- }
+ const model = this.collection.get(id);
- model.set('status', 'Held');
+ if (!model) {
+ return;
+ }
- this.listenToOnce(model, 'sync', () => {
- Espo.Ui.notify(false);
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- this.collection.fetch();
- });
+ await model.save({status: 'Held'}, {patch: true});
- Espo.Ui.notifyWait();
+ Espo.Ui.success(this.translate('Saved'));
+ }
- model.save();
- },
+ /**
+ * @protected
+ * @param {Record} data
+ */
+ async actionSetNotHeld(data) {
+ const id = data.id;
- actionSetNotHeld: function (data) {
- let id = data.id;
+ if (!id) {
+ return;
+ }
- if (!id) {
- return;
- }
+ const model = this.collection.get(id);
- let model = this.collection.get(id);
+ if (!model) {
+ return;
+ }
- if (!model) {
- return;
- }
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- model.set('status', 'Not Held');
+ await model.save({status: 'Not Held'}, {patch: true});
- this.listenToOnce(model, 'sync', () => {
- Espo.Ui.notify(false);
- this.collection.fetch();
- });
+ Espo.Ui.success(this.translate('Saved'));
+ }
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ // noinspection JSUnusedGlobalSymbols
+ async massActionSetHeld() {
+ const data = {};
- model.save();
- },
+ data.ids = this.checkedList;
- massActionSetHeld: function () {
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- let data = {};
+ await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetHeld`, data);
- data.ids = this.checkedList;
+ Espo.Ui.success(this.translate('Saved'));
- Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetHeld', data)
- .then(() => {
- Espo.Ui.notify(false);
+ await this.collection.fetch();
- this.listenToOnce(this.collection, 'sync', () => {
- data.ids.forEach(id => {
- if (this.collection.get(id)) {
- this.checkRecord(id);
- }
- });
- });
+ data.ids.forEach(id => {
+ if (this.collection.get(id)) {
+ this.checkRecord(id);
+ }
+ });
+ }
- this.collection.fetch();
- });
- },
+ // noinspection JSUnusedGlobalSymbols
+ async massActionSetNotHeld() {
+ const data = {};
- massActionSetNotHeld: function () {
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ data.ids = this.checkedList;
- let data = {};
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- data.ids = this.checkedList;
+ await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetNotHeld`, data);
- Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetNotHeld', data)
- .then(() => {
- Espo.Ui.notify(false);
+ Espo.Ui.success(this.translate('Saved'));
- this.listenToOnce(this.collection, 'sync', () => {
- data.ids.forEach(id => {
- if (this.collection.get(id)) {
- this.checkRecord(id);
- }
- });
- });
+ await this.collection.fetch();
- this.collection.fetch();
- });
- },
- });
-});
+ data.ids.forEach(id => {
+ if (this.collection.get(id)) {
+ this.checkRecord(id);
+ }
+ });
+ }
+}
diff --git a/client/modules/crm/src/views/meeting/fields/contacts.js b/client/modules/crm/src/views/meeting/fields/contacts.js
index 0aa8c5acad..691af012bb 100644
--- a/client/modules/crm/src/views/meeting/fields/contacts.js
+++ b/client/modules/crm/src/views/meeting/fields/contacts.js
@@ -26,8 +26,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/meeting/fields/contacts', ['crm:views/meeting/fields/attendees'], function (Dep) {
+import AttendeesFieldView from 'modules/crm/views/meeting/fields/attendees';
- /** Left for bc. */
- return Dep.extend({});
-});
+export default class extends AttendeesFieldView {}
diff --git a/client/modules/crm/src/views/meeting/record/edit-small.js b/client/modules/crm/src/views/meeting/record/edit-small.js
index 4d7db06199..8836d2c7b1 100644
--- a/client/modules/crm/src/views/meeting/record/edit-small.js
+++ b/client/modules/crm/src/views/meeting/record/edit-small.js
@@ -26,10 +26,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/meeting/record/edit-small', ['views/record/edit'], function (Dep) {
-
- return Dep.extend({
-
- });
-});
+import EditRecordView from 'views/record/edit';
+export default class extends EditRecordView {}
diff --git a/client/modules/crm/src/views/meeting/record/list.js b/client/modules/crm/src/views/meeting/record/list.js
index 58202c6ae4..d872c8bf9b 100644
--- a/client/modules/crm/src/views/meeting/record/list.js
+++ b/client/modules/crm/src/views/meeting/record/list.js
@@ -26,109 +26,111 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-define('crm:views/meeting/record/list', ['views/record/list'], function (Dep) {
+import ListRecordView from 'views/record/list';
- return Dep.extend({
+export default class extends ListRecordView {
- rowActionsView: 'crm:views/meeting/record/row-actions/default',
+ rowActionsView = 'modules/crm/views/meeting/record/row-actions/default'
- setup: function () {
- Dep.prototype.setup.call(this);
+ setup() {
+ super.setup();
- if (
- this.getAcl().checkScope(this.entityType, 'edit') &&
- this.getAcl().checkField(this.entityType, 'status', 'edit')
- ) {
- this.massActionList.push('setHeld');
- this.massActionList.push('setNotHeld');
- }
- },
+ if (
+ this.getAcl().checkScope(this.entityType, 'edit') &&
+ this.getAcl().checkField(this.entityType, 'status', 'edit')
+ ) {
+ this.massActionList.push('setHeld');
+ this.massActionList.push('setNotHeld');
+ }
+ }
- actionSetHeld: function (data) {
- const id = data.id;
+ /**
+ * @protected
+ * @param {Record} data
+ */
+ async actionSetHeld(data) {
+ const id = data.id;
- if (!id) {
- return;
- }
+ if (!id) {
+ return;
+ }
- const model = this.collection.get(id);
+ const model = this.collection.get(id);
- if (!model) {
- return;
- }
+ if (!model) {
+ return;
+ }
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- model.save({status: 'Held'}, {patch: true}).then(() => {
- Espo.Ui.success(this.translate('Saved'));
+ await model.save({status: 'Held'}, {patch: true});
- this.collection.fetch();
- });
- },
+ Espo.Ui.success(this.translate('Saved'));
+ }
- actionSetNotHeld: function (data) {
- const id = data.id;
+ /**
+ * @protected
+ * @param {Record} data
+ */
+ async actionSetNotHeld(data) {
+ const id = data.id;
- if (!id) {
- return;
- }
+ if (!id) {
+ return;
+ }
- const model = this.collection.get(id);
+ const model = this.collection.get(id);
- if (!model) {
- return;
- }
+ if (!model) {
+ return;
+ }
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- model.save({status: 'Not Held'}, {patch: true}).then(() => {
- Espo.Ui.success(this.translate('Saved'));
+ await model.save({status: 'Not Held'}, {patch: true});
- this.collection.fetch();
- });
- },
+ Espo.Ui.success(this.translate('Saved'));
+ }
- massActionSetHeld: function () {
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ // noinspection JSUnusedGlobalSymbols
+ async massActionSetHeld() {
+ const data = {};
- const data = {ids: this.checkedList};
+ data.ids = this.checkedList;
- Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetHeld', data)
- .then(() => {
- Espo.Ui.notify(false);
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- this.listenToOnce(this.collection, 'sync', () => {
- data.ids.forEach(id => {
- if (this.collection.get(id)) {
- this.checkRecord(id);
- }
- });
- });
+ await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetHeld`, data);
- this.collection.fetch();
- });
- },
+ Espo.Ui.success(this.translate('Saved'));
- massActionSetNotHeld: function () {
- Espo.Ui.notify(this.translate('saving', 'messages'));
+ await this.collection.fetch();
- const data = {ids: this.checkedList};
+ data.ids.forEach(id => {
+ if (this.collection.get(id)) {
+ this.checkRecord(id);
+ }
+ });
+ }
+
+ // noinspection JSUnusedGlobalSymbols
+ async massActionSetNotHeld() {
+ const data = {};
+
+ data.ids = this.checkedList;
- Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetNotHeld', data)
- .then(() => {
- Espo.Ui.notify(false);
+ Espo.Ui.notify(this.translate('saving', 'messages'));
- this.listenToOnce(this.collection, 'sync', () => {
- data.ids.forEach(id => {
- if (this.collection.get(id)) {
- this.checkRecord(id);
- }
- });
- });
+ await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetNotHeld`, data);
- this.collection.fetch();
- });
- },
+ Espo.Ui.success(this.translate('Saved'));
- });
-});
+ await this.collection.fetch();
+
+ data.ids.forEach(id => {
+ if (this.collection.get(id)) {
+ this.checkRecord(id);
+ }
+ });
+ }
+}