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( + ' ', + $('').addClass('text-muted middle-dot'), + ' ', + $('') + .attr('href', 'tel:' + number) + .attr('data-phone-number', number) + .attr('data-action', 'dial') + .addClass('small') + .text(number) + ) - $item - .append( - ' ', - $('').addClass('text-muted middle-dot'), - ' ', - $('') - .attr('href', 'tel:' + number) - .attr('data-phone-number', number) - .attr('data-action', 'dial') - .addClass('small') - .text(number) - ) - - return $('
') - .append($item) - .get(0).outerHTML; - }, - }); -}); + return $('
') + .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 += ( - ' ' + - '' + - number + '' - ); - - html = '
' + innerHtml + '
'; - } - - 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'); + if ( + this.getAcl().checkScope(this.entityType, 'edit') && + this.getAcl().checkField(this.entityType, 'status', 'edit') + ) { + this.massActionList.push('setHeld'); + this.massActionList.push('setNotHeld'); + } + } + + /** + * @protected + * @param {Record} data + */ + async actionSetHeld(data) { + const id = data.id; + + if (!id) { + return; + } + + const model = this.collection.get(id); + + if (!model) { + return; + } + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await model.save({status: 'Held'}, {patch: true}); + + Espo.Ui.success(this.translate('Saved')); + } + + /** + * @protected + * @param {Record} data + */ + async actionSetNotHeld(data) { + const id = data.id; + + if (!id) { + return; + } + + const model = this.collection.get(id); + + if (!model) { + return; + } + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await model.save({status: 'Not Held'}, {patch: true}); + + Espo.Ui.success(this.translate('Saved')); + } + + // noinspection JSUnusedGlobalSymbols + async massActionSetHeld() { + const data = {}; + + data.ids = this.checkedList; + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetHeld`, data); + + Espo.Ui.success(this.translate('Saved')); + + await this.collection.fetch(); + + data.ids.forEach(id => { + if (this.collection.get(id)) { + this.checkRecord(id); } - }, + }); + } - actionSetHeld: function (data) { - let id = data.id; + // noinspection JSUnusedGlobalSymbols + async massActionSetNotHeld() { + const data = {}; - if (!id) { - return; + data.ids = this.checkedList; + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetNotHeld`, data); + + Espo.Ui.success(this.translate('Saved')); + + await this.collection.fetch(); + + data.ids.forEach(id => { + if (this.collection.get(id)) { + this.checkRecord(id); } - - var model = this.collection.get(id); - - if (!model) { - return; - } - - model.set('status', 'Held'); - - this.listenToOnce(model, 'sync', () => { - Espo.Ui.notify(false); - - this.collection.fetch(); - }); - - Espo.Ui.notifyWait(); - - model.save(); - }, - - actionSetNotHeld: function (data) { - let id = data.id; - - if (!id) { - return; - } - - let model = this.collection.get(id); - - if (!model) { - return; - } - - model.set('status', 'Not Held'); - - this.listenToOnce(model, 'sync', () => { - Espo.Ui.notify(false); - this.collection.fetch(); - }); - - Espo.Ui.notify(this.translate('saving', 'messages')); - - model.save(); - }, - - massActionSetHeld: function () { - Espo.Ui.notify(this.translate('saving', 'messages')); - - let data = {}; - - data.ids = this.checkedList; - - Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetHeld', data) - .then(() => { - Espo.Ui.notify(false); - - this.listenToOnce(this.collection, 'sync', () => { - data.ids.forEach(id => { - if (this.collection.get(id)) { - this.checkRecord(id); - } - }); - }); - - this.collection.fetch(); - }); - }, - - massActionSetNotHeld: function () { - Espo.Ui.notify(this.translate('saving', 'messages')); - - let data = {}; - - data.ids = this.checkedList; - - Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetNotHeld', data) - .then(() => { - Espo.Ui.notify(false); - - this.listenToOnce(this.collection, 'sync', () => { - data.ids.forEach(id => { - if (this.collection.get(id)) { - this.checkRecord(id); - } - }); - }); - - this.collection.fetch(); - }); - }, - }); -}); + }); + } +} 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'); + } + } + + /** + * @protected + * @param {Record} data + */ + async actionSetHeld(data) { + const id = data.id; + + if (!id) { + return; + } + + const model = this.collection.get(id); + + if (!model) { + return; + } + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await model.save({status: 'Held'}, {patch: true}); + + Espo.Ui.success(this.translate('Saved')); + } + + /** + * @protected + * @param {Record} data + */ + async actionSetNotHeld(data) { + const id = data.id; + + if (!id) { + return; + } + + const model = this.collection.get(id); + + if (!model) { + return; + } + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await model.save({status: 'Not Held'}, {patch: true}); + + Espo.Ui.success(this.translate('Saved')); + } + + // noinspection JSUnusedGlobalSymbols + async massActionSetHeld() { + const data = {}; + + data.ids = this.checkedList; + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetHeld`, data); + + Espo.Ui.success(this.translate('Saved')); + + await this.collection.fetch(); + + data.ids.forEach(id => { + if (this.collection.get(id)) { + this.checkRecord(id); } - }, + }); + } - actionSetHeld: function (data) { - const id = data.id; + // noinspection JSUnusedGlobalSymbols + async massActionSetNotHeld() { + const data = {}; - if (!id) { - return; + data.ids = this.checkedList; + + Espo.Ui.notify(this.translate('saving', 'messages')); + + await Espo.Ajax.postRequest(`${this.collection.entityType}/action/massSetNotHeld`, data); + + Espo.Ui.success(this.translate('Saved')); + + await this.collection.fetch(); + + data.ids.forEach(id => { + if (this.collection.get(id)) { + this.checkRecord(id); } - - const model = this.collection.get(id); - - if (!model) { - return; - } - - Espo.Ui.notify(this.translate('saving', 'messages')); - - model.save({status: 'Held'}, {patch: true}).then(() => { - Espo.Ui.success(this.translate('Saved')); - - this.collection.fetch(); - }); - }, - - actionSetNotHeld: function (data) { - const id = data.id; - - if (!id) { - return; - } - - const model = this.collection.get(id); - - if (!model) { - return; - } - - Espo.Ui.notify(this.translate('saving', 'messages')); - - model.save({status: 'Not Held'}, {patch: true}).then(() => { - Espo.Ui.success(this.translate('Saved')); - - this.collection.fetch(); - }); - }, - - massActionSetHeld: function () { - Espo.Ui.notify(this.translate('saving', 'messages')); - - const data = {ids: this.checkedList}; - - Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetHeld', data) - .then(() => { - Espo.Ui.notify(false); - - this.listenToOnce(this.collection, 'sync', () => { - data.ids.forEach(id => { - if (this.collection.get(id)) { - this.checkRecord(id); - } - }); - }); - - this.collection.fetch(); - }); - }, - - massActionSetNotHeld: function () { - Espo.Ui.notify(this.translate('saving', 'messages')); - - const data = {ids: this.checkedList}; - - Espo.Ajax.postRequest(this.collection.entityType + '/action/massSetNotHeld', data) - .then(() => { - Espo.Ui.notify(false); - - this.listenToOnce(this.collection, 'sync', () => { - data.ids.forEach(id => { - if (this.collection.get(id)) { - this.checkRecord(id); - } - }); - }); - - this.collection.fetch(); - }); - }, - - }); -}); + }); + } +}