This commit is contained in:
Yuri Kuznetsov
2023-07-01 17:49:06 +03:00
parent a7efea44d1
commit 95b1560c8a
19 changed files with 287 additions and 283 deletions
+1 -1
View File
@@ -441,7 +441,7 @@ class Controller {
/**
* Create a main view in the master.
*
* @param {string} view A view name.
* @param {string} [view] A view name.
* @param {Object} [options] Options for view.
* @param {module:controller~viewCallback} [callback] A callback with a created view.
* @param {boolean} [useStored] Use a stored view if available.
+6
View File
@@ -41,6 +41,12 @@ class ApiUserController extends RecordController {
});
}
/**
* @protected
* @param {Object} options
* @param {module:models/user} model
* @param {string} view
*/
createViewView(options, model, view) {
if (!model.isApi()) {
if (model.isPortal()) {
+10 -10
View File
@@ -26,17 +26,17 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/inbound-email', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class InboundEmailController extends RecordController {
checkAccess: function () {
if (this.getUser().isAdmin()) {
return true;
}
checkAccess(action) {
if (this.getUser().isAdmin()) {
return true;
}
return false;
},
return false;
}
}
});
});
export default InboundEmailController;
+10 -8
View File
@@ -26,14 +26,16 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/last-viewed', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class LastViewedController extends RecordController {
entityType: 'ActionHistoryRecord',
entityType = 'ActionHistoryRecord'
checkAccess: function (action) {
return this.getAcl().check(this.entityType, action);
},
});
});
checkAccess(action) {
return this.getAcl().check(this.entityType, action);
}
}
// noinspection JSUnusedGlobalSymbols
export default LastViewedController;
+19 -15
View File
@@ -26,23 +26,27 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/layout-set', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class LayoutSetController extends RecordController {
actionEditLayouts: function (options) {
var id = options.id;
// noinspection JSUnusedGlobalSymbols
/**
* @param {Record} options
*/
actionEditLayouts(options) {
let 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,
scope: options.scope,
type: options.type,
});
},
this.main('views/layout-set/layouts', {
layoutSetId: id,
scope: options.scope,
type: options.type,
});
}
}
});
});
export default LayoutSetController;
@@ -26,32 +26,34 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/lead-capture-opt-in-confirmation', ['controller'], function (Dep) {
import Controller from 'controller';
return Dep.extend({
class LeadCaptureOptInConfirmationController extends Controller {
actionOptInConfirmationSuccess: function (data) {
var viewName = this.getMetadata()
.get(['clientDefs', 'LeadCapture', 'optInConfirmationSuccessView']) ||
'views/lead-capture/opt-in-confirmation-success';
// noinspection JSUnusedGlobalSymbols
actionOptInConfirmationSuccess(data) {
let viewName = this.getMetadata().get(['clientDefs', 'LeadCapture', 'optInConfirmationSuccessView']) ||
'views/lead-capture/opt-in-confirmation-success';
this.entire(viewName, {
resultData: data,
}, (view) => {
view.render();
});
},
this.entire(viewName, {
resultData: data,
}, view => {
view.render();
});
}
actionOptInConfirmationExpired: function (data) {
var viewName = this.getMetadata()
.get(['clientDefs', 'LeadCapture', 'optInConfirmationExpiredView']) ||
'views/lead-capture/opt-in-confirmation-expired';
// noinspection JSUnusedGlobalSymbols
actionOptInConfirmationExpired(data) {
let viewName = this.getMetadata().get(['clientDefs', 'LeadCapture', 'optInConfirmationExpiredView']) ||
'views/lead-capture/opt-in-confirmation-expired';
this.entire(viewName, {
resultData: data
}, (view) => {
view.render();
});
},
});
});
this.entire(viewName, {
resultData: data,
}, view => {
view.render();
});
}
}
// noinspection JSUnusedGlobalSymbols
export default LeadCaptureOptInConfirmationController;
+27 -21
View File
@@ -26,29 +26,35 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/login-as', ['controller'], function (Dep) {
import Controller from 'controller';
return Dep.extend({
class LoginAsController extends Controller {
actionLogin: function (options) {
let anotherUser = options.anotherUser;
let username = options.username;
// noinspection JSUnusedGlobalSymbols
/**
* @param {Record} options
*/
actionLogin(options) {
let anotherUser = options.anotherUser;
let username = options.username;
if (!anotherUser) {
throw new Error("No anotherUser.");
}
if (!anotherUser) {
throw new Error("No anotherUser.");
}
this.baseController.login({
anotherUser: anotherUser,
username: username,
});
this.baseController.login({
anotherUser: anotherUser,
username: username,
});
this.listenToOnce(this.baseController, 'login', () => {
this.baseController.once('router-set', () => {
let url = window.location.href.split('?')[0];
window.location.replace(url);
})
});
},
});
});
this.listenToOnce(this.baseController, 'login', () => {
this.baseController.once('router-set', () => {
let url = window.location.href.split('?')[0];
window.location.replace(url);
})
});
}
}
export default LoginAsController;
+27 -28
View File
@@ -26,42 +26,41 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/note', ['controller'], function (Dep) {
import Controller from 'controller';
class NoteController extends Controller {
// noinspection JSUnusedGlobalSymbols
/**
* @class
* @name Class
* @extends module:controller
* @memberOf module:controllers/note
* @param {Record} options
*/
return Dep.extend(/** @lends module:controllers/note.Class# */{
actionView(options) {
let id = options.id;
actionView: function (options) {
let id = options.id;
if (!id) {
throw new Espo.Exceptions.NotFound;
}
if (!id) {
throw new Espo.Espo.Exceptions.NotFound;
}
let viewName = this.getMetadata().get(['clientDefs', this.name, 'views', 'detail']) ||
'views/note/detail';
let viewName = 'views/note/detail' ||
this.getMetadata().get(['clientDefs', this.name, 'views', 'detail']);
let model;
let model;
this.showLoadingNotification();
this.showLoadingNotification();
this.modelFactory.create('Note')
.then(m => {
model = m;
model.id = id;
this.modelFactory.create('Note')
.then(m => {
model = m;
model.id = id;
return model.fetch({main: true});
})
.then(() => {
this.hideLoadingNotification();
return model.fetch({main: true});
})
.then(() => {
this.hideLoadingNotification();
this.main(viewName, {model: model});
});
}
}
this.main(viewName, {model: model});
});
},
});
});
export default NoteController;
+12 -10
View File
@@ -26,16 +26,18 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/notification', ['controller'], function (Dep) {
import Controller from 'controller';
return Dep.extend({
class NotificationController extends Controller {
defaultAction: 'index',
defaultAction = 'index'
actionIndex: function () {
this.main('views/notification/list', {}, (view) => {
view.render();
});
},
});
});
// noinspection JSUnusedGlobalSymbols
actionIndex() {
this.main('views/notification/list', {}, view => {
view.render();
});
}
}
export default NotificationController;
-39
View File
@@ -1,39 +0,0 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
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,24 +26,26 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/password-change-request', ['controller'], function (Dep) {
import Controller from 'controller';
return Dep.extend({
class PasswordChangeRequestController extends Controller {
actionPasswordChange: function (options) {
options = options || {};
// noinspection JSUnusedGlobalSymbols
actionPasswordChange(options) {
options = options || {};
if (!options.id) {
throw new Error();
}
if (!options.id) {
throw new Error();
}
this.entire('views/user/password-change-request', {
requestId: options.id,
strengthParams: options.strengthParams,
notFound: options.notFound,
}, view => {
view.render();
});
},
});
});
this.entire('views/user/password-change-request', {
requestId: options.id,
strengthParams: options.strengthParams,
notFound: options.notFound,
}, view => {
view.render();
});
}
}
export default PasswordChangeRequestController;
+11 -10
View File
@@ -26,16 +26,17 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/portal-role', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class PortalRoleController extends RecordController {
checkAccess: function () {
if (this.getUser().isAdmin()) {
return true;
}
checkAccess(action) {
if (this.getUser().isAdmin()) {
return true;
}
return false;
},
});
});
return false;
}
}
export default PortalRoleController;
+6
View File
@@ -41,6 +41,12 @@ class PortalUserController extends RecordController {
});
}
/**
* @protected
* @param {Object} options
* @param {module:models/user} model
* @param {string} view
*/
createViewView(options, model, view) {
if (!model.isPortal()) {
if (model.isApi()) {
+27 -25
View File
@@ -26,36 +26,38 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/preferences', ['controllers/record', 'models/preferences'], function (Dep, Preferences) {
import RecordController from 'controllers/record';
import Preferences from 'models/preferences';
return Dep.extend({
class PreferencesController extends RecordController {
defaultAction: 'own',
defaultAction = 'own'
getModel: function (callback) {
var model = new Preferences();
getModel(callback, context) {
let model = new Preferences();
model.settings = this.getConfig();
model.defs = this.getMetadata().get('entityDefs.Preferences');
model.settings = this.getConfig();
model.defs = this.getMetadata().get('entityDefs.Preferences');
if (callback) {
callback.call(this, model);
}
return new Promise(function (resolve) {
resolve(model);
});
},
if (callback) {
callback.call(this, model);
}
checkAccess: function (action) {
return true;
},
return new Promise(resolve => {
resolve(model);
});
}
actionOwn: function () {
this.actionEdit({
id: this.getUser().id
});
},
checkAccess(action) {
return true;
}
actionList: function () {},
});
});
// noinspection JSUnusedGlobalSymbols
actionOwn() {
this.actionEdit({id: this.getUser().id});
}
actionList() {}
}
export default PreferencesController;
+27 -24
View File
@@ -26,36 +26,39 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/record-tree', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class RecordTreeController extends RecordController {
defaultAction: 'listTree',
defaultAction = 'listTree'
beforeView: function (options) {
Dep.prototype.beforeView.call(this, options);
beforeView(options) {
super.beforeView(options);
options = options || {};
options = options || {};
if (options.model) {
options.model.unset('childCollection');
options.model.unset('childList');
}
},
if (options.model) {
options.model.unset('childCollection');
options.model.unset('childList');
}
}
beforeListTree: function () {
this.handleCheckAccess('read');
},
// noinspection JSUnusedGlobalSymbols
beforeListTree() {
this.handleCheckAccess('read');
}
actionListTree: function () {
this.getCollection().then(collection => {
collection.url = collection.entityType + '/action/listTree';
// noinspection JSUnusedGlobalSymbols
actionListTree() {
this.getCollection().then(collection => {
collection.url = collection.entityType + '/action/listTree';
this.main(this.getViewName('listTree'), {
scope: this.name,
collection: collection
});
this.main(this.getViewName('listTree'), {
scope: this.name,
collection: collection
});
},
});
});
});
}
}
export default RecordTreeController;
+1 -1
View File
@@ -61,7 +61,7 @@ class RecordController extends Controller {
* Get a view name/path.
*
* @protected
* @param {'list'|'detail'|'edit'|'create'|'listRelated'} type A type.
* @param {'list'|'detail'|'edit'|'create'|'listRelated'|string} type A type.
* @returns {string}
*/
getViewName(type) {
+11 -10
View File
@@ -26,16 +26,17 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/role', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class RoleController extends RecordController {
checkAccess: function () {
if (this.getUser().isAdmin()) {
return true;
}
checkAccess(action) {
if (this.getUser().isAdmin()) {
return true;
}
return false;
},
});
});
return false;
}
}
export default RoleController;
+32 -28
View File
@@ -26,36 +26,40 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/stream', ['controller'], function (Dep) {
import Controller from 'controller';
return Dep.extend({
class StreamController extends Controller {
defaultAction: 'index',
defaultAction = 'index'
actionIndex: function () {
this.main('views/stream', {
displayTitle: true,
}, function (view) {
view.render();
});
},
// noinspection JSUnusedGlobalSymbols
actionIndex() {
this.main('views/stream', {
displayTitle: true,
}, view => {
view.render();
});
}
actionPosts: function () {
this.main('views/stream', {
displayTitle: true,
filter: 'posts',
}, function (view) {
view.render();
});
},
// noinspection JSUnusedGlobalSymbols
actionPosts() {
this.main('views/stream', {
displayTitle: true,
filter: 'posts',
}, view => {
view.render();
});
}
actionUpdates: function () {
this.main('views/stream', {
displayTitle: true,
filter: 'updates',
}, function (view) {
view.render();
});
},
});
});
// noinspection JSUnusedGlobalSymbols
actionUpdates() {
this.main('views/stream', {
displayTitle: true,
filter: 'updates',
}, view => {
view.render();
});
}
}
export default StreamController;
+15 -12
View File
@@ -26,18 +26,21 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('controllers/team', ['controllers/record'], function (Dep) {
import RecordController from 'controllers/record';
return Dep.extend({
class TeamController extends RecordController {
checkAccess: function (action) {
if (action == 'read') {
return true;
}
checkAccess(action) {
if (action === 'read') {
return true;
}
if (this.getUser().isAdmin()) {
return true;
}
},
});
});
if (this.getUser().isAdmin()) {
return true;
}
return false;
}
}
export default TeamController;