Skip to content

Commit

Permalink
Bug fix #1: Template saving working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
a-rmz committed May 6, 2019
1 parent a6b8b89 commit 9bd7fc3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
18 changes: 15 additions & 3 deletions component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const LAYOUT;
const computed = Ember.computed;
const get = Ember.get;
const set = Ember.set;
const observe = Ember.observer;
const alias = Ember.computed.alias;
const service = Ember.inject.service;

Expand All @@ -34,7 +35,6 @@ export default Ember.Component.extend(NodeDriver, {
set(this, 'layout', template);

this._super(...arguments);

},
/*!!!!!!!!!!!DO NOT CHANGE END!!!!!!!!!!!*/

Expand All @@ -48,9 +48,10 @@ export default Ember.Component.extend(NodeDriver, {
passwd: '',
isAuthenticated: false,
zone: 'de-fra1',
coreNumber: 1,
memoryAmount: 4,
coreNumber: 0,
memoryAmount: 0,
storageSize: 25,
useCustomConfig: false,
usePrivateNetworkOnly: false,
});

Expand Down Expand Up @@ -115,6 +116,17 @@ export default Ember.Component.extend(NodeDriver, {
}
},

customConfigObserver: observe('config.useCustomConfig', function () {
const useCustomConfig = get(this, 'config.useCustomConfig');
if (!useCustomConfig) {
set(this, 'config.coreNumber', 0);
set(this, 'config.memoryAmount', 0);
} else {
set(this, 'config.coreNumber', 1);
set(this, 'config.memoryAmount', 4);
}
}),

actions: {
authenticate() {
this.dummyAPIRequest('/1.2/account')
Expand Down
14 changes: 7 additions & 7 deletions component/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@
<label>
Use a custom configuration
<input type="checkbox"
checked={{model.upcloudConfig.useCustomConfig}}
value={{useCustomConfig}}
onchange={{action (mut model.upcloudConfig.useCustomConfig) value='target.checked'}}>
checked={{config.coreNumber}}
value={{or config.useCustomConfig config.coreNumber}}
onchange={{action (mut config.useCustomConfig) value='target.checked'}}>
</label>
<div class="mt-15">
{{#unless model.upcloudConfig.useCustomConfig}}
{{#unless config.coreNumber}}
<label>Predefined plans</label>
<div class="row">
<select class="col span-6 form-control" onchange={{action (mut model.upcloudConfig.plan)
<select class="col span-6 form-control" onchange={{action (mut config.plan)
value="target.value" }}>
{{#each plans as |plan|}}
<option value={{plan.value}} selected={{eq model.upcloudConfig.plan plan.value}}>{{plan.name}}</option>
<option value={{plan.value}} selected={{eq config.plan plan.value}}>{{plan.name}}</option>
{{/each}}
</select>
</div>
Expand Down Expand Up @@ -91,7 +91,7 @@
<div class="row">
{{#each zones as |zone| }}
<label class="zoneCard col span-3">
<input type="radio" name="zones" value={{zone.id}} checked={{eq model.upcloudConfig.zone zone.id}}>
{{radio-button name="zones" selection=config.zone value=zone.id}}
<img src="https://hub.upcloud.com/static/flags/{{zone.flag}}.png"
srcset="https://hub.upcloud.com/static/flags/{{zone.flag}}.png 1x, https://hub.upcloud.com/static/flags/{{zone.flag}}-2x.png 2x"
alt="Flag of {{zone.flag}}"
Expand Down

0 comments on commit 9bd7fc3

Please sign in to comment.