mirror of
https://github.com/espocrm/espocrm.git
synced 2026-07-01 00:16:07 +00:00
meeting/call duplicate from modal view
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ define('views/edit', 'views/main', function (Dep) {
|
||||
'attributes',
|
||||
'rootUrl',
|
||||
'duplicateSourceId',
|
||||
'returnAfterCreate',
|
||||
],
|
||||
|
||||
headerView: 'views/header',
|
||||
|
||||
@@ -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});
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user