diff --git a/application/Espo/Resources/layouts/Settings/authentication.json b/application/Espo/Resources/layouts/Settings/authentication.json index 7fbfb27990..88d1b767c8 100644 --- a/application/Espo/Resources/layouts/Settings/authentication.json +++ b/application/Espo/Resources/layouts/Settings/authentication.json @@ -5,28 +5,5 @@ [{"name": "authenticationMethod"}, {"name": "authTokenLifetime"}], [{"name": "authTokenPreventConcurrent"}, {"name": "authTokenMaxIdleTime"}] ] - }, - { - "label": "LDAP", - "name": "LDAP", - "rows": [ - [{"name": "ldapHost"}, {"name": "ldapPort"}], - [{"name": "ldapAuth"}, {"name": "ldapSecurity"}], - [{"name": "ldapUsername", "fullWidth": true}], - [{"name": "ldapPassword"}, {"name": "testConnection", "customLabel": null, "view": "views/admin/authentication/fields/test-connection"}], - [{"name": "ldapUserNameAttribute"}, {"name": "ldapUserObjectClass"}], - [{"name": "ldapAccountCanonicalForm"}, {"name": "ldapBindRequiresDn"}], - [{"name": "ldapBaseDn", "fullWidth": true}], - [{"name": "ldapUserLoginFilter", "fullWidth": true}], - [{"name": "ldapAccountDomainName"}, {"name": "ldapAccountDomainNameShort"}], - [{"name": "ldapTryUsernameSplit"}, {"name": "ldapOptReferrals"}], - [{"name": "ldapCreateEspoUser"}, false], - [{"name": "ldapUserFirstNameAttribute"}, {"name": "ldapUserLastNameAttribute"}], - [{"name": "ldapUserTitleAttribute"}, false], - [{"name": "ldapUserEmailAddressAttribute"}, {"name": "ldapUserPhoneNumberAttribute"}], - [{"name": "ldapUserTeams"}, {"name": "ldapUserDefaultTeam"}], - [{"name": "ldapPortalUserLdapAuth"}, false], - [{"name": "ldapPortalUserPortals"}, {"name": "ldapPortalUserRoles"}] - ] } ] diff --git a/application/Espo/Resources/metadata/authenticationMethods/LDAP.json b/application/Espo/Resources/metadata/authenticationMethods/LDAP.json new file mode 100644 index 0000000000..5e5a4b79d2 --- /dev/null +++ b/application/Espo/Resources/metadata/authenticationMethods/LDAP.json @@ -0,0 +1,181 @@ +{ + + "settings": { + "layout": { + "label": "LDAP", + "rows": [ + [{"name": "ldapHost"}, {"name": "ldapPort"}], + [{"name": "ldapAuth"}, {"name": "ldapSecurity"}], + [{"name": "ldapUsername", "fullWidth": true}], + [{"name": "ldapPassword"}, {"name": "testConnection", "customLabel": null, "view": "views/admin/authentication/fields/test-connection"}], + [{"name": "ldapUserNameAttribute"}, {"name": "ldapUserObjectClass"}], + [{"name": "ldapAccountCanonicalForm"}, {"name": "ldapBindRequiresDn"}], + [{"name": "ldapBaseDn", "fullWidth": true}], + [{"name": "ldapUserLoginFilter", "fullWidth": true}], + [{"name": "ldapAccountDomainName"}, {"name": "ldapAccountDomainNameShort"}], + [{"name": "ldapTryUsernameSplit"}, {"name": "ldapOptReferrals"}], + [{"name": "ldapCreateEspoUser"}, false], + [{"name": "ldapUserFirstNameAttribute"}, {"name": "ldapUserLastNameAttribute"}], + [{"name": "ldapUserTitleAttribute"}, false], + [{"name": "ldapUserEmailAddressAttribute"}, {"name": "ldapUserPhoneNumberAttribute"}], + [{"name": "ldapUserTeams"}, {"name": "ldapUserDefaultTeam"}], + [{"name": "ldapPortalUserLdapAuth"}, false], + [{"name": "ldapPortalUserPortals"}, {"name": "ldapPortalUserRoles"}] + ] + }, + "fieldList": [ + "ldapHost", "ldapPort", "ldapAuth", "ldapSecurity", + "ldapUsername", "ldapPassword", "ldapBindRequiresDn", + "ldapUserLoginFilter", "ldapBaseDn", "ldapAccountCanonicalForm", + "ldapAccountDomainName", "ldapAccountDomainNameShort", "ldapAccountDomainName", + "ldapAccountDomainNameShort", "ldapTryUsernameSplit", "ldapOptReferrals", + "ldapCreateEspoUser", "ldapPortalUserLdapAuth" + ], + "dynamicLogic": { + "fields": { + "ldapUsername": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapAuth" + } + ] + } + }, + "ldapPassword": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapAuth" + } + ] + } + }, + "testConnection": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapAuth" + } + ] + } + }, + "ldapAccountDomainName": { + "visible": { + "conditionGroup": [ + { + "type": "in", + "attribute": "ldapAccountCanonicalForm", + "value": ["Backslash", "Principal"] + } + ] + } + }, + "ldapAccountDomainNameShort": { + "visible": { + "conditionGroup": [ + { + "type": "in", + "attribute": "ldapAccountCanonicalForm", + "value": ["Backslash", "Principal"] + } + ] + } + }, + "ldapUserTitleAttribute": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapUserFirstNameAttribute": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapUserLastNameAttribute": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapUserEmailAddressAttribute": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapUserPhoneNumberAttribute": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapUserTeams": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapUserDefaultTeam": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapCreateEspoUser" + } + ] + } + }, + "ldapPortalUserPortals": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapPortalUserLdapAuth" + } + ] + } + }, + "ldapPortalUserRoles": { + "visible": { + "conditionGroup": [ + { + "type": "isTrue", + "attribute": "ldapPortalUserLdapAuth" + } + ] + } + } + } + } + } +} \ No newline at end of file diff --git a/client/src/views/admin/authentication.js b/client/src/views/admin/authentication.js index 964b8123c3..baaba3dcd2 100644 --- a/client/src/views/admin/authentication.js +++ b/client/src/views/admin/authentication.js @@ -26,136 +26,81 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/admin/authentication', 'views/settings/record/edit', function (Dep) { +define('views/admin/authentication', 'views/settings/record/edit', function (Dep) { return Dep.extend({ layoutName: 'authentication', - dependencyDefs: { - 'ldapAuth': { - map: { - true: [ - { - action: 'show', - fields: ['ldapUsername', 'ldapPassword', 'testConnection'] - } - ] - }, - default: [ - { - action: 'hide', - fields: ['ldapUsername', 'ldapPassword', 'testConnection'] - } - ] - }, - 'ldapAccountCanonicalForm': { - map: { - 'Backslash': [ - { - action: 'show', - fields: ['ldapAccountDomainName', 'ldapAccountDomainNameShort'] - } - ], - 'Principal': [ - { - action: 'show', - fields: ['ldapAccountDomainName', 'ldapAccountDomainNameShort'] - } - ] - }, - default: [ - { - action: 'hide', - fields: ['ldapAccountDomainName', 'ldapAccountDomainNameShort'] - } - ] - }, - 'ldapCreateEspoUser': { - map: { - true: [ - { - action: 'show', - fields: ['ldapUserTitleAttribute', 'ldapUserFirstNameAttribute', 'ldapUserLastNameAttribute', 'ldapUserEmailAddressAttribute', 'ldapUserPhoneNumberAttribute', 'ldapUserTeams', 'ldapUserDefaultTeam'] - } - ] - }, - default: [ - { - action: 'hide', - fields: ['ldapUserTitleAttribute', 'ldapUserFirstNameAttribute', 'ldapUserLastNameAttribute', 'ldapUserEmailAddressAttribute', 'ldapUserPhoneNumberAttribute', 'ldapUserTeams', 'ldapUserDefaultTeam'] - } - ] - }, - 'ldapPortalUserLdapAuth': { - map: { - true: [ - { - action: 'show', - fields: ['ldapPortalUserPortals', 'ldapPortalUserRoles'] - } - ] - }, - default: [ - { - action: 'hide', - fields: ['ldapPortalUserPortals', 'ldapPortalUserRoles'] - } - ] - } - }, - setup: function () { - Dep.prototype.setup.call(this); - this.methodList = this.getMetadata().get('entityDefs.Settings.fields.authenticationMethod.options') || []; - this.authFields = { - 'LDAP': [ - 'ldapHost', 'ldapPort', 'ldapAuth', 'ldapSecurity', - 'ldapUsername', 'ldapPassword', 'ldapBindRequiresDn', - 'ldapUserLoginFilter', 'ldapBaseDn', 'ldapAccountCanonicalForm', - 'ldapAccountDomainName', 'ldapAccountDomainNameShort', 'ldapAccountDomainName', - 'ldapAccountDomainNameShort', 'ldapTryUsernameSplit', 'ldapOptReferrals', - 'ldapCreateEspoUser', 'ldapPortalUserLdapAuth' - ] - }; + this.authFields = {}; + + Dep.prototype.setup.call(this); this.handlePanelsVisibility(); - }, - - - afterRender: function () { this.listenTo(this.model, 'change:authenticationMethod', function () { this.handlePanelsVisibility(); }, this); }, + setupBeforeFinal: function () { + this.dynamicLogicDefs = { + fields: {}, + panels: {}, + }; + + this.methodList.forEach(function (method) { + var fieldList = this.getMetadata().get(['authenticationMethods', method, 'settings', 'fieldList']); + if (fieldList) { + this.authFields[method] = fieldList; + } + var mDynamicLogicFieldsDefs = this.getMetadata().get(['authenticationMethods', method, 'settings', 'dynamicLogic', 'fields']); + if (mDynamicLogicFieldsDefs) { + for (var f in mDynamicLogicFieldsDefs) { + this.dynamicLogicDefs.fields[f] = Espo.Utils.cloneDeep(mDynamicLogicFieldsDefs[f]); + } + } + }, this); + + Dep.prototype.setupBeforeFinal.call(this); + }, + + modifyDetailLayout: function (layout) { + this.methodList.forEach(function (method) { + var mLayout = this.getMetadata().get(['authenticationMethods', method, 'settings', 'layout']); + if (mLayout) { + mLayout = Espo.Utils.cloneDeep(mLayout); + mLayout.name = method; + layout.push(mLayout); + } + }, this); + }, + handlePanelsVisibility: function () { var authenticationMethod = this.model.get('authenticationMethod'); this.methodList.forEach(function (method) { - var list = (this.authFields[method] || []); + var fieldList = (this.authFields[method] || []); + if (method != authenticationMethod) { this.hidePanel(method); - list.forEach(function (field) { + + fieldList.forEach(function (field) { this.hideField(field); }, this); } else { this.showPanel(method); - list.forEach(function (field) { + fieldList.forEach(function (field) { this.showField(field); }, this); - Object.keys(this.dependencyDefs || {}).forEach(function (attr) { - if (~list.indexOf(attr)) { - this._handleDependencyAttribute(attr); - } - }, this); + + this.processDynamicLogic(); } }, this); }, }); - }); diff --git a/client/src/views/record/detail.js b/client/src/views/record/detail.js index d852e110d0..aa26d2e91b 100644 --- a/client/src/views/record/detail.js +++ b/client/src/views/record/detail.js @@ -1369,6 +1369,10 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct } this._helper.layoutManager.get(this.model.name, this.layoutName, function (simpleLayout) { + if (typeof this.modifyDetailLayout == 'function') { + var simpleLayout = Espo.Utils.cloneDeep(simpleLayout); + this.modifyDetailLayout(simpleLayout); + } this.gridLayout = { type: gridLayoutType, layout: this.convertDetailLayout(simpleLayout)