ref
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"controller": "controllers/email-account",
|
||||
"recordViews": {
|
||||
"list":"views/email-account/record/list",
|
||||
"detail": "views/email-account/record/detail",
|
||||
|
||||
@@ -26,16 +26,18 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/about', ['controller'], function (Dep) {
|
||||
import Controller from 'controller';
|
||||
|
||||
return Dep.extend({
|
||||
class AboutController extends Controller {
|
||||
|
||||
defaultAction: 'about',
|
||||
defaultAction = 'about'
|
||||
|
||||
actionAbout: function () {
|
||||
this.main('About', {}, function (view) {
|
||||
view.render();
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionAbout() {
|
||||
this.main('About', {}, view => {
|
||||
view.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default AboutController;
|
||||
|
||||
@@ -26,34 +26,39 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/address-map', ['controller'], function (Dep) {
|
||||
import Controller from 'controller';
|
||||
|
||||
return Dep.extend({
|
||||
class AddressMapController extends Controller {
|
||||
|
||||
defaultAction: 'index',
|
||||
defaultAction = 'index'
|
||||
|
||||
actionIndex: function () {
|
||||
this.error404();
|
||||
},
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionIndex() {
|
||||
this.error404();
|
||||
}
|
||||
|
||||
actionView: function (o) {
|
||||
this.modelFactory.create(o.entityType)
|
||||
.then(
|
||||
function (model) {
|
||||
model.id = o.id;
|
||||
model.fetch().then(
|
||||
function () {
|
||||
var viewName = this.getMetadata().get(['AddressMap', 'view']) ||
|
||||
'views/address-map/view';
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* @param {Object} o
|
||||
*/
|
||||
actionView(o) {
|
||||
this.modelFactory
|
||||
.create(o.entityType)
|
||||
.then(model => {
|
||||
model.id = o.id;
|
||||
|
||||
this.main(viewName, {
|
||||
model: model,
|
||||
field: o.field,
|
||||
});
|
||||
}.bind(this)
|
||||
);
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
||||
model.fetch()
|
||||
.then(() => {
|
||||
let viewName = this.getMetadata().get(['AddressMap', 'view']) ||
|
||||
'views/address-map/view';
|
||||
|
||||
this.main(viewName, {
|
||||
model: model,
|
||||
field: o.field,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default AddressMapController;
|
||||
|
||||
@@ -26,18 +26,20 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/dashboard', ['controller'], function (Dep) {
|
||||
import Controller from 'controller';
|
||||
|
||||
return Dep.extend({
|
||||
class DashboardController extends Controller {
|
||||
|
||||
defaultAction: 'index',
|
||||
defaultAction = 'index'
|
||||
|
||||
actionIndex: function () {
|
||||
this.main('views/dashboard', {
|
||||
displayTitle: true,
|
||||
}, (view) => {
|
||||
view.render();
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionIndex() {
|
||||
this.main('views/dashboard', {
|
||||
displayTitle: true,
|
||||
}, view => {
|
||||
view.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default DashboardController;
|
||||
|
||||
@@ -1,34 +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/email-account', ['controllers/record'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
});
|
||||
});
|
||||
@@ -26,21 +26,22 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/email', ['controllers/record'], function (Dep) {
|
||||
import RecordController from 'controllers/record';
|
||||
|
||||
return Dep.extend({
|
||||
class EmailController extends RecordController {
|
||||
|
||||
prepareModelView: function (model, options) {
|
||||
Dep.prototype.prepareModelView(model, options);
|
||||
prepareModelView(model, options) {
|
||||
super.prepareModelView(model, options);
|
||||
|
||||
this.listenToOnce(model, 'after:send', () => {
|
||||
let key = this.name + 'List';
|
||||
let stored = this.getStoredMainView(key);
|
||||
this.listenToOnce(model, 'after:send', () => {
|
||||
let key = this.name + 'List';
|
||||
let stored = this.getStoredMainView(key);
|
||||
|
||||
if (stored) {
|
||||
this.clearStoredMainView(key);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
if (stored) {
|
||||
this.clearStoredMainView(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default EmailController;
|
||||
|
||||
@@ -26,37 +26,41 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/external-account', ['controller'], function (Dep) {
|
||||
import Controller from 'controller';
|
||||
|
||||
return Dep.extend({
|
||||
class ExternalAccountController extends Controller {
|
||||
|
||||
defaultAction: 'list',
|
||||
defaultAction = 'list'
|
||||
|
||||
actionList: function (options) {
|
||||
this.collectionFactory.create('ExternalAccount', (collection) => {
|
||||
collection.once('sync', () => {
|
||||
this.main('ExternalAccount.Index', {
|
||||
collection: collection,
|
||||
});
|
||||
actionList() {
|
||||
this.collectionFactory.create('ExternalAccount', collection => {
|
||||
collection.once('sync', () => {
|
||||
this.main('ExternalAccount.Index', {
|
||||
collection: collection,
|
||||
});
|
||||
|
||||
collection.fetch();
|
||||
});
|
||||
},
|
||||
|
||||
actionEdit: function (options) {
|
||||
let id = options.id;
|
||||
collection.fetch();
|
||||
});
|
||||
}
|
||||
|
||||
this.collectionFactory.create('ExternalAccount', (collection) => {
|
||||
collection.once('sync', () => {
|
||||
this.main('ExternalAccount.Index', {
|
||||
collection: collection,
|
||||
id: id,
|
||||
});
|
||||
/**
|
||||
* @param {{id: string}} options
|
||||
*/
|
||||
actionEdit(options) {
|
||||
let id = options.id;
|
||||
|
||||
this.collectionFactory.create('ExternalAccount', collection => {
|
||||
collection.once('sync', () => {
|
||||
this.main('ExternalAccount.Index', {
|
||||
collection: collection,
|
||||
id: id,
|
||||
});
|
||||
|
||||
collection.fetch();
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
collection.fetch();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ExternalAccountController;
|
||||
|
||||
@@ -26,12 +26,14 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/home', ['controller'], function (Dep) {
|
||||
import Controller from 'controller';
|
||||
|
||||
return Dep.extend({
|
||||
class HomeController extends Controller {
|
||||
|
||||
actionIndex: function () {
|
||||
this.main('views/home', null);
|
||||
},
|
||||
});
|
||||
});
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionIndex() {
|
||||
this.main('views/home', null);
|
||||
}
|
||||
}
|
||||
|
||||
export default HomeController;
|
||||
|
||||
@@ -26,71 +26,79 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('controllers/import', ['controllers/record'], function (Dep) {
|
||||
import RecordController from 'controllers/record';
|
||||
|
||||
return Dep.extend({
|
||||
class ImportController extends RecordController {
|
||||
|
||||
defaultAction: 'index',
|
||||
defaultAction = 'index'
|
||||
|
||||
checkAccessGlobal: function () {
|
||||
if (this.getAcl().checkScope('Import')) {
|
||||
return true;
|
||||
}
|
||||
checkAccessGlobal() {
|
||||
if (this.getAcl().checkScope('Import')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
return false;
|
||||
}
|
||||
|
||||
checkAccess: function () {
|
||||
if (this.getAcl().checkScope('Import')) {
|
||||
return true;
|
||||
}
|
||||
checkAccess(action) {
|
||||
if (this.getAcl().checkScope('Import')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
return false;
|
||||
}
|
||||
|
||||
actionIndex: function (o) {
|
||||
o = o || {};
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* @param {{
|
||||
* step?: int|string,
|
||||
* fromAdmin?: boolean,
|
||||
* formData?: Object
|
||||
* }} o
|
||||
*/
|
||||
actionIndex(o) {
|
||||
o = o || {};
|
||||
|
||||
var step = null;
|
||||
let step = null;
|
||||
|
||||
if (o.step) {
|
||||
step = parseInt(step);
|
||||
}
|
||||
if (o.step) {
|
||||
step = parseInt(step);
|
||||
}
|
||||
|
||||
var formData = null;
|
||||
var fileContents = null;
|
||||
let formData = null;
|
||||
let fileContents = null;
|
||||
|
||||
if (this.storedData) {
|
||||
formData = this.storedData.formData;
|
||||
fileContents = this.storedData.fileContents;
|
||||
}
|
||||
if (this.storedData) {
|
||||
formData = this.storedData.formData;
|
||||
fileContents = this.storedData.fileContents;
|
||||
}
|
||||
|
||||
if (!formData) {
|
||||
step = null;
|
||||
}
|
||||
if (!formData) {
|
||||
step = null;
|
||||
}
|
||||
|
||||
formData = formData || o.formData;
|
||||
formData = formData || o.formData;
|
||||
|
||||
this.main('views/import/index', {
|
||||
step: step,
|
||||
formData: formData,
|
||||
fileContents: fileContents,
|
||||
fromAdmin: o.fromAdmin,
|
||||
}, (view) => {
|
||||
this.listenTo(view, 'change', () => {
|
||||
this.storedData = {
|
||||
formData: view.formData,
|
||||
fileContents: view.fileContents,
|
||||
};
|
||||
});
|
||||
|
||||
this.listenTo(view, 'done', () => {
|
||||
delete this.storedData;
|
||||
});
|
||||
|
||||
view.render();
|
||||
this.main('views/import/index', {
|
||||
step: step,
|
||||
formData: formData,
|
||||
fileContents: fileContents,
|
||||
fromAdmin: o.fromAdmin,
|
||||
}, /** module:views/import/index */ view => {
|
||||
this.listenTo(view, 'change', () => {
|
||||
this.storedData = {
|
||||
formData: view.formData,
|
||||
fileContents: view.fileContents,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
this.listenTo(view, 'done', () => {
|
||||
delete this.storedData;
|
||||
});
|
||||
|
||||
view.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ImportController;
|
||||
|
||||
@@ -80,7 +80,7 @@ class FieldManager {
|
||||
* Get a list of parameters for a specific field type.
|
||||
*
|
||||
* @param {string} fieldType A field type.
|
||||
* @returns {string[]}
|
||||
* @returns {Object.<string, *>[]}
|
||||
*/
|
||||
getParamList(fieldType) {
|
||||
if (fieldType in this.defs) {
|
||||
|
||||
@@ -26,36 +26,31 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('handlers/create-related', [], () => {
|
||||
/**
|
||||
* Prepares attributes for a related record that is being created.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
class CreateRelatedHandler {
|
||||
|
||||
/**
|
||||
* Prepares attributes for a related record that is being created.
|
||||
*
|
||||
* @abstract
|
||||
* @class
|
||||
* @name Class
|
||||
* @memberOf module:handlers/create-related
|
||||
* @param {module:view-helper} viewHelper
|
||||
*/
|
||||
class Class {
|
||||
|
||||
/**
|
||||
* @param {module:view-helper} viewHelper
|
||||
*/
|
||||
constructor(viewHelper) {
|
||||
this.viewHelper = viewHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes for a new record.
|
||||
*
|
||||
* @abstract
|
||||
* @param {module:model} model A model.
|
||||
* @return {Promise<Object.<string, *>>} Attributes.
|
||||
*/
|
||||
getAttributes(model) {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
constructor(viewHelper) {
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
this.viewHelper = viewHelper;
|
||||
}
|
||||
|
||||
return Class;
|
||||
});
|
||||
/**
|
||||
* Get attributes for a new record.
|
||||
*
|
||||
* @abstract
|
||||
* @param {module:model} model A model.
|
||||
* @return {Promise<Object.<string, *>>} Attributes.
|
||||
*/
|
||||
getAttributes(model) {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
}
|
||||
|
||||
export default CreateRelatedHandler;
|
||||
|
||||
@@ -26,101 +26,101 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('handlers/email-filter', ['dynamic-handler'], (Dep) => {
|
||||
import DynamicHandler from 'dynamic-handler';
|
||||
|
||||
return Dep.extend({
|
||||
class EmailFilterHandler extends DynamicHandler {
|
||||
|
||||
init: function () {
|
||||
if (this.model.isNew()) {
|
||||
if (!this.recordView.getUser().isAdmin()) {
|
||||
this.recordView.hideField('isGlobal');
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!this.model.isNew() &&
|
||||
!this.recordView.getUser().isAdmin() &&
|
||||
!this.model.get('isGlobal')
|
||||
) {
|
||||
init() {
|
||||
if (this.model.isNew()) {
|
||||
if (!this.recordView.getUser().isAdmin()) {
|
||||
this.recordView.hideField('isGlobal');
|
||||
}
|
||||
}
|
||||
|
||||
if (this.model.isNew() && !this.model.get('parentId')) {
|
||||
this.model.set('parentType', 'User');
|
||||
this.model.set('parentId', this.recordView.getUser().id);
|
||||
this.model.set('parentName', this.recordView.getUser().get('name'));
|
||||
if (
|
||||
!this.model.isNew() &&
|
||||
!this.recordView.getUser().isAdmin() &&
|
||||
!this.model.get('isGlobal')
|
||||
) {
|
||||
this.recordView.hideField('isGlobal');
|
||||
}
|
||||
|
||||
if (!this.recordView.getUser().isAdmin()) {
|
||||
this.recordView.setFieldReadOnly('parent');
|
||||
}
|
||||
}
|
||||
else if (
|
||||
this.model.get('parentType') &&
|
||||
!this.recordView.options.duplicateSourceId
|
||||
) {
|
||||
if (this.model.isNew() && !this.model.get('parentId')) {
|
||||
this.model.set('parentType', 'User');
|
||||
this.model.set('parentId', this.recordView.getUser().id);
|
||||
this.model.set('parentName', this.recordView.getUser().get('name'));
|
||||
|
||||
if (!this.recordView.getUser().isAdmin()) {
|
||||
this.recordView.setFieldReadOnly('parent');
|
||||
this.recordView.setFieldReadOnly('isGlobal');
|
||||
}
|
||||
}
|
||||
else if (
|
||||
this.model.get('parentType') &&
|
||||
!this.recordView.options.duplicateSourceId
|
||||
) {
|
||||
this.recordView.setFieldReadOnly('parent');
|
||||
this.recordView.setFieldReadOnly('isGlobal');
|
||||
}
|
||||
|
||||
this.recordView.listenTo(this.model, 'change:isGlobal', (model, value, o) => {
|
||||
if (!o.ui) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.recordView.listenTo(this.model, 'change:isGlobal', (model, value, o) => {
|
||||
if (!o.ui) {
|
||||
if (value) {
|
||||
this.model.set({
|
||||
action: 'Skip',
|
||||
parentName: null,
|
||||
parentType: null,
|
||||
parentId: null,
|
||||
emailFolderId: null,
|
||||
groupEmailFolderId: null,
|
||||
markAsRead: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.recordView.listenTo(this.model, 'change:parentType', (model, value, o) => {
|
||||
if (!o.ui) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoiding side effects.
|
||||
setTimeout(() => {
|
||||
if (value !== 'User') {
|
||||
this.model.set('markAsRead', false);
|
||||
}
|
||||
|
||||
if (value === 'EmailAccount') {
|
||||
this.model.set('action', 'Skip');
|
||||
this.model.set('emailFolderId', null);
|
||||
this.model.set('groupEmailFolderId', null);
|
||||
this.model.set('markAsRead', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
this.model.set({
|
||||
action: 'Skip',
|
||||
parentName: null,
|
||||
parentType: null,
|
||||
parentId: null,
|
||||
emailFolderId: null,
|
||||
groupEmailFolderId: null,
|
||||
markAsRead: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.recordView.listenTo(this.model, 'change:parentType', (model, value, o) => {
|
||||
if (!o.ui) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoiding side effects.
|
||||
setTimeout(() => {
|
||||
if (value !== 'User') {
|
||||
this.model.set('markAsRead', false);
|
||||
}
|
||||
|
||||
if (value === 'EmailAccount') {
|
||||
if (value !== 'InboundEmail') {
|
||||
if (this.model.get('action') === 'Move to Group Folder') {
|
||||
this.model.set('action', 'Skip');
|
||||
this.model.set('emailFolderId', null);
|
||||
this.model.set('groupEmailFolderId', null);
|
||||
this.model.set('markAsRead', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value !== 'InboundEmail') {
|
||||
if (this.model.get('action') === 'Move to Group Folder') {
|
||||
this.model.set('action', 'Skip');
|
||||
}
|
||||
this.model.set('groupEmailFolderId', null);
|
||||
|
||||
this.model.set('groupEmailFolderId', null);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
if (value !== 'User') {
|
||||
if (this.model.get('action') === 'Move to Folder') {
|
||||
this.model.set('action', 'Skip');
|
||||
}
|
||||
|
||||
if (value !== 'User') {
|
||||
if (this.model.get('action') === 'Move to Folder') {
|
||||
this.model.set('action', 'Skip');
|
||||
}
|
||||
this.model.set('groupFolderId', null);
|
||||
}
|
||||
}, 40);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.model.set('groupFolderId', null);
|
||||
export default EmailFilterHandler;
|
||||
|
||||
return;
|
||||
}
|
||||
}, 40);
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,29 +26,26 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('handlers/import', ['action-handler'], function (Dep) {
|
||||
import ActionHandler from 'action-handler';
|
||||
|
||||
/**
|
||||
* @extends module:action-handler
|
||||
*/
|
||||
class Class extends Dep {
|
||||
class ImportHandler extends ActionHandler {
|
||||
|
||||
actionErrorExport() {
|
||||
Espo.Ajax
|
||||
.postRequest(`Import/${this.view.model.id}/exportErrors`)
|
||||
.then(data => {
|
||||
if (!data.attachmentId) {
|
||||
let message = this.view.translate('noErrors', 'messages', 'Import');
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionErrorExport() {
|
||||
Espo.Ajax
|
||||
.postRequest(`Import/${this.view.model.id}/exportErrors`)
|
||||
.then(data => {
|
||||
if (!data.attachmentId) {
|
||||
let message = this.view.translate('noErrors', 'messages', 'Import');
|
||||
|
||||
Espo.Ui.warning(message);
|
||||
Espo.Ui.warning(message);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
window.location = this.view.getBasePath() + '?entryPoint=download&id=' + data.attachmentId;
|
||||
});
|
||||
}
|
||||
window.location = this.view.getBasePath() + '?entryPoint=download&id=' + data.attachmentId;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Class;
|
||||
});
|
||||
export default ImportHandler;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
class Handler {
|
||||
class LoginHandler {
|
||||
|
||||
/**
|
||||
* @param {module:views/login} loginView A login view.
|
||||
@@ -67,4 +67,4 @@ class Handler {
|
||||
}
|
||||
}
|
||||
|
||||
export default Handler;
|
||||
export default LoginHandler;
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
import Dep from 'handlers/login';
|
||||
import LoginHandler from 'handlers/login';
|
||||
import Base64 from 'js-base64';
|
||||
|
||||
class Handler extends Dep {
|
||||
class OidcLoginHandler extends LoginHandler {
|
||||
|
||||
/** @inheritDoc */
|
||||
process() {
|
||||
@@ -209,4 +209,4 @@ class Handler extends Dep {
|
||||
}
|
||||
}
|
||||
|
||||
export default Handler;
|
||||
export default OidcLoginHandler;
|
||||
|
||||
@@ -42,12 +42,13 @@
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
class SelectRelated {
|
||||
class SelectRelatedHandler {
|
||||
|
||||
/**
|
||||
* @param {module:view-helper} viewHelper
|
||||
*/
|
||||
constructor(viewHelper) {
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/** @protected */
|
||||
this.viewHelper = viewHelper;
|
||||
}
|
||||
@@ -64,4 +65,4 @@ class SelectRelated {
|
||||
}
|
||||
}
|
||||
|
||||
export default SelectRelated;
|
||||
export default SelectRelatedHandler;
|
||||
|
||||
@@ -26,44 +26,47 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('handlers/select-related/same-account-many', ['handlers/select-related'], Dep => {
|
||||
import SelectRelatedHandler from 'handlers/select-related';
|
||||
|
||||
return class extends Dep {
|
||||
/**
|
||||
* @param {module:model} model
|
||||
* @return {Promise<module:handlers/select-related~filters>}
|
||||
*/
|
||||
getFilters(model) {
|
||||
let advanced = {};
|
||||
class SameAccountManySelectRelatedHandler extends SelectRelatedHandler {
|
||||
|
||||
let accountId = null;
|
||||
let accountName = null;
|
||||
/**
|
||||
* @param {module:model} model
|
||||
* @return {Promise<module:handlers/select-related~filters>}
|
||||
*/
|
||||
getFilters(model) {
|
||||
let advanced = {};
|
||||
|
||||
if (model.get('accountId')) {
|
||||
accountId = model.get('accountId');
|
||||
accountName = model.get('accountName');
|
||||
}
|
||||
let accountId = null;
|
||||
let accountName = null;
|
||||
|
||||
if (!accountId && model.get('parentType') === 'Account' && model.get('parentId')) {
|
||||
accountId = model.get('parentId');
|
||||
accountName = model.get('parentName');
|
||||
}
|
||||
|
||||
if (accountId) {
|
||||
let nameHash = {};
|
||||
nameHash[accountId] = accountName;
|
||||
|
||||
advanced.accounts = {
|
||||
field: 'accounts',
|
||||
type: 'linkedWith',
|
||||
value: [accountId],
|
||||
data: {nameHash: nameHash},
|
||||
};
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
advanced: advanced,
|
||||
});
|
||||
if (model.get('accountId')) {
|
||||
accountId = model.get('accountId');
|
||||
accountName = model.get('accountName');
|
||||
}
|
||||
|
||||
if (!accountId && model.get('parentType') === 'Account' && model.get('parentId')) {
|
||||
accountId = model.get('parentId');
|
||||
accountName = model.get('parentName');
|
||||
}
|
||||
|
||||
if (accountId) {
|
||||
let nameHash = {};
|
||||
nameHash[accountId] = accountName;
|
||||
|
||||
advanced.accounts = {
|
||||
field: 'accounts',
|
||||
type: 'linkedWith',
|
||||
value: [accountId],
|
||||
data: {nameHash: nameHash},
|
||||
};
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
advanced: advanced,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
export default SameAccountManySelectRelatedHandler;
|
||||
|
||||
@@ -26,44 +26,46 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('handlers/select-related/same-account', ['handlers/select-related'], Dep => {
|
||||
import SelectRelatedHandler from 'handlers/select-related';
|
||||
|
||||
return class extends Dep {
|
||||
/**
|
||||
* @param {module:model} model
|
||||
* @return {Promise<module:handlers/select-related~filters>}
|
||||
*/
|
||||
getFilters(model) {
|
||||
let advanced = {};
|
||||
class SameAccountSelectRelatedHandler extends SelectRelatedHandler {
|
||||
|
||||
let accountId = null;
|
||||
let accountName = null;
|
||||
/**
|
||||
* @param {module:model} model
|
||||
* @return {Promise<module:handlers/select-related~filters>}
|
||||
*/
|
||||
getFilters(model) {
|
||||
let advanced = {};
|
||||
|
||||
if (model.get('accountId')) {
|
||||
accountId = model.get('accountId');
|
||||
accountName = model.get('accountName');
|
||||
}
|
||||
let accountId = null;
|
||||
let accountName = null;
|
||||
|
||||
if (!accountId && model.get('parentType') === 'Account' && model.get('parentId')) {
|
||||
accountId = model.get('parentId');
|
||||
accountName = model.get('parentName');
|
||||
}
|
||||
|
||||
if (accountId) {
|
||||
advanced.account = {
|
||||
attribute: 'accountId',
|
||||
type: 'equals',
|
||||
value: accountId,
|
||||
data: {
|
||||
type: 'is',
|
||||
nameValue: accountName,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
advanced: advanced,
|
||||
});
|
||||
if (model.get('accountId')) {
|
||||
accountId = model.get('accountId');
|
||||
accountName = model.get('accountName');
|
||||
}
|
||||
|
||||
if (!accountId && model.get('parentType') === 'Account' && model.get('parentId')) {
|
||||
accountId = model.get('parentId');
|
||||
accountName = model.get('parentName');
|
||||
}
|
||||
|
||||
if (accountId) {
|
||||
advanced.account = {
|
||||
attribute: 'accountId',
|
||||
type: 'equals',
|
||||
value: accountId,
|
||||
data: {
|
||||
type: 'is',
|
||||
nameValue: accountName,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
advanced: advanced,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default SameAccountSelectRelatedHandler;
|
||||
|
||||
@@ -30,26 +30,26 @@
|
||||
|
||||
/**
|
||||
* A field-language util.
|
||||
*
|
||||
* @class
|
||||
* @param {module:metadata} metadata A metadata.
|
||||
* @param {module:language} language A language.
|
||||
*/
|
||||
const FieldLanguage = function (metadata, language) {
|
||||
/**
|
||||
* @private
|
||||
* @type {module:metadata}
|
||||
*/
|
||||
this.metadata = metadata;
|
||||
class FieldLanguage {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:language}
|
||||
* @param {module:metadata} metadata A metadata.
|
||||
* @param {module:language} language A language.
|
||||
*/
|
||||
this.language = language;
|
||||
};
|
||||
constructor(metadata, language) {
|
||||
/**
|
||||
* @private
|
||||
* @type {module:metadata}
|
||||
*/
|
||||
this.metadata = metadata;
|
||||
|
||||
_.extend(FieldLanguage.prototype, /** @lends FieldLanguage# */{
|
||||
/**
|
||||
* @private
|
||||
* @type {module:language}
|
||||
*/
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an attribute.
|
||||
@@ -58,61 +58,61 @@ _.extend(FieldLanguage.prototype, /** @lends FieldLanguage# */{
|
||||
* @param {string} name An attribute name.
|
||||
* @returns {string}
|
||||
*/
|
||||
translateAttribute: function (scope, name) {
|
||||
translateAttribute(scope, name) {
|
||||
let label = this.language.translate(name, 'fields', scope);
|
||||
|
||||
if (name.indexOf('Id') === name.length - 2) {
|
||||
let baseField = name.substr(0, name.length - 2);
|
||||
let baseField = name.slice(0, name.length - 2);
|
||||
|
||||
if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
|
||||
label = this.language.translate(baseField, 'fields', scope) +
|
||||
' (' + this.language.translate('id', 'fields') + ')';
|
||||
' (' + this.language.translate('id', 'fields') + ')';
|
||||
}
|
||||
}
|
||||
else if (name.indexOf('Name') === name.length - 4) {
|
||||
let baseField = name.substr(0, name.length - 4);
|
||||
let baseField = name.slice(0, name.length - 4);
|
||||
|
||||
if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
|
||||
label = this.language.translate(baseField, 'fields', scope) +
|
||||
' (' + this.language.translate('name', 'fields') + ')';
|
||||
' (' + this.language.translate('name', 'fields') + ')';
|
||||
}
|
||||
}
|
||||
else if (name.indexOf('Type') === name.length - 4) {
|
||||
let baseField = name.substr(0, name.length - 4);
|
||||
let baseField = name.slice(0, name.length - 4);
|
||||
|
||||
if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
|
||||
label = this.language.translate(baseField, 'fields', scope) +
|
||||
' (' + this.language.translate('type', 'fields') + ')';
|
||||
' (' + this.language.translate('type', 'fields') + ')';
|
||||
}
|
||||
}
|
||||
|
||||
if (name.indexOf('Ids') === name.length - 3) {
|
||||
let baseField = name.substr(0, name.length - 3);
|
||||
let baseField = name.slice(0, name.length - 3);
|
||||
|
||||
if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
|
||||
label = this.language.translate(baseField, 'fields', scope) +
|
||||
' (' + this.language.translate('ids', 'fields') + ')';
|
||||
' (' + this.language.translate('ids', 'fields') + ')';
|
||||
}
|
||||
}
|
||||
else if (name.indexOf('Names') === name.length - 5) {
|
||||
let baseField = name.substr(0, name.length - 5);
|
||||
let baseField = name.slice(0, name.length - 5);
|
||||
|
||||
if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
|
||||
label = this.language.translate(baseField, 'fields', scope) +
|
||||
' (' + this.language.translate('names', 'fields') + ')';
|
||||
' (' + this.language.translate('names', 'fields') + ')';
|
||||
}
|
||||
}
|
||||
else if (name.indexOf('Types') === name.length - 5) {
|
||||
let baseField = name.substr(0, name.length - 5);
|
||||
let baseField = name.slice(0, name.length - 5);
|
||||
|
||||
if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
|
||||
label = this.language.translate(baseField, 'fields', scope) +
|
||||
' (' + this.language.translate('types', 'fields') + ')';
|
||||
' (' + this.language.translate('types', 'fields') + ')';
|
||||
}
|
||||
}
|
||||
|
||||
return label;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default FieldLanguage;
|
||||
|
||||
Reference in New Issue
Block a user