Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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

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

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

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


# Initialization of the default currency
if MnoeCurrentUser.user.settings?.default_dashboard_currency?
# Case the user has set his default, verify it is available
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
vm.defaultCurrency = vm.currencies.find( (c) -> c.selected ) 

vm.changeCurrencyList = () ->
MnoeCurrentUser.update(
settings: Object.assign(MnoeCurrentUser.user.settings,
currencies: vm.currencies.filter(isSelected).map((c) -> c.id),
default_dashboard_currency: vm.defaultCurrency.id))
return
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="form-group">
<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=""

{{currency.id}}
</label>
</div>
</div>

<div class="form-group">
<label class="control-label" for="currency-select">
{{ 'mno_enterprise.templates.components.currency_select.selectbox' | translate }}
</label>
<select id="currency-select" class="form-control" ng-model="currencySelectCtrl.defaultCurrency" ng-change="currencySelectCtrl.changeCurrency()" ng-options="currency.id for currency in currencySelectCtrl.currencies | filter:{selected:true}">
</select>
</div>

<button class="btn btn-warning" type="button" ng-disabled="(currencySelectCtrl.defaultCurrency == null)" ng-click="currencySelectCtrl.changeCurrencyList()">Save</button>
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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


MnoConfirm.showModal(modalOptions).then(
->
Expand Down
4 changes: 4 additions & 0 deletions src/app/views/account/account.controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ angular.module 'mnoEnterpriseAngular'
vm.isLocalizationVisible = I18N_CONFIG.enabled
vm.isLocalizationOpen = false

# ----------------------------------------------------
# Currency selection section
# ----------------------------------------------------
vm.isCurrencySectionOpen = false
# ----------------------------------------------------
# Developer Section
# ----------------------------------------------------
Expand Down
12 changes: 11 additions & 1 deletion src/app/views/account/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,21 @@ <h2 class="section-title">{{ 'mno_enterprise.templates.dashboard.account.my_acco
-->
<div uib-accordion-group ng-if="vm.isLocalizationVisible" is-open="vm.isLocalizationOpen">
<div uib-accordion-heading>
{{ 'mno_enterprise.templates.dashboard.account.settings' | translate }} <span class="fa pull-right" ng-class="{'fa-caret-down': !vm.isLocalizationOpen, 'fa-caret-up': vm.isLocalizationOpen}"></span>
{{ 'mno_enterprise.templates.dashboard.account.locale' | translate }} <span class="fa pull-right" ng-class="{'fa-caret-down': !vm.isLocalizationOpen, 'fa-caret-up': vm.isLocalizationOpen}"></span>
</div>
<dashboard-language-selectbox></dashboard-language-selectbox>
</div>

<!--
Dashboard Currencies Section
-->
<div uib-accordion-group ng-if="vm.isLocalizationVisible" is-open="vm.isCurrencySectionOpen">
<div uib-accordion-heading>
{{ 'mno_enterprise.templates.dashboard.account.currencies' | translate }} <span class="fa pull-right" ng-class="{'fa-caret-down': !vm.isCurrencySectionOpen, 'fa-caret-up': vm.isCurrencySectionOpen}"></span>
</div>
<dashboard-currency-selection></dashboard-currency-selection>
</div>

<!--
Authorize Admin Access Section
-->
Expand Down
5 changes: 4 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",

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

"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",
Expand Down Expand Up @@ -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.",
Expand Down