Skip to content

Commit

Permalink
Model Selection small refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
damartinable committed Mar 7, 2019
1 parent 4ffac85 commit 12ab5a3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 53 deletions.
14 changes: 12 additions & 2 deletions Vue/app/src/mixins/SaveLoad.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
parse_simple_pages() {
let select_data = this.$store.state.frontend_state["model_selection"];
if (select_data ) { this.parsed_parameters["model_selection"] = select_data}
if (select_data ) { this.parsed_parameters["model_selection"] = this.parse_selection_page(select_data)}
let battery_data = this.$store.state.frontend_state["model_battery"];
if (battery_data) { this.parsed_parameters["model_battery"] = battery_data }
Expand Down Expand Up @@ -82,7 +82,17 @@
selected_load_file: data["selected_load_file"]
};
console.log(parsed_data);
return parsed_data
return parsed_data;
},
// Custom saver for this page due to additional dropdown logic
parse_selection_page(data) {
let parsed_data = [];
parsed_data.push(data.model_dropdown);
parsed_data.push(data.network_dropdown);
console.log("Selection Page Data", parsed_data);
return parsed_data;
}
// create_config_file(model_key) {
Expand Down
98 changes: 48 additions & 50 deletions Vue/app/src/pages/inputs/ModelSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<div class="background">
<div class="main-container">
<h1>{{ view_name }}</h1>
<span class="input-line"
v-for="input in input_data"
:key="input.id">
{{ input.display_text }}

<SimpleNumberInput
v-if="input.tag==='my_number'"
v-model="input.value"
:my_placeholder="input.placeholder"/>

<SimpleDropdown v-else-if="input.tag==='my_dropdown'"
v-model="input.value"
:my_options="my_options[input.dropdown_key]"
:my_placeholder="input.placeholder"/>
<span class="input-line">
{{ input_data.model_dropdown.display_text }}
<SimpleDropdown
v-model="input_data.model_dropdown.value"
v-on:input="save_model_selection(input_data.model_dropdown.value)"
:my_options="model_type_options"
:my_placeholder="input_data.model_dropdown.placeholder"/>
</span>
<span class="input-line">
{{ input_data.network_dropdown.display_text }}
<SimpleDropdown
v-model="input_data.network_dropdown.value"
:my_options="input_data.selected_model_options"
:my_placeholder="input_data.network_dropdown.placeholder"/>
</span>
</div>
</div>
Expand All @@ -41,55 +41,41 @@
view_name: this.$options.name,
model_page_name: "model_selection",
input_data: [
{
id: 0,
input_data: {
selected_model: "",
selected_model_options: [],
model_dropdown: {
name: "model_type",
display_text: "Model ",
value: "",
dropdown_key:"model_type",
display_text: "Model",
placeholder: "select model",
tag:"my_dropdown"
},
{
id: 1,
network_dropdown: {
name: "network_type",
display_text: "Network Type ",
value: "",
dropdown_key:"network_type",
placeholder: "please select a model",
tag:"my_dropdown"
},
],
my_options: {
network_options: {
"": [],
luomi_network_options: [
"Embedded Network",
"Peer to Peer Retail",
],
mike: [
"Apartment",
]
placeholder: "select model",
},
},
network_type:
[
"Apartment",
network_options: {
luomi: [
"Embedded Network",
"Peer to Peer Retail",
],
model_type: [
"mike",
"luomi",
mike: [
"Apartment",
]
}
},
model_type_options: [
"mike",
"luomi",
],
}
},
Expand All @@ -102,9 +88,21 @@
},
methods: {
// frontend "global"ish variable. Set in the store. May be used for hiding financing page.
save_model_selection(selection) {
console.log("This");
}
this.input_data.selected_model_options = this.network_options[selection];
if (this.input_data.network_dropdown.value === "") {
this.input_data.network_dropdown.value = this.input_data.selected_model_options[0]
}
let payload = {
model_page_name: "selected_model",
data: selection
};
this.$store.commit('save_page', payload)
},
}
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion Vue/app/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const model_parameters = {

const frontend_state = {
state: {
"selected_model": "luomi",
selected_model: "luomi",
},

mutations: {
Expand Down

0 comments on commit 12ab5a3

Please sign in to comment.