ui dialog

This commit is contained in:
yuri
2017-02-07 16:30:55 +02:00
parent 471df0034e
commit 56f65e0fc0
23 changed files with 169 additions and 105 deletions
@@ -139,7 +139,7 @@ Espo.define('crm:views/calendar/modals/edit', 'views/modals/edit', function (Dep
actionRemove: function () {
var model = this.getView('edit').model;
if (confirm(this.translate('removeRecordConfirmation', 'messages'))) {
this.confirm(this.translate('removeRecordConfirmation', 'messages'), function () {
var $buttons = this.dialog.$el.find('.modal-footer button');
$buttons.addClass('disabled');
model.destroy({
@@ -151,7 +151,7 @@ Espo.define('crm:views/calendar/modals/edit', 'views/modals/edit', function (Dep
$buttons.removeClass('disabled');
}
});
}
}, this);
}
});
});
+2 -2
View File
@@ -46,7 +46,7 @@
},
actionSendInvitations: function () {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.disableMenuItem('sendInvitations');
this.notify('Sending...');
$.ajax({
@@ -67,7 +67,7 @@
this.enableMenuItem('sendInvitations');
}.bind(this),
});
}
}, this);
}
});
@@ -79,7 +79,7 @@ Espo.define('crm:views/meeting/detail', 'views/detail', function (Dep) {
},
actionSendInvitations: function () {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.disableMenuItem('sendInvitations');
this.notify('Sending...');
$.ajax({
@@ -101,7 +101,7 @@ Espo.define('crm:views/meeting/detail', 'views/detail', function (Dep) {
this.enableMenuItem('sendInvitations');
}.bind(this),
});
}
}, this);
}
});
@@ -140,7 +140,7 @@ Espo.define('crm:views/target-list/record/panels/opted-out', ['views/record/pane
},
actionCancelOptOut: function (data) {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
$.ajax({
url: 'TargetList/action/cancelOptOut',
type: 'POST',
@@ -152,7 +152,7 @@ Espo.define('crm:views/target-list/record/panels/opted-out', ['views/record/pane
}).done(function () {
this.collection.fetch();
}.bind(this));
}
}, this);
}
});
@@ -33,7 +33,7 @@ Espo.define('crm:views/target-list/record/panels/relationship', 'views/record/pa
fetchOnModelAfterRelate: true,
actionOptOut: function (data) {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
$.ajax({
url: 'TargetList/action/optOut',
type: 'POST',
@@ -47,7 +47,7 @@ Espo.define('crm:views/target-list/record/panels/relationship', 'views/record/pa
Espo.Ui.success(this.translate('Done'));
this.model.trigger('opt-out');
}.bind(this));
}
}, this);
}
});
@@ -30,11 +30,11 @@ Espo.define('Crm:Views.Target.Detail', 'Views.Detail', function (Dep) {
return Dep.extend({
actionConvertToLead: function () {
actionConvertToLead: function () {
var id = this.model.id;
var self = this;
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
self.notify('Please wait...');
$.ajax({
url: 'Target/action/convert',
@@ -45,7 +45,7 @@ Espo.define('Crm:Views.Target.Detail', 'Views.Detail', function (Dep) {
self.notify('Converted', 'success');
}
});
}
}, this);
},
});
+31
View File
@@ -265,6 +265,37 @@ Espo.define('ui', [], function () {
Dialog: Dialog,
confirm: function (message, okText, cancelText, callback, context) {
var dialog = new Dialog({
backdrop: false,
header: false,
className: 'dialog-confirm',
body: '<span class="confirm-message">' + message + '</a>',
buttons: [
{
text: ' ' + okText + ' ',
name: 'confirm',
onClick: function () {
callback.call(context || this);
dialog.close();
},
style: 'danger',
pullLeft: true
},
{
text: cancelText,
name: 'cancel',
onClick: function () {
dialog.close();
},
pullRight: true
}
]
});
dialog.show();
},
dialog: function (options) {
return new Dialog(options);
},
+12
View File
@@ -223,6 +223,18 @@ Espo.define('view', [], function () {
ajaxGetRequest: function (url, data, options) {
return this.ajaxRequest(url, 'GET', data, options);
},
confirm: function (o, callback, context) {
if (typeof o === 'string' || o instanceof String) {
var message = o;
var confirmText = this.translate('Yes');
} else {
o = o || {};
var message = o.message;
var confirmText = o.confirmText;
}
Espo.Ui.confirm(message, confirmText, this.translate('Cancel'), callback, context);
}
});
@@ -57,9 +57,9 @@ Espo.define('views/admin/entity-manager/index', 'view', function (Dep) {
},
'click [data-action="removeEntity"]': function (e) {
var scope = $(e.currentTarget).data('scope');
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.removeEntity(scope);
}
}, this);
}
},
+2 -2
View File
@@ -61,7 +61,7 @@ Espo.define('views/admin/extensions/index', 'view', function (Dep) {
var name = this.collection.get(id).get('name');
var self = this;
if (confirm(this.translate('uninstallConfirmation', 'messages', 'Admin'))) {
this.confirm(this.translate('uninstallConfirmation', 'messages', 'Admin'), function () {
Espo.Ui.notify(this.translate('Uninstalling...', 'labels', 'Admin'));
$.ajax({
@@ -79,7 +79,7 @@ Espo.define('views/admin/extensions/index', 'view', function (Dep) {
window.location.reload();
}.bind(this));
}
}, this);
}
},
+2 -2
View File
@@ -44,7 +44,7 @@ Espo.define('views/admin/field-manager/list', 'view', function (Dep) {
'click [data-action="removeField"]': function (e) {
var field = $(e.currentTarget).data('name');
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.notify('Removing...');
$.ajax({
url: 'Admin/fieldManager/' + this.scope + '/' + field,
@@ -57,7 +57,7 @@ Espo.define('views/admin/field-manager/list', 'view', function (Dep) {
$(e.currentTarget).closest('tr').remove();
}.bind(this),
});
}
}, this);
}
},
+2 -2
View File
@@ -44,9 +44,9 @@ Espo.define('views/admin/layouts/base', 'view', function (Dep) {
this.cancel();
},
'click button[data-action="resetToDefault"]': function () {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.resetToDefault();
}
}, this)
},
},
+2 -2
View File
@@ -53,9 +53,9 @@ Espo.define('views/admin/link-manager/index', 'view', function (Dep) {
},
'click [data-action="removeLink"]': function (e) {
var link = $(e.currentTarget).data('link');
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.removeLink(link);
}
}, this);
}
},
+4 -5
View File
@@ -91,7 +91,7 @@ Espo.define('views/import/detail', 'views/detail', function (Dep) {
},
actionRevert: function () {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
$btn = this.$el.find('button[data-action="revert"]');
$btn.addClass('disabled');
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
@@ -107,12 +107,11 @@ Espo.define('views/import/detail', 'views/detail', function (Dep) {
this.getRouter().navigate('#Import/list', {trigger: true});
}.bind(this));
}
}, this);
},
actionRemoveDuplicates: function () {
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
$btn = this.$el.find('button[data-action="removeDuplicates"]');
$btn.addClass('disabled');
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
@@ -128,7 +127,7 @@ Espo.define('views/import/detail', 'views/detail', function (Dep) {
this.model.fetch();
Espo.Ui.success(this.translate('duplicatesRemoved', 'messages', 'Import'))
}.bind(this));
}
}, this);
}
});
@@ -36,7 +36,7 @@ Espo.define('views/import/record/panels/duplicates', 'views/import/record/panels
var id = data.id;
var type = data.type;
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.ajaxPostRequest('Import/action/unmarkAsDuplicate', {
id: this.model.id,
entityId: id,
@@ -44,7 +44,7 @@ Espo.define('views/import/record/panels/duplicates', 'views/import/record/panels
}).then(function () {
this.collection.fetch();
});
}
}, this);
}
});
+2 -2
View File
@@ -387,7 +387,7 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
actionRemove: function () {
var model = this.getView('record').model;
if (confirm(this.translate('removeRecordConfirmation', 'messages'))) {
this.confirm(this.translate('removeRecordConfirmation', 'messages'), function () {
var $buttons = this.dialog.$el.find('.modal-footer button');
$buttons.addClass('disabled').attr('disabled', 'disabled');
model.destroy({
@@ -399,7 +399,7 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
$buttons.removeClass('disabled').removeAttr('disabled');
}
});
}
}, this);
},
actionFullForm: function () {
+2 -2
View File
@@ -143,7 +143,7 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep)
},
actionReset: function () {
if (confirm(this.translate('resetPreferencesConfirmation', 'messages'))) {
this.confirm(this.translate('resetPreferencesConfirmation', 'messages'), function () {
$.ajax({
url: 'Preferences/' + this.model.id,
type: 'DELETE',
@@ -153,7 +153,7 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep)
this.getPreferences().set(this.model.toJSON());
this.getPreferences().trigger('update');
}.bind(this));
}
}, this);
},
afterRender: function () {
+2 -2
View File
@@ -393,7 +393,7 @@ Espo.define('views/record/detail', ['views/record/base', 'view-record-helper'],
},
delete: function () {
if (confirm(this.translate('removeRecordConfirmation', 'messages'))) {
this.confirm(this.translate('removeRecordConfirmation', 'messages'), function () {
this.trigger('before:delete');
this.trigger('delete');
@@ -419,7 +419,7 @@ Espo.define('views/record/detail', ['views/record/base', 'view-record-helper'],
this.exit('delete');
}.bind(this),
});
}
}, this);
},
getFieldViews: function (withHidden) {
+59 -56
View File
@@ -343,56 +343,59 @@ Espo.define('views/record/list', 'view', function (Dep) {
massAction: function (name) {
var bypassConfirmation = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'bypassConfirmation']);
var confirmationMsg = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'confirmationMessage']) || 'confirmation';
if (!bypassConfirmation && !confirm(this.translate(confirmationMsg, 'messages', this.scope))) {
return;
}
var proceed = function () {
var acl = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'acl']);
var aclScope = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'aclScope']);
var acl = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'acl']);
var aclScope = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'aclScope']);
if (acl || aclScope) {
if (!this.getAcl().check(aclScope || this.scope, acl)) {
this.notify('Access denied', 'error');
return;
}
}
var idList = [];
var data = {};
if (this.allResultIsChecked) {
data.where = this.collection.getWhere();
data.selectData = this.collection.data || {};
data.byWhere = true;
} else {
data.idList = idList;
}
for (var i in this.checkedList) {
idList.push(this.checkedList[i]);
}
data.entityType = this.entityType;
var waitMessage = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'waitMessage']) || 'pleaseWait';
Espo.Ui.notify(this.translate(waitMessage, 'messages', this.scope));
var url = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'url']);
this.ajaxPostRequest(url, data).then(function (result) {
var successMessage = result.successMessage || this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'successMessage']) || 'done';
this.collection.fetch().then(function () {
var message = this.translate(successMessage, 'messages', this.scope);
if ('count' in result) {
message = message.replace('{count}', result.count);
if (acl || aclScope) {
if (!this.getAcl().check(aclScope || this.scope, acl)) {
this.notify('Access denied', 'error');
return;
}
Espo.Ui.success(message);
}
var idList = [];
var data = {};
if (this.allResultIsChecked) {
data.where = this.collection.getWhere();
data.selectData = this.collection.data || {};
data.byWhere = true;
} else {
data.idList = idList;
}
for (var i in this.checkedList) {
idList.push(this.checkedList[i]);
}
data.entityType = this.entityType;
var waitMessage = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'waitMessage']) || 'pleaseWait';
Espo.Ui.notify(this.translate(waitMessage, 'messages', this.scope));
var url = this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'url']);
this.ajaxPostRequest(url, data).then(function (result) {
var successMessage = result.successMessage || this.getMetadata().get(['clientDefs', this.scope, 'massActionDefs', name, 'successMessage']) || 'done';
this.collection.fetch().then(function () {
var message = this.translate(successMessage, 'messages', this.scope);
if ('count' in result) {
message = message.replace('{count}', result.count);
}
Espo.Ui.success(message);
}.bind(this));
}.bind(this));
}.bind(this));
}
if (!bypassConfirmation) {
this.confirm(this.translate(confirmationMsg, 'messages', this.scope), proceed, this);
} else {
proceed.call(this);
}
},
massActionRemove: function () {
@@ -406,7 +409,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
var self = this;
if (confirm(this.translate('removeSelectedRecordsConfirmation', 'messages'))) {
this.confirm(this.translate('removeSelectedRecordsConfirmation', 'messages'), function () {
this.notify('Removing...');
var ids = [];
@@ -466,7 +469,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
}
}
}.bind(this));
}
}, this);
},
massActionFollow: function () {
@@ -478,7 +481,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
}
var confirmMsg = this.translate('confirmMassFollow', 'messages').replace('{count}', count.toString());
if (confirm(confirmMsg)) {
this.confirm(confirmMsg, function () {
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
this.ajaxPostRequest(this.entityType + '/action/massFollow', {
ids: idList
@@ -494,7 +497,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
Espo.Ui.warning(this.translate('massFollowZeroResult', 'messages'));
}
}.bind(this));
}
}, this);
},
massActionUnfollow: function () {
@@ -506,7 +509,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
}
var confirmMsg = this.translate('confirmMassUnfollow', 'messages').replace('{count}', count.toString());
if (confirm(confirmMsg)) {
this.confirm(confirmMsg, function () {
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
this.ajaxPostRequest(this.entityType + '/action/massUnfollow', {
ids: idList
@@ -522,7 +525,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
Espo.Ui.warning(this.translate('massUnfollowZeroResult', 'messages'));
}
}.bind(this));
}
}, this);
},
massActionMerge: function () {
@@ -1229,8 +1232,8 @@ Espo.define('views/record/list', 'view', function (Dep) {
this.notify('Access denied', 'error');
return false;
}
var self = this;
if (confirm(this.translate('removeRecordConfirmation', 'messages'))) {
this.confirm(this.translate('removeRecordConfirmation', 'messages'), function () {
this.collection.trigger('model-removing', id);
this.collection.remove(model);
this.notify('Removing...');
@@ -1240,10 +1243,10 @@ Espo.define('views/record/list', 'view', function (Dep) {
this.removeRecordFromList(id);
}.bind(this),
error: function () {
self.notify('Error occured', 'error');
}
this.notify('Error occured', 'error');
}.bind(this)
});
}
}, this);
},
removeRecordFromList: function (id) {
@@ -287,7 +287,7 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
var id = data.id;
var self = this;
if (confirm(this.translate('unlinkRecordConfirmation', 'messages'))) {
this.confirm(this.translate('unlinkRecordConfirmation', 'messages'), function () {
var model = this.collection.get(id);
self.notify('Unlinking...');
$.ajax({
@@ -305,14 +305,14 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
self.notify('Error occurred', 'error');
},
});
}
}, this);
},
actionRemoveRelated: function (data) {
var id = data.id;
var self = this;
if (confirm(this.translate('removeRecordConfirmation', 'messages'))) {
this.confirm(this.translate('removeRecordConfirmation', 'messages'), function () {
var model = this.collection.get(id);
self.notify('Removing...');
model.destroy({
@@ -321,11 +321,11 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
self.collection.fetch();
},
});
}
}, this);
},
actionUnlinkAllRelated: function (data) {
if (confirm(this.translate('unlinkAllConfirmation', 'messages'))) {
this.confirm(this.translate('unlinkAllConfirmation', 'messages'), function () {
this.notify('Please wait...');
$.ajax({
url: this.model.name + '/action/unlinkAll',
@@ -339,7 +339,7 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
this.notify('Unlinked', 'success');
this.collection.fetch();
}.bind(this));
}
}, this);
},
});
});
+2 -2
View File
@@ -232,9 +232,9 @@ Espo.define('views/record/search', 'view', function (Dep) {
},
'click .dropdown-menu a[data-action="removePreset"]': function (e) {
var id = this.presetName;
if (confirm(this.translate('confirmation', 'messages'))) {
this.confirm(this.translate('confirmation', 'messages'), function () {
this.removePreset(id);
}
}, this);
},
'change .search-row ul.filter-menu input[data-role="boolFilterCheckbox"]': function (e) {
e.stopPropagation();
+9 -2
View File
@@ -395,13 +395,20 @@ ul.dropdown-menu > li.checkbox:last-child {
@media screen and (min-width: @screen-sm-min) {
.modal-dialog {
width: 740px !important;
width: 740px;
}
}
@media screen and (min-width: @screen-md-min) {
.modal-dialog {
width: 900px !important;
width: 900px;
}
.dialog-confirm > .modal-dialog {
width: 550px;
}
}
.dialog-confirm > .modal-dialog > .modal-content {
text-align: center;
}
table.table > tbody td > .list-row-buttons button {
+14 -2
View File
@@ -153,11 +153,19 @@ table.table {
}
.modal-footer > .main-btn-group {
float: left !important;
float: left;
}
.modal-footer > .additional-btn-group {
float: right !important;
float: right;
}
.dialog-confirm .modal-footer > .main-btn-group {
float: right;
}
.dialog-confirm .modal-footer > .additional-btn-group {
float: left;
}
.modal-footer {
@@ -172,6 +180,10 @@ table.table {
.modal-content .note-editor > .modal > .modal-dialog {
margin: 0 0 0 -@container-padding;
}
.dialog-confirm > .modal-dialog {
margin: 0 auto;
}
}
@media (max-width: @screen-sm-min) {