Skip to content

[MNOE-616] Impac- Selection of currencies#334

Open
enizor wants to merge 4 commits into
maestrano:2.0from
enizor:mnoe-616
Open

[MNOE-616] Impac- Selection of currencies#334
enizor wants to merge 4 commits into
maestrano:2.0from
enizor:mnoe-616

Conversation

@enizor

@enizor enizor commented Sep 21, 2017

Copy link
Copy Markdown
Contributor

In Account => Currencies, the user is able to choose which currencies will appear on the Impac dropdown, and the default currency for created dashboards.

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 alexnoox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to do this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

angular.module 'mnoEnterpriseAngular'
.component('dashboardCurrencySelection', {
templateUrl: 'app/components/dashboard-currency-select/dashboard-currency-select.html',
controllerAs: "currencySelectCtrl"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty space before (c)

controller: (MnoeCurrentUser, DASHBOARD_CONFIG) ->
vm = this
isSelected = (currency) ->
currency.selected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be on one line

# 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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty space before (c)

Comment thread src/locales/en.json
"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 ",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty space in locale

<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="">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty style=""

@alexnoox alexnoox requested a review from ouranos October 19, 2017 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants