[MNOE-616] Impac- Selection of currencies#334
Open
enizor wants to merge 4 commits into
Open
Conversation
It allows the user to have other settings (working on default_widget_currency and currencies)
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.
alexnoox
suggested changes
Sep 28, 2017
alexnoox
left a comment
Contributor
There was a problem hiding this comment.
Please change the dashboard-currency-select directive to a component (https://docs.angularjs.org/guide/component)
| 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. |
Contributor
There was a problem hiding this comment.
Why do you need to do this?
Contributor
Author
There was a problem hiding this comment.
The previous call would reset the whole settings settings attribute. Same logic is applied on the currency settings save action. I don't really understand how it could be improved, except by creating an API call for settings modification
alexnoox
suggested changes
Oct 19, 2017
| angular.module 'mnoEnterpriseAngular' | ||
| .component('dashboardCurrencySelection', { | ||
| templateUrl: 'app/components/dashboard-currency-select/dashboard-currency-select.html', | ||
| controllerAs: "currencySelectCtrl" |
Contributor
There was a problem hiding this comment.
Remove this configuration and use $ctrl in the template
| isSelected = (currency) -> | ||
| currency.selected | ||
| # List of availables currencies | ||
| vm.currencies = DASHBOARD_CONFIG.impac.currencies.replace(/ /g,'').split(",").map( (c) -> { id: c, selected: true }) |
Contributor
There was a problem hiding this comment.
Remove empty space before (c)
| controller: (MnoeCurrentUser, DASHBOARD_CONFIG) -> | ||
| vm = this | ||
| isSelected = (currency) -> | ||
| currency.selected |
| # Is there at least one currency in common with the user' settings? | ||
| 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 | ||
| vm.currencies.map( (c) -> c.selected = MnoeCurrentUser.user.settings.currencies.includes(c.id)) |
Contributor
There was a problem hiding this comment.
Remove empty space before (c)
| "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 ", |
| <label>{{ 'mno_enterprise.templates.components.currency_select.checkbox' | translate }}</label> | ||
| <div ng-repeat="currency in currencySelectCtrl.currencies"> | ||
| <label> | ||
| <input type="checkbox" ng-model="currency.selected" style=""> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Account => Currencies, the user is able to choose which currencies will appear on the Impac dropdown, and the default currency for created dashboards.