Skip to content

Commit

Permalink
Merge pull request #1800 from uProxy/fix-set-settings
Browse files Browse the repository at this point in the history
Fix the advanced settings view and functionality
  • Loading branch information
jpevarnek committed Aug 17, 2015
2 parents 69d6ecd + f783dd7 commit 60d1497
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
13 changes: 4 additions & 9 deletions src/generic_ui/polymer/advanced-settings.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<link rel='import' href='../../bower/polymer/polymer.html'>
<link rel='import' href='../../bower/paper-input/paper-input-decorator.html'>
<link rel='import' href='../../bower/paper-input/paper-autogrow-textarea.html'>
<link rel='import' href='../../bower/core-label/core-label.html'>
<link rel='import' href='../../bower/core-tooltip/core-tooltip.html'>
<link rel='import' href='../../bower/core-overlay/core-overlay.html'>
Expand Down Expand Up @@ -64,16 +63,12 @@
background-color: rgb(240,240,240);
padding-left: 10px;
padding-top: 0;
padding-bottom: 0;
margin-bottom: 0.75em;
margin-top: 0.75em;
}
#advancedSettingsDecorator {
height: 340px;
}
#advancedSettingsPaperTextarea {
height: 340px;
margin: 0em;
textarea[fit] {
/* fit does not properly size textareas on Firefox */
height: 100%;
}
.advancedSettingsText {
font-size: 12px;
Expand Down Expand Up @@ -151,7 +146,7 @@
<div id='formContainer' flex vertical layout>
<p class='inputLabel'>{{ 'EDIT_ADVANCED_SETTINGS' | $$ }}</p>
<paper-input-decorator id='advancedSettingsDecorator' label='{{ "EDIT_ADVANCED_SETTINGS_PLACEHOLDER" | $$ }}' flex>
<textarea id='advancedSettingsInput' value='{{ settings }}' fit>
<textarea value='{{ settings }}' fit>
</textarea>
</paper-input-decorator>
<p id='confirmSetAdvancedSettings' class='advancedSettingsText' hidden?='{{ status !== StatusState.SET }}'>
Expand Down
18 changes: 9 additions & 9 deletions src/generic_ui/polymer/advanced-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ Polymer({
checkSettings_: function(oldSettings :any, newSettings :any) {
for (var key in oldSettings){
if (!(key in newSettings)) {
this.status = StatusState.KEY_VALUE_ERROR;
return false;
}
}
for (var key in newSettings){
if (!(key in oldSettings)) {
this.status = StatusState.KEY_VALUE_ERROR;
return false;
}
}
Expand All @@ -54,14 +52,16 @@ Polymer({
setAdvancedSettings: function() {
try {
var newSettings = JSON.parse(this.settings);
if (this.checkSettings_(ui_context.model.globalSettings, newSettings)) {
ui_context.model.globalSettings = newSettings;
this.status = StatusState.SET;
ui_context.core.updateGlobalSettings(ui_context.model.globalSettings);

this.settings = this.jsonifySettings_(ui_context.model.globalSettings);
this.$.advancedSettingsPaperTextarea.update();
if (!this.checkSettings_(ui_context.model.globalSettings, newSettings)) {
this.status = StatusState.KEY_VALUE_ERROR;
return;
}

ui_context.model.globalSettings = newSettings;
this.status = StatusState.SET;
ui_context.core.updateGlobalSettings(ui_context.model.globalSettings);

this.settings = this.jsonifySettings_(ui_context.model.globalSettings);
} catch (e) {
this.status = StatusState.PARSE_ERROR;
}
Expand Down

0 comments on commit 60d1497

Please sign in to comment.