meeting/call duplicate from modal view

This commit is contained in:
Yuri Kuznetsov
2022-02-04 14:49:49 +02:00
parent d6f0bc063e
commit 8d2238e04a
4 changed files with 41 additions and 5 deletions

View File

@@ -30,6 +30,8 @@ define('crm:views/meeting/modals/detail', 'views/modals/detail', function (Dep)
return Dep.extend({
duplicateAction: true,
setupAfterModelCreated: function () {
Dep.prototype.setupAfterModelCreated.call(this);

View File

@@ -44,6 +44,7 @@ define('views/edit', 'views/main', function (Dep) {
'attributes',
'rootUrl',
'duplicateSourceId',
'returnAfterCreate',
],
headerView: 'views/header',

View File

@@ -56,9 +56,9 @@ define('views/modals/detail', 'views/modal', function (Dep) {
flexibleHeaderFontSize: true,
setup: function () {
var self = this;
duplicateAction: false,
setup: function () {
this.scope = this.scope || this.options.scope;
this.id = this.options.id;
@@ -160,6 +160,13 @@ define('views/modals/detail', 'views/modal', function (Dep) {
this.listenToOnce(this.getRouter(), 'routed', function () {
this.remove();
}, this);
if (this.duplicateAction && this.getAcl().checkScope(this.scope, 'create')) {
this.addDropdownItem({
name: 'duplicate',
label: 'Duplicate',
});
}
},
setupAfterModelCreated: function () {
@@ -500,6 +507,31 @@ define('views/modals/detail', 'views/modal', function (Dep) {
this.trigger('leave');
this.dialog.close();
}
},
actionDuplicate: function () {
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
Espo.Ajax
.postRequest(this.scope + '/action/getDuplicateAttributes', {
id: this.model.id,
})
.then(attributes => {
Espo.Ui.notify(false);
let url = '#' + this.scope + '/create';
this.getRouter().dispatch(this.scope, 'create', {
attributes: attributes,
returnUrl: this.getRouter().getCurrentUrl(),
options: {
duplicateSourceId: this.model.id,
returnAfterCreate: true,
},
});
this.getRouter().navigate(url, {trigger: false});
});
},
});
});

View File

@@ -1051,6 +1051,8 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
this.dropdownItemList = Espo.Utils.cloneDeep(this.dropdownItemList);
this.dropdownEditItemList = Espo.Utils.cloneDeep(this.dropdownEditItemList);
this.returnAfterCreate = this.options.returnAfterCreate;
this.returnUrl = this.options.returnUrl || this.returnUrl;
this.returnDispatchParams = this.options.returnDispatchParams || this.returnDispatchParams;
@@ -2307,7 +2309,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
},
exitAfterCreate: function () {
if (this.model.id) {
if (!this.returnAfterCreate && this.model.id) {
var url = '#' + this.scope + '/view/' + this.model.id;
this.getRouter().navigate(url, {trigger: false});
@@ -2322,7 +2324,6 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
}
},
/**
* Called after save or cancel.
* By default redirects page. Can be orverridden in options.