This commit is contained in:
Yuri Kuznetsov
2022-06-18 13:54:40 +03:00
parent 5c1fe910b6
commit d2a400d08a
43 changed files with 445 additions and 168 deletions
+2 -5
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl-portal/email', 'acl-portal', function (Dep) {
define('acl-portal/email', ['acl-portal'], function (Dep) {
return Dep.extend({
@@ -57,9 +57,6 @@ Espo.define('acl-portal/email', 'acl-portal', function (Dep) {
}
return result;
}
},
});
});
+2 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl-portal/notification', 'acl-portal', function (Dep) {
define('acl-portal/notification', ['acl-portal'], function (Dep) {
return Dep.extend({
@@ -35,7 +35,6 @@ Espo.define('acl-portal/notification', 'acl-portal', function (Dep) {
return true;
}
return false;
}
},
});
});
+2 -5
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl-portal/preferences', 'acl-portal', function (Dep) {
define('acl-portal/preferences', ['acl-portal'], function (Dep) {
return Dep.extend({
@@ -36,9 +36,6 @@ Espo.define('acl-portal/preferences', 'acl-portal', function (Dep) {
}
return false;
}
},
});
});
+6 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl/email', 'acl', function (Dep) {
define('acl/email', ['acl'], function (Dep) {
return Dep.extend({
@@ -60,7 +60,10 @@ Espo.define('acl/email', 'acl', function (Dep) {
},
checkIsOwner: function (model) {
if (this.getUser().id === model.get('assignedUserId') || this.getUser().id === model.get('createdById')) {
if (
this.getUser().id === model.get('assignedUserId') ||
this.getUser().id === model.get('createdById')
) {
return true;
}
@@ -109,6 +112,6 @@ Espo.define('acl/email', 'acl', function (Dep) {
}
return result;
}
},
});
});
+2 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl/import', 'acl', function (Dep) {
define('acl/import', ['acl'], function (Dep) {
return Dep.extend({
@@ -48,7 +48,6 @@ Espo.define('acl/import', 'acl', function (Dep) {
checkModelDelete: function (model, data, precise) {
return true;
}
},
});
});
+2 -1
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl/notification', 'acl', function (Dep) {
define('acl/notification', ['acl'], function (Dep) {
return Dep.extend({
@@ -34,6 +34,7 @@ Espo.define('acl/notification', 'acl', function (Dep) {
if (this.getUser().id === model.get('userId')) {
return true;
}
return false;
}
});
+3 -5
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('acl/preferences', 'acl', function (Dep) {
define('acl/preferences', ['acl'], function (Dep) {
return Dep.extend({
@@ -34,10 +34,8 @@ Espo.define('acl/preferences', 'acl', function (Dep) {
if (this.getUser().id === model.id) {
return true;
}
return false;
}
},
});
});
+1 -2
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('acl/team', 'acl', function (Dep) {
define('acl/team', ['acl'], function (Dep) {
return Dep.extend({
@@ -35,6 +35,5 @@ define('acl/team', 'acl', function (Dep) {
return (userTeamIdList.indexOf(model.id) != -1);
},
});
});
+1 -2
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('acl/user', 'acl', function (Dep) {
define('acl/user', ['acl'], function (Dep) {
return Dep.extend({
@@ -43,6 +43,5 @@ define('acl/user', 'acl', function (Dep) {
checkIsOwner: function (model) {
return this.getUser().id === model.id;
},
});
});
+1 -1
View File
@@ -703,7 +703,7 @@ function (
* Create an acl-manager.
*
* @protected
* @return {module:acl-manager}
* @return {module:acl-manager.Class}
*/
createAclManager: function () {
return new AclManager(this.user, null, this.settings.get('aclAllowDeleteCreated'));
+17 -3
View File
@@ -26,10 +26,19 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('collections/note', 'collection', function (Dep) {
define('collections/note', ['collection'], function (Dep) {
return Dep.extend({
/**
* @class
* @name Class
* @extends module:collection.Class
* @memberOf module:collections/note
*/
return Dep.extend(/** @lends module:collections/note.Class# */{
/**
* @inheritDoc
*/
parse: function (response, params) {
var total = this.total;
@@ -46,6 +55,12 @@ define('collections/note', 'collection', function (Dep) {
return list;
},
/**
* Fetch new records.
*
* @param {Object} options Options.
* @returns {Promise}
*/
fetchNew: function (options) {
options = options || {};
@@ -64,6 +79,5 @@ define('collections/note', 'collection', function (Dep) {
return this.fetch(options);
},
});
});
+2 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/about', 'controller', function (Dep) {
define('controllers/about', ['controller'], function (Dep) {
return Dep.extend({
@@ -36,7 +36,6 @@ define('controllers/about', 'controller', function (Dep) {
this.main('About', {}, function (view) {
view.render();
});
}
},
});
});
+4 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/address-map', 'controller', function (Dep) {
define('controllers/address-map', ['controller'], function (Dep) {
return Dep.extend({
@@ -43,7 +43,9 @@ define('controllers/address-map', 'controller', function (Dep) {
model.id = o.id;
model.fetch().then(
function () {
var viewName = this.getMetadata().get(['AddressMap', 'view']) || 'views/address-map/view';
var viewName = this.getMetadata().get(['AddressMap', 'view']) ||
'views/address-map/view';
this.main(viewName, {
model: model,
field: o.field,
@@ -53,6 +55,5 @@ define('controllers/address-map', 'controller', function (Dep) {
}.bind(this)
);
},
});
});
+18 -2
View File
@@ -26,10 +26,20 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/admin', ['controller', 'search-manager', 'lib!underscore'], function (Dep, SearchManager, _) {
define('controllers/admin', ['controller', 'search-manager', 'lib!underscore'],
function (Dep, /** typeof module:search-manager.Class */SearchManager, _) {
return Dep.extend({
/**
* @class
* @name Class
* @memberOf module:controllers/admin
* @extends module:controller.Class
*/
return Dep.extend(/** @lends module:controllers/admin.Class# */{
/**
* @inheritDoc
*/
checkAccessGlobal: function () {
if (this.getUser().isAdmin()) {
return true;
@@ -271,6 +281,9 @@ define('controllers/admin', ['controller', 'search-manager', 'lib!underscore'],
this.main('views/admin/system-requirements/index');
},
/**
* @returns {module:models/settings.Class}
*/
getSettingsModel: function () {
let model = this.getConfig().clone();
model.defs = this.getConfig().defs;
@@ -408,6 +421,9 @@ define('controllers/admin', ['controller', 'search-manager', 'lib!underscore'],
});
},
/**
* @returns {Object|null}
*/
getPageDefs: function (page) {
let panelsDefs = this.getMetadata().get(['app', 'adminPanel']) || {};
+9 -5
View File
@@ -26,15 +26,20 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/api-user', 'controllers/record', function (Dep) {
define('controllers/api-user', ['controllers/record'], function (Dep) {
return Dep.extend({
/**
* @class
* @name Class
* @extends module:controllers/record.Class
* @memberOf module:controllers/api-user
*/
return Dep.extend(/** @lends module:controllers/api-user.Class# */{
entityType: 'User',
getCollection: function (callback, context, usePreviouslyFetched) {
context = context || this;
Dep.prototype.getCollection.call(this, function (collection) {
return Dep.prototype.getCollection.call(this, (collection) => {
collection.data.userType = 'api';
callback.call(context, collection);
@@ -59,6 +64,5 @@ define('controllers/api-user', 'controllers/record', function (Dep) {
options.attributes.type = 'api';
Dep.prototype.actionCreate.call(this, options);
},
});
});
+3 -5
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/dashboard', 'controller', function (Dep) {
define('controllers/dashboard', ['controller'], function (Dep) {
return Dep.extend({
@@ -35,11 +35,9 @@ define('controllers/dashboard', 'controller', function (Dep) {
actionIndex: function () {
this.main('views/dashboard', {
displayTitle: true,
}, function (view) {
}, (view) => {
view.render();
});
}
},
});
});
+1 -1
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/email-account', 'controllers/record', function (Dep) {
define('controllers/email-account', ['controllers/record'], function (Dep) {
return Dep.extend({
+8 -7
View File
@@ -26,20 +26,21 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/email', 'controllers/record', function (Dep) {
define('controllers/email', ['controllers/record'], function (Dep) {
return Dep.extend({
prepareModelView: function (model, options) {
Dep.prototype.prepareModelView(model, options);
this.listenToOnce(model, 'after:send', function () {
var key = this.name + 'List';
var stored = this.getStoredMainView(key);
this.listenToOnce(model, 'after:send', () => {
let key = this.name + 'List';
let stored = this.getStoredMainView(key);
if (stored) {
this.clearStoredMainView(key);
}
}, this);
}
});
},
});
});
+13 -11
View File
@@ -26,35 +26,37 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/external-account', 'controller', function (Dep) {
define('controllers/external-account', ['controller'], function (Dep) {
return Dep.extend({
defaultAction: 'list',
actionList: function (options) {
this.collectionFactory.create('ExternalAccount', function (collection) {
collection.once('sync', function () {
this.collectionFactory.create('ExternalAccount', (collection) => {
collection.once('sync', () => {
this.main('ExternalAccount.Index', {
collection: collection,
});
}, this);
});
collection.fetch();
}, this);
});
},
actionEdit: function (options) {
var id = options.id;
let id = options.id;
this.collectionFactory.create('ExternalAccount', function (collection) {
collection.once('sync', function () {
this.collectionFactory.create('ExternalAccount', (collection) => {
collection.once('sync', () => {
this.main('ExternalAccount.Index', {
collection: collection,
id: id
id: id,
});
}, this);
});
collection.fetch();
}, this);
});
},
});
});
+1 -1
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/home', 'controller', function (Dep) {
define('controllers/home', ['controller'], function (Dep) {
return Dep.extend({
+1 -1
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/import', 'controllers/record', function (Dep) {
define('controllers/import', ['controllers/record'], function (Dep) {
return Dep.extend({
+2 -1
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/inbound-email', 'controllers/record', function (Dep) {
define('controllers/inbound-email', ['controllers/record'], function (Dep) {
return Dep.extend({
@@ -34,6 +34,7 @@ define('controllers/inbound-email', 'controllers/record', function (Dep) {
if (this.getUser().isAdmin()) {
return true;
}
return false;
},
+1 -1
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/last-viewed', 'controllers/record', function (Dep) {
define('controllers/last-viewed', ['controllers/record'], function (Dep) {
return Dep.extend({
+5 -2
View File
@@ -26,13 +26,16 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/layout-set', 'controllers/record', function (Dep) {
define('controllers/layout-set', ['controllers/record'], function (Dep) {
return Dep.extend({
actionEditLayouts: function (options) {
var id = options.id;
if (!id) throw new Error("ID not passed.");
if (!id) {
throw new Error("ID not passed.");
}
this.main('views/layout-set/layouts', {
layoutSetId: id,
@@ -26,31 +26,32 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/lead-capture-opt-in-confirmation', 'controller', function (Dep) {
define('controllers/lead-capture-opt-in-confirmation', ['controller'], function (Dep) {
return Dep.extend({
actionOptInConfirmationSuccess: function (data) {
var viewName = this.getMetadata().get(['clientDefs', 'LeadCapture', 'optInConfirmationSuccessView']) ||
var viewName = this.getMetadata()
.get(['clientDefs', 'LeadCapture', 'optInConfirmationSuccessView']) ||
'views/lead-capture/opt-in-confirmation-success';
this.entire(viewName, {
resultData: data
}, function (view) {
resultData: data,
}, (view) => {
view.render();
});
},
actionOptInConfirmationExpired: function (data) {
var viewName = this.getMetadata().get(['clientDefs', 'LeadCapture', 'optInConfirmationExpiredView']) ||
var viewName = this.getMetadata()
.get(['clientDefs', 'LeadCapture', 'optInConfirmationExpiredView']) ||
'views/lead-capture/opt-in-confirmation-expired';
this.entire(viewName, {
resultData: data
}, function (view) {
}, (view) => {
view.render();
});
}
},
});
});
+3 -5
View File
@@ -26,18 +26,16 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/notification', 'controller', function (Dep) {
define('controllers/notification', ['controller'], function (Dep) {
return Dep.extend({
defaultAction: 'index',
actionIndex: function () {
this.main('views/notification/list', {
}, function (view) {
this.main('views/notification/list', {}, (view) => {
view.render();
});
}
},
});
});
+3 -2
View File
@@ -26,13 +26,14 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/page', 'controller', function (Dep) {
define('controllers/page', ['controller'], function (Dep) {
return Dep.extend({
actionView: function (options) {
var page = options.id;
this.main(null, {template: 'pages.' + Espo.Utils.convert(page, 'c-h')});
}
},
});
});
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/password-change-request', 'controller', function (Dep) {
define('controllers/password-change-request', ['controller'], function (Dep) {
return Dep.extend({
+3 -4
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/portal-role', 'controllers/record', function (Dep) {
define('controllers/portal-role', ['controllers/record'], function (Dep) {
return Dep.extend({
@@ -34,9 +34,8 @@ define('controllers/portal-role', 'controllers/record', function (Dep) {
if (this.getUser().isAdmin()) {
return true;
}
return false;
}
},
});
});
+14 -6
View File
@@ -26,15 +26,20 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/portal-user', 'controllers/record', function (Dep) {
define('controllers/portal-user', ['controllers/record'], function (Dep) {
return Dep.extend({
/**
* @class
* @name Class
* @extends module:controllers/record.Class
* @memberOf module:controllers/portal-user
*/
return Dep.extend(/** @lends module:controllers/portal-user.Class# */{
entityType: 'User',
getCollection: function (callback, context, usePreviouslyFetched) {
context = context || this;
Dep.prototype.getCollection.call(this, function (collection) {
return Dep.prototype.getCollection.call(this, (collection) => {
collection.data.userType = 'portal';
callback.call(context, collection);
@@ -45,11 +50,15 @@ define('controllers/portal-user', 'controllers/record', function (Dep) {
if (!model.isPortal()) {
if (model.isApi()) {
this.getRouter().dispatch('ApiUser', 'view', {id: model.id, model: model});
return;
}
this.getRouter().dispatch('User', 'view', {id: model.id, model: model});
return;
}
Dep.prototype.createViewView.call(this, options, model, view);
},
@@ -57,16 +66,15 @@ define('controllers/portal-user', 'controllers/record', function (Dep) {
options = options || {};
options.attributes = options.attributes || {};
options.attributes.type = 'portal';
Dep.prototype.actionCreate.call(this, options);
},
checkAccess: function (action) {
if (this.getAcl().get('portalPermission') === 'yes')
return true;
return false;
},
});
});
+3 -1
View File
@@ -34,8 +34,10 @@ define('controllers/preferences', ['controllers/record', 'models/preferences'],
getModel: function (callback) {
var model = new Preferences();
model.settings = this.getConfig();
model.defs = this.getMetadata().get('entityDefs.Preferences');
if (callback) {
callback.call(this, model);
}
@@ -54,6 +56,6 @@ define('controllers/preferences', ['controllers/record', 'models/preferences'],
});
},
actionList: function () {}
actionList: function () {},
});
});
+4 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/record-tree', 'controllers/record', function (Dep) {
define('controllers/record-tree', ['controllers/record'], function (Dep) {
return Dep.extend({
@@ -34,7 +34,9 @@ define('controllers/record-tree', 'controllers/record', function (Dep) {
beforeView: function (options) {
Dep.prototype.beforeView.call(this, options);
options = options || {};
if (options.model) {
options.model.unset('childCollection');
options.model.unset('childList');
@@ -53,7 +55,6 @@ define('controllers/record-tree', 'controllers/record', function (Dep) {
collection: collection
});
});
}
},
});
});
+82 -20
View File
@@ -26,14 +26,33 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/record', 'controller', function (Dep) {
define('controllers/record', ['controller'], function (Dep) {
return Dep.extend({
/**
* A record controller.
*
* @class
* @name Class
* @extends module:controller.Class
* @memberOf module:controllers/record
*/
return Dep.extend(/** @lends module:controllers/record.Class# */{
/**
* A type => view-name map.
* @protected
* @type {Object.<string,string>}
*/
viewMap: null,
/**
* @inheritDoc
*/
defaultAction: 'list',
/**
* @inheritDoc
*/
checkAccess: function (action) {
if (this.getAcl().check(this.name, action)) {
return true;
@@ -42,12 +61,32 @@ define('controllers/record', 'controller', function (Dep) {
return false;
},
/**
* @inheritDoc
*/
initialize: function () {
/**
* A type => view-name map.
* @protected
* @type {Object.<string,string>}
*/
this.viewMap = this.viewMap || {};
this.viewsMap = this.viewsMap || {};
/**
* @private
* @type {Object}
*/
this.collectionMap = {};
},
/**
* Get a view name/path.
*
* @protected
* @param {'list'|'detail'|'edit'|'create'} type A type.
* @returns {string}
*/
getViewName: function (type) {
return this.viewMap[type] ||
this.getMetadata().get(['clientDefs', this.name, 'views', type]) ||
@@ -93,7 +132,7 @@ define('controllers/record', 'controller', function (Dep) {
},
createViewView: function (options, model, view) {
var view = view || this.getViewName('detail');
view = view || this.getViewName('detail');
this.main(view, {
scope: this.name,
@@ -104,6 +143,11 @@ define('controllers/record', 'controller', function (Dep) {
});
},
/**
* @protected
* @param {module:model.Class} model
* @param {Object} options
*/
prepareModelView: function (model, options) {},
actionView: function (options) {
@@ -182,8 +226,13 @@ define('controllers/record', 'controller', function (Dep) {
this.handleCheckAccess('create');
},
/**
* @protected
* @param {module:model.Class} model
* @param {Object} options
*/
prepareModelCreate: function (model, options) {
this.listenToOnce(model, 'before:save', function () {
this.listenToOnce(model, 'before:save', () => {
var key = this.name + 'List';
var stored = this.getStoredMainView(key);
@@ -191,7 +240,7 @@ define('controllers/record', 'controller', function (Dep) {
if (stored && !stored.storeViewAfterCreate) {
this.clearStoredMainView(key);
}
}, this);
});
this.listenToOnce(model, 'after:save', () => {
var key = this.name + 'List';
@@ -246,6 +295,11 @@ define('controllers/record', 'controller', function (Dep) {
this.handleCheckAccess('edit');
},
/**
* @protected
* @param {module:model.Class} model
* @param {Object} options
*/
prepareModelEdit: function (model, options) {
this.listenToOnce(model, 'before:save', () => {
var key = this.name + 'List';
@@ -344,8 +398,13 @@ define('controllers/record', 'controller', function (Dep) {
},
/**
* Get collection for the current controller.
* @param {collection}.
* Get a collection for the current controller.
*
* @protected
* @param {Function|null} [callback]
* @param {Object|null} [context]
* @param {boolean} [usePreviouslyFetched=false] Use a previously fetched.
* @return {Promise<module:collection.Class>}
*/
getCollection: function (callback, context, usePreviouslyFetched) {
context = context || this;
@@ -354,34 +413,38 @@ define('controllers/record', 'controller', function (Dep) {
throw new Error('No collection for unnamed controller');
}
var collectionName = this.entityType || this.name;
let collectionName = this.entityType || this.name;
if (usePreviouslyFetched) {
if (collectionName in this.collectionMap) {
var collection = this.collectionMap[collectionName];
let collection = this.collectionMap[collectionName];
callback.call(context, collection);
return;
return Promise.resolve(collection);
}
}
return this.collectionFactory.create(collectionName, function (collection) {
return this.collectionFactory.create(collectionName, (collection) => {
this.collectionMap[collectionName] = collection;
this.listenTo(collection, 'sync', function () {
this.listenTo(collection, 'sync', () => {
collection.isFetched = true;
}, this);
});
if (callback) {
callback.call(context, collection);
}
}, context);
});
},
/**
* Get model for the current controller.
* @param {model}.
* Get a model for the current controller.
*
* @protected
* @param {Function} [callback]
* @param {Object} [context]
* @return {Promise<module:model.Class>}
*/
getModel: function (callback, context) {
context = context || this;
@@ -390,14 +453,13 @@ define('controllers/record', 'controller', function (Dep) {
throw new Error('No collection for unnamed controller');
}
var modelName = this.entityType || this.name;
let modelName = this.entityType || this.name;
return this.modelFactory.create(modelName, function (model) {
return this.modelFactory.create(modelName, (model) => {
if (callback) {
callback.call(context, model);
}
}, context);
});
},
});
});
+3 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/role', 'controllers/record', function (Dep) {
define('controllers/role', ['controllers/record'], function (Dep) {
return Dep.extend({
@@ -34,8 +34,8 @@ define('controllers/role', 'controllers/record', function (Dep) {
if (this.getUser().isAdmin()) {
return true;
}
return false;
}
return false;
},
});
});
+1 -2
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/stream', 'controller', function (Dep) {
define('controllers/stream', ['controller'], function (Dep) {
return Dep.extend({
@@ -57,6 +57,5 @@ define('controllers/stream', 'controller', function (Dep) {
view.render();
});
},
});
});
+3 -3
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/team', 'controllers/record', function (Dep) {
define('controllers/team', ['controllers/record'], function (Dep) {
return Dep.extend({
@@ -34,10 +34,10 @@ define('controllers/team', 'controllers/record', function (Dep) {
if (action == 'read') {
return true;
}
if (this.getUser().isAdmin()) {
return true;
}
}
},
});
});
+15 -5
View File
@@ -26,13 +26,18 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/user', 'controllers/record', function (Dep) {
define('controllers/user', ['controllers/record'], function (Dep) {
return Dep.extend({
/**
* @class
* @name Class
* @extends module:controllers/record.Class
* @memberOf module:controllers/user
*/
return Dep.extend(/** @lends module:controllers/user.Class */{
getCollection: function (callback, context, usePreviouslyFetched) {
context = context || this;
Dep.prototype.getCollection.call(this, function (collection) {
return Dep.prototype.getCollection.call(this, (collection) => {
collection.data.userType = 'internal';
callback.call(context, collection);
@@ -43,18 +48,23 @@ define('controllers/user', 'controllers/record', function (Dep) {
if (model.get('deleted')) {
view = 'views/deleted-detail';
Dep.prototype.createViewView.call(this, options, model, view);
return;
}
if (model.isPortal()) {
this.getRouter().dispatch('PortalUser', 'view', {id: model.id, model: model});
return;
}
if (model.isApi()) {
this.getRouter().dispatch('ApiUser', 'view', {id: model.id, model: model});
return;
}
Dep.prototype.createViewView.call(this, options, model, view);
},
});
});
+35 -4
View File
@@ -26,15 +26,37 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('helpers/export', ['lib!espo'], function (Espo) {
define('helpers/export', [], function () {
return class {
/**
* An export helper.
*
* @memberOf module:helpers/export
*/
class Class {
/**
* @param {module:view.Class} view A view.
*/
constructor(view) {
/**
* @private
* @type {module:view.Class}
*/
this.view = view;
/**
* @private
* @type {module:models/settings.Class}
*/
this.config = view.getConfig();
}
/**
* Check whether an export should be run in idle.
*
* @param {number} totalCount A total record count.
* @returns {boolean}
*/
checkIsIdle(totalCount) {
if (this.view.getUser().isPortal()) {
return false;
@@ -47,10 +69,17 @@ define('helpers/export', ['lib!espo'], function (Espo) {
return totalCount === -1 || totalCount > this.config.get('exportIdleCountThreshold');
}
/**
* Process export.
*
* @param {string} id An ID.
* @returns {Promise<module:view.Class>} Resolves with a dialog view.
* The view emits the 'close:success' event.
*/
process(id) {
Espo.Ui.notify(false);
return new Promise((resolve) => {
return new Promise(resolve => {
this.view
.createView('dialog', 'views/export/modals/idle', {
id: id,
@@ -70,5 +99,7 @@ define('helpers/export', ['lib!espo'], function (Espo) {
});
});
}
};
}
return Class;
});
+45 -4
View File
@@ -26,13 +26,41 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('helpers/file-upload', ['lib!espo'], function (Espo) {
define('helpers/file-upload', [], function () {
return class {
/**
* A file-upload helper.
*
* @memberOf module:helpers/file-upload
*/
class Class {
/**
* @param {module:models/settings.Class} config A config.
*/
constructor(config) {
/**
* @private
* @type {module:models/settings.Class}
*/
this.config = config;
}
/**
* @typedef {Object} module:helpers/file-upload~Options
*
* @property {Function} [afterChunkUpload] After every chunk is uploaded.
* @property {Function} [afterAttachmentSave] After an attachment is saved.
* @property {{isCanceled?: boolean}} [mediator] A mediator.
*/
/**
* Upload.
*
* @param {File} file A file.
* @param {module:model.Class} attachment An attachment model.
* @param {module:helpers/file-upload~Options} [options] Options.
* @returns {Promise<unknown>}
*/
upload(file, attachment, options) {
options = options || {};
@@ -64,11 +92,13 @@ define('helpers/file-upload', ['lib!espo'], function (Espo) {
});
}
/**
* @private
*/
_uploadByChunks(file, attachment, options) {
return new Promise((resolve, reject) => {
attachment.set('isBeingUploaded', true);
// todo test catching
attachment
.save()
.then(() => {
@@ -86,6 +116,9 @@ define('helpers/file-upload', ['lib!espo'], function (Espo) {
});
}
/**
* @private
*/
_uploadChunks(file, attachment, resolve, reject, options, start) {
start = start || 0;
let end = start + this._getChunkSize() + 1;
@@ -139,6 +172,9 @@ define('helpers/file-upload', ['lib!espo'], function (Espo) {
fileReader.readAsDataURL(blob);
}
/**
* @private
*/
_useChunks(file) {
let chunkSize = this._getChunkSize();
@@ -153,8 +189,13 @@ define('helpers/file-upload', ['lib!espo'], function (Espo) {
return false;
}
/**
* @private
*/
_getChunkSize() {
return (this.config.get('attachmentUploadChunkSize') || 0) * 1024 * 1024;
}
};
}
return Class;
});
+36 -4
View File
@@ -26,15 +26,37 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('helpers/mass-action', ['lib!espo'], function (Espo) {
define('helpers/mass-action', [], function () {
return class {
/**
* A mass-action helper.
*
* @memberOf module:helpers/mass-action
*/
class Class {
/**
* @param {module:view.Class} view A view.
*/
constructor(view) {
/**
* @private
* @type {module:view.Class}
*/
this.view = view;
/**
* @private
* @type {module:models/settings.Class}
*/
this.config = view.getConfig();
}
/**
* Check whether an action should be run in idle.
*
* @param {number} totalCount A total record count.
* @returns {boolean}
*/
checkIsIdle(totalCount) {
if (this.view.getUser().isPortal()) {
return false;
@@ -47,10 +69,18 @@ define('helpers/mass-action', ['lib!espo'], function (Espo) {
return totalCount === -1 || totalCount > this.config.get('massActionIdleCountThreshold');
}
/**
* Process.
*
* @param {string} id An ID.
* @param {string} action An action.
* @returns {Promise<module:view.Class>} Resolves with a dialog view.
* The view emits the 'close:success' event.
*/
process(id, action) {
Espo.Ui.notify(false);
return new Promise((resolve) => {
return new Promise(resolve => {
this.view
.createView('dialog', 'views/modals/mass-action', {
id: id,
@@ -71,5 +101,7 @@ define('helpers/mass-action', ['lib!espo'], function (Espo) {
});
});
}
};
}
return Class;
});
+2 -4
View File
@@ -26,9 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('models/email', 'model', function (Dep) {
define('models/email', ['model'], function (Dep) {
return Dep.extend({
});
return Dep.extend({});
});
+26 -5
View File
@@ -28,18 +28,39 @@
define('models/preferences', ['model'], function (Dep) {
return Dep.extend({
/**
* User preferences.
*
* @class
* @name Class
* @extends module:model.Class
*
* @memberOf module:models/preferences
*/
return Dep.extend(/** @lends module:models/preferences.Class# */{
/**
* @inheritDoc
*/
name: 'Preferences',
settings: null,
/**
* Get dashlet options.
*
* @param {string} id A dashlet ID.
* @returns {Object|null}
*/
getDashletOptions: function (id) {
var value = this.get('dashletsOptions') || {};
let value = this.get('dashletsOptions') || {};
return value[id] || false;
return value[id] || null;
},
/**
* Whether a user is portal.
*
* @returns {boolean}
*/
isPortal: function () {
return this.get('isPortalUser');
},
+50 -8
View File
@@ -26,34 +26,76 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('models/user', 'model', function (Dep) {
define('models/user', ['model'], function (Dep) {
return Dep.extend({
/**
* A user.
*
* @class
* @name Class
* @extends module:model.Class
*
* @memberOf module:models/user
*/
return Dep.extend({/** @lends module:models/user.Class# */
/**
* @inheritDoc
*/
name: 'User',
/**
* Is admin.
*
* @returns {boolean}
*/
isAdmin: function () {
return this.get('type') == 'admin' || this.isSuperAdmin();
return this.get('type') === 'admin' || this.isSuperAdmin();
},
/**
* Is portal.
*
* @returns {boolean}
*/
isPortal: function () {
return this.get('type') == 'portal';
return this.get('type') === 'portal';
},
/**
* Is API.
*
* @returns {boolean}
*/
isApi: function () {
return this.get('type') == 'api';
return this.get('type') === 'api';
},
/**
* Is regular.
*
* @returns {boolean}
*/
isRegular: function () {
return this.get('type') == 'regular';
return this.get('type') === 'regular';
},
/**
* Is system.
*
* @returns {boolean}
*/
isSystem: function () {
return this.get('type') == 'system';
return this.get('type') === 'system';
},
/**
* Is super-admin.
*
* @returns {boolean}
*/
isSuperAdmin: function () {
return this.get('type') == 'super-admin';
return this.get('type') === 'super-admin';
},
});
});