|
@@ -260,74 +260,78 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, {
|
|
|
* @private
|
|
|
*/
|
|
|
_showSettingsPopup: function (response) {
|
|
|
- var curValue = null;
|
|
|
- var self = this;
|
|
|
var keys = this.get('userSettingsKeys');
|
|
|
- var timezonesFormatted = timezoneUtils.get('timezones');
|
|
|
- var initValue = JSON.parse(response[keys.show_bg.name]);
|
|
|
- var initTimezone = timezonesFormatted.findProperty('value', JSON.parse(response[keys.timezone.name]));
|
|
|
- return App.ModalPopup.show({
|
|
|
+ var curValue, self, timezonesFormatted, initValue, initTimezone;
|
|
|
+ if (response[keys.show_bg.name]) {
|
|
|
+ curValue = null;
|
|
|
+ self = this;
|
|
|
+ timezonesFormatted = timezoneUtils.get('timezones');
|
|
|
+ initValue = JSON.parse(response[keys.show_bg.name]);
|
|
|
+ initTimezone = timezonesFormatted.findProperty('value', JSON.parse(response[keys.timezone.name]));
|
|
|
+ return App.ModalPopup.show({
|
|
|
|
|
|
- header: Em.I18n.t('common.userSettings'),
|
|
|
+ header: Em.I18n.t('common.userSettings'),
|
|
|
|
|
|
- bodyClass: Em.View.extend({
|
|
|
+ bodyClass: Em.View.extend({
|
|
|
|
|
|
- templateName: require('templates/common/settings'),
|
|
|
+ templateName: require('templates/common/settings'),
|
|
|
|
|
|
- isNotShowBgChecked: !initValue,
|
|
|
+ isNotShowBgChecked: !initValue,
|
|
|
|
|
|
- updateValue: function () {
|
|
|
- curValue = !this.get('isNotShowBgChecked');
|
|
|
- }.observes('isNotShowBgChecked'),
|
|
|
+ updateValue: function () {
|
|
|
+ curValue = !this.get('isNotShowBgChecked');
|
|
|
+ }.observes('isNotShowBgChecked'),
|
|
|
|
|
|
- timezonesList: timezonesFormatted,
|
|
|
+ timezonesList: timezonesFormatted,
|
|
|
|
|
|
- privileges: self.get('privileges'),
|
|
|
+ privileges: self.get('privileges'),
|
|
|
|
|
|
- isAdmin: App.get('isAdmin'),
|
|
|
+ isAdmin: App.get('isAdmin'),
|
|
|
|
|
|
- noClusterPriv: self.get('noClusterPriv'),
|
|
|
+ noClusterPriv: self.get('noClusterPriv'),
|
|
|
|
|
|
- noViewPriv: self.get('noViewPriv'),
|
|
|
+ noViewPriv: self.get('noViewPriv'),
|
|
|
|
|
|
- hidePrivileges: self.get('hidePrivileges') || App.get('isAdmin')
|
|
|
- }),
|
|
|
+ hidePrivileges: self.get('hidePrivileges') || App.get('isAdmin')
|
|
|
+ }),
|
|
|
|
|
|
- /**
|
|
|
- * @type {string}
|
|
|
- */
|
|
|
- selectedTimezone: initTimezone,
|
|
|
+ /**
|
|
|
+ * @type {string}
|
|
|
+ */
|
|
|
+ selectedTimezone: initTimezone,
|
|
|
|
|
|
- primary: Em.I18n.t('common.save'),
|
|
|
+ primary: Em.I18n.t('common.save'),
|
|
|
|
|
|
- onPrimary: function() {
|
|
|
- if (Em.isNone(curValue)) {
|
|
|
- curValue = initValue;
|
|
|
- }
|
|
|
- var tz = this.get('selectedTimezone.value');
|
|
|
- var popup = this;
|
|
|
- if (!App.get('testMode')) {
|
|
|
- self.postUserPref('show_bg', curValue).always(function () {
|
|
|
- self.postUserPref('timezone', tz).always(function () {
|
|
|
- if (popup.needsPageRefresh()) {
|
|
|
- location.reload();
|
|
|
- }
|
|
|
+ onPrimary: function () {
|
|
|
+ if (Em.isNone(curValue)) {
|
|
|
+ curValue = initValue;
|
|
|
+ }
|
|
|
+ var tz = this.get('selectedTimezone.value');
|
|
|
+ var popup = this;
|
|
|
+ if (!App.get('testMode')) {
|
|
|
+ self.postUserPref('show_bg', curValue).always(function () {
|
|
|
+ self.postUserPref('timezone', tz).always(function () {
|
|
|
+ if (popup.needsPageRefresh()) {
|
|
|
+ location.reload();
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
+ this._super();
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Determines if page should be refreshed after user click "Save"
|
|
|
+ *
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ needsPageRefresh: function () {
|
|
|
+ return initTimezone !== this.get('selectedTimezone');
|
|
|
}
|
|
|
- this._super();
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * Determines if page should be refreshed after user click "Save"
|
|
|
- *
|
|
|
- * @returns {boolean}
|
|
|
- */
|
|
|
- needsPageRefresh: function () {
|
|
|
- return initTimezone !== this.get('selectedTimezone');
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ App.showAlertPopup(Em.I18n.t('common.error'), Em.I18n.t('app.settings.noData'));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
});
|