From 589c16defa8ef9c4f048f6d3180ad3fb48e1efc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Garde?= Date: Tue, 19 Sep 2017 15:04:42 +1000 Subject: [PATCH 1/4] [MNOE-616] Feat(account/settings): locale does not reset whole settings It allows the user to have other settings (working on default_widget_currency and currencies) --- .../dashboard-language-selectbox.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/dashboard-language-selectbox/dashboard-language-selectbox.coffee b/src/app/components/dashboard-language-selectbox/dashboard-language-selectbox.coffee index eeed956f..3fbdaa90 100644 --- a/src/app/components/dashboard-language-selectbox/dashboard-language-selectbox.coffee +++ b/src/app/components/dashboard-language-selectbox/dashboard-language-selectbox.coffee @@ -31,7 +31,7 @@ angular.module 'mnoEnterpriseAngular' bodyText: 'mno_enterprise.templates.components.language_selectbox.confirm' headerTextExtraData: { name: locale.name } bodyTextExtraData: { name: locale.name } - actionCb: -> MnoeCurrentUser.update(settings: {locale: $scope.selectedLangKey}) + actionCb: -> MnoeCurrentUser.update(settings: Object.assign(MnoeCurrentUser.user.settings, locale: $scope.selectedLangKey)) # WIll destroy the whole previous settings. MnoConfirm.showModal(modalOptions).then( -> From 268837f2074644446b5e6858bdb1e59aa7d360dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Garde?= Date: Thu, 21 Sep 2017 16:50:21 +1000 Subject: [PATCH 2/4] [MNOE-616] Account Settings: currencies selection The currencies list is taken from the config (set in admin panel/general/dashboard) It sets the user.settings.currencies and .default_dashboard_currency attributes. Currently the 'save' button does save the settings but does not load them in the frontend, a refresh is needed. --- .../dashboard-currency-select.coffee | 34 +++++++++++++++++++ .../dashboard-currency-select.html | 19 +++++++++++ .../views/account/account.controller.coffee | 4 +++ src/app/views/account/account.html | 12 ++++++- src/locales/en.json | 5 ++- 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/app/components/dashboard-currency-select/dashboard-currency-select.coffee create mode 100644 src/app/components/dashboard-currency-select/dashboard-currency-select.html diff --git a/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee b/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee new file mode 100644 index 00000000..b84ea81d --- /dev/null +++ b/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee @@ -0,0 +1,34 @@ +angular.module 'mnoEnterpriseAngular' + .directive('dashboardCurrencySelection', -> + return { + restrict: 'EA' + templateUrl:'app/components/dashboard-currency-select/dashboard-currency-select.html' + controller: ($scope, $log, MnoeCurrentUser, DASHBOARD_CONFIG) -> + isSelected = (currency) -> + currency.selected + + # List of availables currencies + $scope.currencies = DASHBOARD_CONFIG.impac.currencies.replace(/ /g,'').split(",").map( (c) -> { id: c, selected: true }) + # Initialization of the selected currencies: match the user settings if possible, else all are selected (see init above) + if MnoeCurrentUser.user.settings?.currencies? + # Is there at least one currency in common with the user' settings? + if $scope.currencies.some((c,i,a) -> MnoeCurrentUser.user.settings.currencies.includes(c.id) ) + # select the intersection of availbale currencies from the tenant and the settings + $scope.currencies.map( (c) -> c.selected = MnoeCurrentUser.user.settings.currencies.includes(c.id)) + + + # Initialization of the default currency + if MnoeCurrentUser.user.settings?.default_dashboard_currency? + # Case the user has set his default, verify it is available + $scope.defaultCurrency = $scope.currencies.find( (c) -> c.id == MnoeCurrentUser.user.settings.default_dashboard_currency && c.selected) || $scope.currencies.find( (c) -> c.selected ) + else + # Otherwise return the first selected currency + $scope.defaultCurrency = $scope.currencies.find( (c) -> c.selected )  + + $scope.changeCurrencyList = () -> + MnoeCurrentUser.update( + settings: Object.assign(MnoeCurrentUser.user.settings, + currencies: $scope.currencies.filter(isSelected).map((c) -> c.id), + default_dashboard_currency: $scope.defaultCurrency.id)) + } + ) diff --git a/src/app/components/dashboard-currency-select/dashboard-currency-select.html b/src/app/components/dashboard-currency-select/dashboard-currency-select.html new file mode 100644 index 00000000..a2c8e68f --- /dev/null +++ b/src/app/components/dashboard-currency-select/dashboard-currency-select.html @@ -0,0 +1,19 @@ +
+ +
+ +
+
+ +
+ + +
+ + diff --git a/src/app/views/account/account.controller.coffee b/src/app/views/account/account.controller.coffee index e4a5b75d..a9b760d7 100644 --- a/src/app/views/account/account.controller.coffee +++ b/src/app/views/account/account.controller.coffee @@ -90,6 +90,10 @@ angular.module 'mnoEnterpriseAngular' vm.isLocalizationVisible = I18N_CONFIG.enabled vm.isLocalizationOpen = false + # ---------------------------------------------------- + # Currency selection section + # ---------------------------------------------------- + vm.isCurrencySectionOpen = false # ---------------------------------------------------- # Developer Section # ---------------------------------------------------- diff --git a/src/app/views/account/account.html b/src/app/views/account/account.html index 39a0a7c1..e6cc7f82 100644 --- a/src/app/views/account/account.html +++ b/src/app/views/account/account.html @@ -144,11 +144,21 @@

{{ 'mno_enterprise.templates.dashboard.account.my_acco -->
- {{ 'mno_enterprise.templates.dashboard.account.settings' | translate }} + {{ 'mno_enterprise.templates.dashboard.account.locale' | translate }}
+ +
+
+ {{ 'mno_enterprise.templates.dashboard.account.currencies' | translate }} +
+ +
+ diff --git a/src/locales/en.json b/src/locales/en.json index 12bafb2e..4c4bdb72 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -809,7 +809,8 @@ "mno_enterprise.templates.dashboard.account.passwd_form_confirm": "Confirm Password", "mno_enterprise.templates.dashboard.account.passwd_form_save": "Save", "mno_enterprise.templates.dashboard.account.passwd_form_cancel": "Cancel", - "mno_enterprise.templates.dashboard.account.settings": "Settings", + "mno_enterprise.templates.dashboard.account.locale": "Locale", + "mno_enterprise.templates.dashboard.account.currencies": "Currencies ", "mno_enterprise.templates.dashboard.account.developer": "Developer", "mno_enterprise.templates.dashboard.account.are_you_developer": "Are you a Developer looking to contribute to the Maestrano platform?", "mno_enterprise.templates.dashboard.account.api_key": "API Key", @@ -931,6 +932,8 @@ "mno_enterprise.templates.components.language_selectbox.change_language": "Change language", "mno_enterprise.templates.components.language_selectbox.confirm_header": "Change language to {name}?", "mno_enterprise.templates.components.language_selectbox.confirm": "Are you sure you want to change language to {name}?", + "mno_enterprise.templates.components.currency_select.checkbox": "Currencies available for dashboards", + "mno_enterprise.templates.components.currency_select.selectbox": "Default currency for dashboards (applies to newly created ones):", "mno_enterprise.pages.app_access_unauthorized.title": "App Access Not Granted", "mno_enterprise.pages.app_access_unauthorized.explanation": "It looks like the administrator of this application has not granted you access.", "mno_enterprise.pages.app_access_unauthorized.recommendation": "You should ask your administrator to share this application with you.", From ad01eb083d8df6280753f1d1a93033c938b75f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Garde?= Date: Thu, 28 Sep 2017 11:46:47 +1000 Subject: [PATCH 3/4] [MNOE-616] Dashboard-currency-select as a component --- .../dashboard-currency-select.coffee | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee b/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee index b84ea81d..d8c1c84a 100644 --- a/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee +++ b/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee @@ -1,34 +1,30 @@ angular.module 'mnoEnterpriseAngular' - .directive('dashboardCurrencySelection', -> - return { - restrict: 'EA' - templateUrl:'app/components/dashboard-currency-select/dashboard-currency-select.html' - controller: ($scope, $log, MnoeCurrentUser, DASHBOARD_CONFIG) -> - isSelected = (currency) -> - currency.selected + .component('dashboardCurrencySelection', { + templateUrl: 'app/components/dashboard-currency-select/dashboard-currency-select.html', + controller: ($scope, MnoeCurrentUser, DASHBOARD_CONFIG) -> + isSelected = (currency) -> + currency.selected - # List of availables currencies - $scope.currencies = DASHBOARD_CONFIG.impac.currencies.replace(/ /g,'').split(",").map( (c) -> { id: c, selected: true }) - # Initialization of the selected currencies: match the user settings if possible, else all are selected (see init above) - if MnoeCurrentUser.user.settings?.currencies? - # Is there at least one currency in common with the user' settings? - if $scope.currencies.some((c,i,a) -> MnoeCurrentUser.user.settings.currencies.includes(c.id) ) - # select the intersection of availbale currencies from the tenant and the settings - $scope.currencies.map( (c) -> c.selected = MnoeCurrentUser.user.settings.currencies.includes(c.id)) + # List of availables currencies + $scope.currencies = DASHBOARD_CONFIG.impac.currencies.replace(/ /g,'').split(",").map( (c) -> { id: c, selected: true }) + # Initialization of the selected currencies: match the user settings if possible, else all are selected (see init above) + if MnoeCurrentUser.user.settings?.currencies? + # Is there at least one currency in common with the user' settings? + if $scope.currencies.some((c,i,a) -> MnoeCurrentUser.user.settings.currencies.includes(c.id) ) + # select the intersection of available currencies from the tenant and the settings + $scope.currencies.map( (c) -> c.selected = MnoeCurrentUser.user.settings.currencies.includes(c.id)) + # Initialization of the default currency + if MnoeCurrentUser.user.settings?.default_dashboard_currency? + # Case the user has set his default, verify it is available + $scope.defaultCurrency = $scope.currencies.find( (c) -> c.id == MnoeCurrentUser.user.settings.default_dashboard_currency && c.selected) || $scope.currencies.find( (c) -> c.selected ) + else + # Otherwise return the first selected currency + $scope.defaultCurrency = $scope.currencies.find( (c) -> c.selected )  - # Initialization of the default currency - if MnoeCurrentUser.user.settings?.default_dashboard_currency? - # Case the user has set his default, verify it is available - $scope.defaultCurrency = $scope.currencies.find( (c) -> c.id == MnoeCurrentUser.user.settings.default_dashboard_currency && c.selected) || $scope.currencies.find( (c) -> c.selected ) - else - # Otherwise return the first selected currency - $scope.defaultCurrency = $scope.currencies.find( (c) -> c.selected )  - - $scope.changeCurrencyList = () -> - MnoeCurrentUser.update( - settings: Object.assign(MnoeCurrentUser.user.settings, - currencies: $scope.currencies.filter(isSelected).map((c) -> c.id), - default_dashboard_currency: $scope.defaultCurrency.id)) - } - ) + $scope.changeCurrencyList = () -> + MnoeCurrentUser.update( + settings: Object.assign(MnoeCurrentUser.user.settings, + currencies: $scope.currencies.filter(isSelected).map((c) -> c.id), + default_dashboard_currency: $scope.defaultCurrency.id)) + }) From f5b6218b6c4ea628d65df622986328a4b746f1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Garde?= Date: Thu, 28 Sep 2017 16:23:04 +1000 Subject: [PATCH 4/4] [MNOE-616] Currency selection: controllerAs instead of $scope --- .../dashboard-currency-select.coffee | 22 ++++++++++--------- .../dashboard-currency-select.html | 6 ++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee b/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee index d8c1c84a..79798073 100644 --- a/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee +++ b/src/app/components/dashboard-currency-select/dashboard-currency-select.coffee @@ -1,30 +1,32 @@ angular.module 'mnoEnterpriseAngular' .component('dashboardCurrencySelection', { templateUrl: 'app/components/dashboard-currency-select/dashboard-currency-select.html', - controller: ($scope, MnoeCurrentUser, DASHBOARD_CONFIG) -> + controllerAs: "currencySelectCtrl" + controller: (MnoeCurrentUser, DASHBOARD_CONFIG) -> + vm = this isSelected = (currency) -> currency.selected - # List of availables currencies - $scope.currencies = DASHBOARD_CONFIG.impac.currencies.replace(/ /g,'').split(",").map( (c) -> { id: c, selected: true }) + vm.currencies = DASHBOARD_CONFIG.impac.currencies.replace(/ /g,'').split(",").map( (c) -> { id: c, selected: true }) # Initialization of the selected currencies: match the user settings if possible, else all are selected (see init above) if MnoeCurrentUser.user.settings?.currencies? # Is there at least one currency in common with the user' settings? - if $scope.currencies.some((c,i,a) -> MnoeCurrentUser.user.settings.currencies.includes(c.id) ) + if vm.currencies.some((c,i,a) -> MnoeCurrentUser.user.settings.currencies.includes(c.id) ) # select the intersection of available currencies from the tenant and the settings - $scope.currencies.map( (c) -> c.selected = MnoeCurrentUser.user.settings.currencies.includes(c.id)) + vm.currencies.map( (c) -> c.selected = MnoeCurrentUser.user.settings.currencies.includes(c.id)) # Initialization of the default currency if MnoeCurrentUser.user.settings?.default_dashboard_currency? # Case the user has set his default, verify it is available - $scope.defaultCurrency = $scope.currencies.find( (c) -> c.id == MnoeCurrentUser.user.settings.default_dashboard_currency && c.selected) || $scope.currencies.find( (c) -> c.selected ) + vm.defaultCurrency = vm.currencies.find( (c) -> c.id == MnoeCurrentUser.user.settings.default_dashboard_currency && c.selected) || vm.currencies.find( (c) -> c.selected ) else # Otherwise return the first selected currency - $scope.defaultCurrency = $scope.currencies.find( (c) -> c.selected )  + vm.defaultCurrency = vm.currencies.find( (c) -> c.selected )  - $scope.changeCurrencyList = () -> + vm.changeCurrencyList = () -> MnoeCurrentUser.update( settings: Object.assign(MnoeCurrentUser.user.settings, - currencies: $scope.currencies.filter(isSelected).map((c) -> c.id), - default_dashboard_currency: $scope.defaultCurrency.id)) + currencies: vm.currencies.filter(isSelected).map((c) -> c.id), + default_dashboard_currency: vm.defaultCurrency.id)) + return }) diff --git a/src/app/components/dashboard-currency-select/dashboard-currency-select.html b/src/app/components/dashboard-currency-select/dashboard-currency-select.html index a2c8e68f..42c42014 100644 --- a/src/app/components/dashboard-currency-select/dashboard-currency-select.html +++ b/src/app/components/dashboard-currency-select/dashboard-currency-select.html @@ -1,6 +1,6 @@
-
+
- +