From 70c2992282e2cd9a1a7c9488a9c9d8eb2c706deb Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 5 Aug 2015 12:35:57 +0300 Subject: [PATCH] theme in preferences --- application/Espo/Core/Controllers/Record.php | 2 +- application/Espo/Core/defaults/config.php | 2 +- .../Espo/Resources/i18n/de_DE/Settings.json | 4 +- .../Espo/Resources/i18n/en_US/Global.json | 3 +- .../Resources/i18n/en_US/Preferences.json | 3 +- .../Espo/Resources/i18n/en_US/Settings.json | 7 +- .../Espo/Resources/i18n/es_ES/Settings.json | 16 ++--- .../Espo/Resources/i18n/fr_FR/Settings.json | 4 +- .../Espo/Resources/i18n/nl_NL/Settings.json | 4 +- .../Espo/Resources/i18n/pl_PL/Settings.json | 2 +- .../Espo/Resources/i18n/pt_BR/Settings.json | 4 +- .../Espo/Resources/i18n/ro_RO/Settings.json | 2 +- .../Espo/Resources/i18n/ru_RU/Settings.json | 2 +- .../Espo/Resources/i18n/uk_UA/Settings.json | 4 +- .../Espo/Resources/i18n/vi_VN/Settings.json | 2 +- .../Resources/layouts/Preferences/detail.json | 4 ++ .../Resources/layouts/Settings/settings.json | 2 +- .../layouts/Settings/userInterface.json | 4 +- .../metadata/entityDefs/Preferences.json | 5 ++ .../metadata/entityDefs/Settings.json | 10 +-- frontend/client/src/app.js | 12 +++- frontend/client/src/theme-manager.js | 70 +++++++++++++++++++ frontend/client/src/view.js | 6 ++ .../src/views/fields/user-with-avatar.js | 2 +- .../src/views/notifications/notification.js | 2 +- .../src/views/preferences/fields/theme.js | 40 +++++++++++ .../src/views/preferences/record/edit.js | 4 ++ frontend/client/src/views/record/detail.js | 7 +- frontend/client/src/views/record/list.js | 4 +- frontend/client/src/views/site/navbar.js | 7 +- frontend/client/src/views/stream/note.js | 2 +- frontend/client/src/views/user/fields/name.js | 6 +- frontend/html/main.html | 2 +- frontend/main.html | 2 +- 34 files changed, 194 insertions(+), 58 deletions(-) create mode 100644 frontend/client/src/theme-manager.js create mode 100644 frontend/client/src/views/preferences/fields/theme.js diff --git a/application/Espo/Core/Controllers/Record.php b/application/Espo/Core/Controllers/Record.php index b1cf4b7e8f..8e05e8dae2 100644 --- a/application/Espo/Core/Controllers/Record.php +++ b/application/Espo/Core/Controllers/Record.php @@ -198,7 +198,7 @@ class Record extends Base public function actionExport($params, $data, $request) { - if ($this->getConfig()->get('disableExport') && !$this->getUser()->isAdmin()) { + if ($this->getConfig()->get('exportDisabled') && !$this->getUser()->isAdmin()) { throw new Forbidden(); } diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index d145c6a8d2..8ba084813e 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -91,7 +91,7 @@ return array ( "tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Email", "Document", "Campaign"), "quickCreateList" => array("Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case"), 'calendarDefaultEntity' => 'Meeting', - 'disableExport' => false, + 'exportDisabled' => false, 'assignmentEmailNotifications' => false, 'assignmentEmailNotificationsEntityList' => array('Lead', 'Opportunity', 'Task', 'Case'), 'assignmentNotificationsEntityList' => array('Meeting', 'Call', 'Task', 'Email'), diff --git a/application/Espo/Resources/i18n/de_DE/Settings.json b/application/Espo/Resources/i18n/de_DE/Settings.json index dc382ed3b0..439afeb2db 100644 --- a/application/Espo/Resources/i18n/de_DE/Settings.json +++ b/application/Espo/Resources/i18n/de_DE/Settings.json @@ -45,12 +45,12 @@ "ldapUserLoginFilter": "Login Filter benutzen", "ldapAccountDomainNameShort": "Domain Name Konto kurz", "ldapOptReferrals": "Opt Referrals", - "disableExport": "Export deaktivieren (nur Admin ist berechtigt)", + "exportDisabled": "Export deaktivieren (nur Admin ist berechtigt)", "assignmentNotificationsEntityList": "Entitäten über die bei Zuweisung benachrichtigt werden soll", "assignmentEmailNotifications": "E-Mail Nachrichten bei Zuweisungen senden", "assignmentEmailNotificationsEntityList": "Entitäten über die mit E-Mail bei Zuweisung benachrichtigt werden soll", "b2cMode": "B2C Modus", - "disableAvatars": "Avatare deaktivieren", + "avatarsDisabled": "Avatare deaktivieren", "followCreatedEntities": "Erstellten Einträgen beobachten" }, "options": { diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index 41df221e99..29926bac27 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -160,7 +160,8 @@ "Tree View": "Tree View", "Unlink All": "Unlink All", "Total": "Total", - "Print to PDF": "Print to PDF" + "Print to PDF": "Print to PDF", + "Default": "Default" }, "messages": { "pleaseWait": "Please wait...", diff --git a/application/Espo/Resources/i18n/en_US/Preferences.json b/application/Espo/Resources/i18n/en_US/Preferences.json index 60be2982e1..3c0c3ef8ba 100644 --- a/application/Espo/Resources/i18n/en_US/Preferences.json +++ b/application/Espo/Resources/i18n/en_US/Preferences.json @@ -22,7 +22,8 @@ "autoFollowEntityTypeList": "Auto-Follow", "signature": "Email Signature", "dashboardTabList": "Tab List", - "defaultReminders": "Default Reminders" + "defaultReminders": "Default Reminders", + "theme": "Theme" }, "links": { }, diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index e0783d52a5..4ef9ed261c 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -45,15 +45,16 @@ "ldapUserLoginFilter": "User Login Filter", "ldapAccountDomainNameShort": "Account Domain Name Short", "ldapOptReferrals": "Opt Referrals", - "disableExport": "Disable Export (only admin is allowed)", + "exportDisabled": "Disable Export (only admin is allowed)", "assignmentNotificationsEntityList": "Entities to Notify about upon Assignment", "assignmentEmailNotifications": "Send Email Notifications upon Assignment", "assignmentEmailNotificationsEntityList": "Entities to Notify about with Email upon Assignment", "b2cMode": "B2C Mode", - "disableAvatars": "Disable Avatars", + "avatarsDisabled": "Disable Avatars", "followCreatedEntities": "Follow Created Entities", "displayListViewRecordCount": "Display Total Count (on List View)", - "theme": "Theme" + "theme": "Theme", + "userThemesDisabled": "Disable User Themes" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/i18n/es_ES/Settings.json b/application/Espo/Resources/i18n/es_ES/Settings.json index 61a14c25e5..13fa245b98 100644 --- a/application/Espo/Resources/i18n/es_ES/Settings.json +++ b/application/Espo/Resources/i18n/es_ES/Settings.json @@ -10,12 +10,12 @@ "defaultCurrency": "Moneda por Defecto", "baseCurrency": "Moneda Base", "currencyRates": "Valores Tarifa", - + "currencyList": "Lista de Moneda", "language": "Idioma", - + "companyLogo": "Logo Compañia", - + "smtpServer": "Servidor", "smtpPort": "Puerto", "smtpAuth": "Autenticación", @@ -26,14 +26,14 @@ "outboundEmailFromName": "De Nombre", "outboundEmailFromAddress": "De la dirección", "outboundEmailIsShared": "Es Compartido", - + "recordsPerPage": "Registros por Página", - "recordsPerPageSmall": "Registros Por Página (Pequeño)", + "recordsPerPageSmall": "Registros Por Página (Pequeño)", "tabList": "Lista Pestaña", "quickCreateList": "Crear Lista Rápida", - + "exportDelimiter": "Exportar Delimitador", - + "authenticationMethod": "Método de Autentificación", "ldapHost": "Host", "ldapPort": "Puerto", @@ -50,7 +50,7 @@ "ldapUserLoginFilter": "Usar Filtro en el Login", "ldapAccountDomainNameShort": "Nombre Dominio Corto para la Cuenta", "ldapOptReferrals": "Referencias Opt", - "disableExport": "Desactivar Exportar (Solo admin está permitido)", + "exportDisabled": "Desactivar Exportar (Solo admin está permitido)", "assignmentEmailNotifications": "Enviar Correos Electrónicos de notificación sobre Asignación", "assignmentEmailNotificationsEntityList": "Entidades a Notificar" }, diff --git a/application/Espo/Resources/i18n/fr_FR/Settings.json b/application/Espo/Resources/i18n/fr_FR/Settings.json index 0cf913523e..e1bb52c44c 100644 --- a/application/Espo/Resources/i18n/fr_FR/Settings.json +++ b/application/Espo/Resources/i18n/fr_FR/Settings.json @@ -52,12 +52,12 @@ "ldapUserLoginFilter": "Filtre des Connexions utilisateur", "ldapAccountDomainNameShort": "Compte du nom de domaine réduit", "ldapOptReferrals": "Abonnés parrainés", - "disableExport": "Désactiver l'Export (seul l'administrateur pourra le faire)", + "exportDisabled": "Désactiver l'Export (seul l'administrateur pourra le faire)", "assignmentNotificationsEntityList": "Entités à prévenir lors d'affectations", "assignmentEmailNotifications": "Envoyer des notifications emal lors d'affectations", "assignmentEmailNotificationsEntityList": "Entités à notifier par email lors d'affectations", "b2cMode": "Mode B2C", - "disableAvatars": "Désactiver les Avatars" + "avatarsDisabled": "Désactiver les Avatars" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/i18n/nl_NL/Settings.json b/application/Espo/Resources/i18n/nl_NL/Settings.json index 5d21dc5cf7..09d66ef04e 100644 --- a/application/Espo/Resources/i18n/nl_NL/Settings.json +++ b/application/Espo/Resources/i18n/nl_NL/Settings.json @@ -50,11 +50,11 @@ "ldapUserLoginFilter": "Gebruikers Login Filter", "ldapAccountDomainNameShort": "Korte Gebruikers Domein Naam", "ldapOptReferrals": "Opt Referentie", - "disableExport": "Exporteren Uitschakelen (Uitsluitend toegestaan voor Admin)", + "exportDisabled": "Exporteren Uitschakelen (Uitsluitend toegestaan voor Admin)", "assignmentEmailNotifications": "Verzend Email na Toewijzing", "assignmentEmailNotificationsEntityList": "Entities om over te informeren", "b2cMode": "B2C Mode", - "disableAvatars": "Avatar uitschakelen" + "avatarsDisabled": "Avatar uitschakelen" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/i18n/pl_PL/Settings.json b/application/Espo/Resources/i18n/pl_PL/Settings.json index dc57ae874c..98ee1552fa 100644 --- a/application/Espo/Resources/i18n/pl_PL/Settings.json +++ b/application/Espo/Resources/i18n/pl_PL/Settings.json @@ -50,7 +50,7 @@ "ldapUserLoginFilter": "Filtr użytkoników ", "ldapAccountDomainNameShort": "Krótka nazwa konta domeny", "ldapOptReferrals": "Opt Referrals", - "disableExport": "Disable Export (only admin is allowed)", + "exportDisabled": "Disable Export (only admin is allowed)", "assignmentEmailNotifications": "Wyślij powiadominie do użytkonika o przypisaniu", "assignmentEmailNotificationsEntityList": "Entities to Notify About" }, diff --git a/application/Espo/Resources/i18n/pt_BR/Settings.json b/application/Espo/Resources/i18n/pt_BR/Settings.json index 1bb4866183..6be0430660 100644 --- a/application/Espo/Resources/i18n/pt_BR/Settings.json +++ b/application/Espo/Resources/i18n/pt_BR/Settings.json @@ -52,11 +52,11 @@ "ldapUserLoginFilter": "Filtro para Login de Usuário", "ldapAccountDomainNameShort": "Nome curto do Domínio da Conta", "ldapOptReferrals": "Referências Opt", - "disableExport": "Desabilitar exportação (permitido apenas para administradores)", + "exportDisabled": "Desabilitar exportação (permitido apenas para administradores)", "assignmentEmailNotifications": "Enviar notificações sobre as designações por e-mail", "assignmentEmailNotificationsEntityList": "Entidades para notificar", "b2cMode": "Modo B2C", - "disableAvatars": "Desabilitar Avatares" + "avatarsDisabled": "Desabilitar Avatares" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/i18n/ro_RO/Settings.json b/application/Espo/Resources/i18n/ro_RO/Settings.json index 3168ac0798..3db719879e 100644 --- a/application/Espo/Resources/i18n/ro_RO/Settings.json +++ b/application/Espo/Resources/i18n/ro_RO/Settings.json @@ -47,7 +47,7 @@ "ldapUserLoginFilter": "User Login Filter", "ldapAccountDomainNameShort": "Account Domain Name Short", "ldapOptReferrals": "Opt Referrals", - "disableExport": "Disable Export (only admin is allowed)" + "exportDisabled": "Disable Export (only admin is allowed)" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/i18n/ru_RU/Settings.json b/application/Espo/Resources/i18n/ru_RU/Settings.json index e06cc1a774..651cd46d14 100644 --- a/application/Espo/Resources/i18n/ru_RU/Settings.json +++ b/application/Espo/Resources/i18n/ru_RU/Settings.json @@ -50,7 +50,7 @@ "ldapUserLoginFilter": "Фильтер пользовательской авторизации", "ldapAccountDomainNameShort": "Краткая учетная запись домена", "ldapOptReferrals": "Opt Referrals", - "disableExport": "Отмена экпортирования (доступно только администратору)", + "exportDisabled": "Отмена экпортирования (доступно только администратору)", "assignmentEmailNotifications": "Оповещать по email при назначении", "assignmentEmailNotificationsEntityList": "Список вещей для оповещения", diff --git a/application/Espo/Resources/i18n/uk_UA/Settings.json b/application/Espo/Resources/i18n/uk_UA/Settings.json index d09b442ef8..2107a1441a 100644 --- a/application/Espo/Resources/i18n/uk_UA/Settings.json +++ b/application/Espo/Resources/i18n/uk_UA/Settings.json @@ -45,12 +45,12 @@ "ldapUserLoginFilter": "Фільтр логіну користувача", "ldapAccountDomainNameShort": "Account Domain Name Short", "ldapOptReferrals": "Оптові реферали", - "disableExport": "Вимкнути експортування (доступно лише адміністру)", + "exportDisabled": "Вимкнути експортування (доступно лише адміністру)", "assignmentNotificationsEntityList": "Entities to Notify about upon Assignment", "assignmentEmailNotifications": "Посилати сповіщення на емейл при назначенні", "assignmentEmailNotificationsEntityList": "Entities to Notify about with Email upon Assignment", "b2cMode": "Режим В2С", - "disableAvatars": "Вимкнути аватари", + "avatarsDisabled": "Вимкнути аватари", "followCreatedEntities": "Follow Created Entities" }, "options": { diff --git a/application/Espo/Resources/i18n/vi_VN/Settings.json b/application/Espo/Resources/i18n/vi_VN/Settings.json index 5b39e4e29a..22eaf37c58 100644 --- a/application/Espo/Resources/i18n/vi_VN/Settings.json +++ b/application/Espo/Resources/i18n/vi_VN/Settings.json @@ -47,7 +47,7 @@ "ldapUserLoginFilter": "Bộ lọc đăng nhập", "ldapAccountDomainNameShort": "Tên miền tài khoản", "ldapOptReferrals": "Được giới thiệu", - "disableExport": "Disable Export (only admin is allowed)" + "exportDisabled": "Disable Export (only admin is allowed)" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/layouts/Preferences/detail.json b/application/Espo/Resources/layouts/Preferences/detail.json index 552a1ad9ab..71386d9baf 100644 --- a/application/Espo/Resources/layouts/Preferences/detail.json +++ b/application/Espo/Resources/layouts/Preferences/detail.json @@ -43,6 +43,10 @@ { "name": "defaultReminders" } + ], + [ + {"name":"theme"}, + false ] ] }, diff --git a/application/Espo/Resources/layouts/Settings/settings.json b/application/Espo/Resources/layouts/Settings/settings.json index b6a29d1f73..8b179c1891 100644 --- a/application/Espo/Resources/layouts/Settings/settings.json +++ b/application/Espo/Resources/layouts/Settings/settings.json @@ -3,7 +3,7 @@ "label": "System", "rows": [ [{"name": "useCache"},{"name": "companyLogo"}], - [{"name": "disableExport"},{"name": "globalSearchEntityList"}], + [{"name": "exportDisabled"},{"name": "globalSearchEntityList"}], [{"name": "followCreatedEntities"}, false] ] }, diff --git a/application/Espo/Resources/layouts/Settings/userInterface.json b/application/Espo/Resources/layouts/Settings/userInterface.json index c78067d324..8d937ff930 100644 --- a/application/Espo/Resources/layouts/Settings/userInterface.json +++ b/application/Espo/Resources/layouts/Settings/userInterface.json @@ -2,9 +2,9 @@ { "label": "Configuration", "rows": [ - [{"name": "theme"}, {"name": "disableAvatars"}], + [{"name": "theme"}, {"name": "userThemesDisabled"}], [{"name": "recordsPerPage"},{"name": "displayListViewRecordCount"}], - [{"name": "recordsPerPageSmall"},false], + [{"name": "recordsPerPageSmall"},{"name": "avatarsDisabled"}], [{"name": "tabList"},{"name": "quickCreateList"}] ] } diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index a6173d95ce..d67f280927 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -102,6 +102,11 @@ "defaultReminders": { "type": "jsonArray", "view": "Crm:Meeting.Fields.Reminders" + }, + "theme": { + "type": "enum", + "view": "Preferences.Fields.Theme", + "translation": "Global.themes" } } } diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index f71bd40081..64f42956c7 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -202,7 +202,7 @@ "type": "bool", "default": true }, - "disableExport": { + "exportDisabled": { "type": "bool", "default": false }, @@ -224,7 +224,7 @@ "type": "bool", "default": false }, - "disableAvatars": { + "avatarsDisabled": { "type": "bool", "default": false }, @@ -239,11 +239,13 @@ "displayListViewRecordCount": { "type": "bool" }, + "userThemesDisabled": { + "type": "bool" + }, "theme": { "type": "enum", "view": "Settings.Fields.Theme", - "translation": "Global.themes", - "isSorted": true + "translation": "Global.themes" } } } diff --git a/frontend/client/src/app.js b/frontend/client/src/app.js index e973438c34..4c484cac3b 100644 --- a/frontend/client/src/app.js +++ b/frontend/client/src/app.js @@ -22,8 +22,8 @@ Espo.define( 'app', - ['ui', 'utils', 'acl', 'cache', 'storage', 'models/settings', 'language', 'metadata', 'field-manager', 'models/user', 'models/preferences', 'model-factory' ,'collection-factory', 'pre-loader', 'view-helper', 'controllers/base', 'router', 'date-time', 'layout-manager'], - function (Ui, Utils, Acl, Cache, Storage, Settings, Language, Metadata, FieldManager, User, Preferences, ModelFactory, CollectionFactory, PreLoader, ViewHelper, BaseController, Router, DateTime, LayoutManager) { + ['ui', 'utils', 'acl', 'cache', 'storage', 'models/settings', 'language', 'metadata', 'field-manager', 'models/user', 'models/preferences', 'model-factory' ,'collection-factory', 'pre-loader', 'view-helper', 'controllers/base', 'router', 'date-time', 'layout-manager', 'theme-manager'], + function (Ui, Utils, Acl, Cache, Storage, Settings, Language, Metadata, FieldManager, User, Preferences, ModelFactory, CollectionFactory, PreLoader, ViewHelper, BaseController, Router, DateTime, LayoutManager, ThemeManager) { var App = function (options, callback) { var options = options || {}; @@ -61,6 +61,8 @@ Espo.define( this.preferences.settings = this.settings; this.acl = new Acl(this.user); + this.themeManager = new ThemeManager(this.settings, this.preferences, this.metadata); + this._modelFactory = new ModelFactory(this.loader, this.metadata, this.user); this._collectionFactory = new CollectionFactory(this.loader, this._modelFactory); @@ -68,7 +70,7 @@ Espo.define( this._initView(); this._initBaseController(); - this._preLoader = new PreLoader(this.cache, this._viewFactory); + this._preLoader = new PreLoader(this.cache, this._viewFactory, this.themeManager); this._preLoad(function () { callback.call(this, this); @@ -135,6 +137,9 @@ Espo.define( this.user.defs = this.metadata.get('entityDefs.User'); this.preferences.defs = this.metadata.get('entityDefs.Preferences'); + if (this.themeManager.isUserTheme()) { + $('#main-stylesheet').attr('href', this.themeManager.getStylesheet()); + } this.loader.addLibsConfig(this.metadata.get('app.jsLibs') || {}); @@ -267,6 +272,7 @@ Espo.define( helper.fieldManager = this.fieldManager; helper.cache = this.cache; helper.storage = this.storage; + helper.themeManager = this.themeManager; this._viewLoader = function (viewName, callback) { Espo.require(Espo.Utils.composeViewClassName(viewName), callback); diff --git a/frontend/client/src/theme-manager.js b/frontend/client/src/theme-manager.js new file mode 100644 index 0000000000..736e86cfcc --- /dev/null +++ b/frontend/client/src/theme-manager.js @@ -0,0 +1,70 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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/. + ************************************************************************/ +Espo.define('theme-manager', [], function () { + + var ThemeManager = function (config, preferences, metadata) { + this.config = config; + this.preferences = preferences; + this.metadata = metadata; + + /*this.preferences.on('change:theme', function () { + if (this.getStylesheet() && this.isUserTheme()) { + $('#main-stylesheet').attr('href', this.getStylesheet()); + } + }, this);*/ + }; + + _.extend(ThemeManager.prototype, { + + getName: function () { + if (!this.config.get('userThemesDisabled')) { + var name = this.preferences.get('theme'); + if (name && name !== '') { + return name; + } + } + return this.config.get('name'); + }, + + getStylesheet: function () { + return this.metadata.get('themes.' + this.getName() + '.stylesheet') || 'client/css/espo.css'; + }, + + getParam: function (name) { + return this.metadata.get('themes.' + this.getName() + '.' + name) || null; + }, + + isUserTheme: function () { + if (!this.config.get('userThemesDisabled')) { + var name = this.preferences.get('theme'); + if (name && name !== '') { + if (name !== this.config.get('theme')) { + return true; + } + } + } + } + + }); + + return ThemeManager; + +}); diff --git a/frontend/client/src/view.js b/frontend/client/src/view.js index 8f4ce6a327..7dbb4730f9 100644 --- a/frontend/client/src/view.js +++ b/frontend/client/src/view.js @@ -147,6 +147,12 @@ Espo.define('view', [], function () { } }, + getThemeManager: function () { + if (this._helper) { + return this._helper.themeManager; + } + }, + updatePageTitle: function () { var title = this.getConfig().get('applicationTitle') || 'EspoCRM'; this.setPageTitle(title); diff --git a/frontend/client/src/views/fields/user-with-avatar.js b/frontend/client/src/views/fields/user-with-avatar.js index bff522f596..a82a4e789f 100644 --- a/frontend/client/src/views/fields/user-with-avatar.js +++ b/frontend/client/src/views/fields/user-with-avatar.js @@ -36,7 +36,7 @@ Espo.define('Views.Fields.UserWithAvatar', 'Views.Fields.Link', function (Dep) { }, getAvatarHtml: function () { - if (this.getConfig().get('disableAvatars')) { + if (this.getConfig().get('avatarsDisabled')) { return ''; } var t; diff --git a/frontend/client/src/views/notifications/notification.js b/frontend/client/src/views/notifications/notification.js index 53dcc2376c..e39d25d2f9 100644 --- a/frontend/client/src/views/notifications/notification.js +++ b/frontend/client/src/views/notifications/notification.js @@ -70,7 +70,7 @@ Espo.define('Views.Notifications.Notification', 'View', function (Dep) { }, getAvatarHtml: function () { - if (this.getConfig().get('disableAvatars')) { + if (this.getConfig().get('avatarsDisabled')) { return ''; } var t; diff --git a/frontend/client/src/views/preferences/fields/theme.js b/frontend/client/src/views/preferences/fields/theme.js new file mode 100644 index 0000000000..21812821cd --- /dev/null +++ b/frontend/client/src/views/preferences/fields/theme.js @@ -0,0 +1,40 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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/. + ************************************************************************/ +Espo.define('views/preferences/fields/theme', 'views/fields/enum', function (Dep) { + + return Dep.extend({ + + setup: function () { + this.params.options = Object.keys(this.getMetadata().get('themes')).sort(function (v1, v2) { + return this.translate(v1, 'theme').localeCompare(this.translate(v2, 'theme')); + }.bind(this)); + + this.params.options.unshift(''); + + Dep.prototype.setup.call(this); + + this.translatedOptions = this.translatedOptions || {}; + this.translatedOptions[''] = this.translate('Default'); + }, + + }); + +}); diff --git a/frontend/client/src/views/preferences/record/edit.js b/frontend/client/src/views/preferences/record/edit.js index dfdeef6cb8..a182aa0360 100644 --- a/frontend/client/src/views/preferences/record/edit.js +++ b/frontend/client/src/views/preferences/record/edit.js @@ -96,6 +96,10 @@ Espo.define('Views.Preferences.Record.Edit', 'Views.Record.Edit', function (Dep) this.hideField('receiveAssignmentEmailNotifications'); } + if (this.getConfig().get('userThemesDisabled')) { + this.hideField('theme'); + } + var smtpSecurityField = this.getFieldView('smtpSecurity'); this.listenTo(smtpSecurityField, 'change', function () { var smtpSecurity = smtpSecurityField.fetch()['smtpSecurity']; diff --git a/frontend/client/src/views/record/detail.js b/frontend/client/src/views/record/detail.js index 6684729302..0ae562ab22 100644 --- a/frontend/client/src/views/record/detail.js +++ b/frontend/client/src/views/record/detail.js @@ -141,11 +141,8 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) { afterRender: function () { var $container = this.$el.find('.detail-button-container'); - var theme = this.getConfig().get('theme'); - var themeDefs = this.getMetadata().get('themes.' + theme) || {}; - - var stickTop = themeDefs.stickTop || 62; - var blockHeight = themeDefs.blockHeight || 21; + var stickTop = this.getThemeManager().getParam('stickTop') || 62; + var blockHeight = this.getThemeManager().getParam('blockHeight') || 21; var $block = $('
').css('height', blockHeight + 'px').html(' ').hide().insertAfter($container); var $record = this.getView('record').$el; diff --git a/frontend/client/src/views/record/list.js b/frontend/client/src/views/record/list.js index a9e811570a..15f570375c 100644 --- a/frontend/client/src/views/record/list.js +++ b/frontend/client/src/views/record/list.js @@ -446,7 +446,7 @@ Espo.define('Views.Record.List', 'View', function (Dep) { }, massActionExport: function () { - if (!this.getConfig().get('disableExport') || this.getUser().get('isAdmin')) { + if (!this.getConfig().get('exportDisabled') || this.getUser().get('isAdmin')) { this.export(); } }, @@ -476,7 +476,7 @@ Espo.define('Views.Record.List', 'View', function (Dep) { }, this); this.checkAllResultMassActionList = checkAllResultMassActionList; - if (this.getConfig().get('disableExport') && !this.getUser().get('isAdmin')) { + if (this.getConfig().get('exportDisabled') && !this.getUser().get('isAdmin')) { this.removeMassAction('export'); } diff --git a/frontend/client/src/views/site/navbar.js b/frontend/client/src/views/site/navbar.js index f9307b736e..0e624ae436 100644 --- a/frontend/client/src/views/site/navbar.js +++ b/frontend/client/src/views/site/navbar.js @@ -116,10 +116,10 @@ Espo.define('Views.Site.Navbar', 'View', function (Dep) { var self = this; - var theme = this.getConfig().get('theme'); - var themeDefs = this.getMetadata().get('themes.' + theme) || {}; + var navbarIsVertical = this.getThemeManager().getParam('navbarIsVertical'); + var navbarStaticItemsHeight = this.getThemeManager().getParam('navbarStaticItemsHeight') || 0; - if (!themeDefs.navbarIsVertical) { + if (!navbarIsVertical) { var $tabs = this.$el.find('ul.tabs'); var $more = $tabs.find('li.dropdown > ul'); @@ -196,7 +196,6 @@ Espo.define('Views.Site.Navbar', 'View', function (Dep) { } else { var $tabs = this.$el.find('ul.tabs'); - var navbarStaticItemsHeight = themeDefs.navbarStaticItemsHeight || 0; var updateHeight = function () { var windowHeight = window.innerHeight; diff --git a/frontend/client/src/views/stream/note.js b/frontend/client/src/views/stream/note.js index d5c98561ce..ffcb3a92c7 100644 --- a/frontend/client/src/views/stream/note.js +++ b/frontend/client/src/views/stream/note.js @@ -117,7 +117,7 @@ Espo.define('Views.Stream.Note', 'View', function (Dep) { }, getAvatarHtml: function () { - if (this.getConfig().get('disableAvatars')) { + if (this.getConfig().get('avatarsDisabled')) { return ''; } var t; diff --git a/frontend/client/src/views/user/fields/name.js b/frontend/client/src/views/user/fields/name.js index 8e39379a86..8fc389c799 100644 --- a/frontend/client/src/views/user/fields/name.js +++ b/frontend/client/src/views/user/fields/name.js @@ -21,7 +21,7 @@ Espo.define('Views.User.Fields.Name', 'Views.Fields.PersonName', function (Dep) { return Dep.extend({ - + listTemplate: 'user.fields.name.list-link', listLinkTemplate: 'user.fields.name.list-link', @@ -33,7 +33,7 @@ Espo.define('Views.User.Fields.Name', 'Views.Fields.PersonName', function (Dep) }, getAvatarHtml: function () { - if (this.getConfig().get('disableAvatars')) { + if (this.getConfig().get('avatarsDisabled')) { return ''; } var t; @@ -47,5 +47,5 @@ Espo.define('Views.User.Fields.Name', 'Views.Fields.PersonName', function (Dep) }, }); - + }); diff --git a/frontend/html/main.html b/frontend/html/main.html index 6fc7705fa5..cf07a566c8 100644 --- a/frontend/html/main.html +++ b/frontend/html/main.html @@ -3,7 +3,7 @@ EspoCRM - + diff --git a/frontend/main.html b/frontend/main.html index dee3579165..120a774642 100644 --- a/frontend/main.html +++ b/frontend/main.html @@ -26,7 +26,7 @@ - +