From 12ab5a30f39fe63ecd58240e0db6a69ca0582156 Mon Sep 17 00:00:00 2001 From: David Martin Date: Thu, 7 Mar 2019 15:57:33 +1100 Subject: [PATCH] Model Selection small refactor. --- Vue/app/src/mixins/SaveLoad.vue | 14 ++- Vue/app/src/pages/inputs/ModelSelection.vue | 98 ++++++++++----------- Vue/app/src/store/store.js | 2 +- 3 files changed, 61 insertions(+), 53 deletions(-) diff --git a/Vue/app/src/mixins/SaveLoad.vue b/Vue/app/src/mixins/SaveLoad.vue index ca7359b..8ccdac9 100644 --- a/Vue/app/src/mixins/SaveLoad.vue +++ b/Vue/app/src/mixins/SaveLoad.vue @@ -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 } @@ -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) { diff --git a/Vue/app/src/pages/inputs/ModelSelection.vue b/Vue/app/src/pages/inputs/ModelSelection.vue index ce16125..6c6560d 100644 --- a/Vue/app/src/pages/inputs/ModelSelection.vue +++ b/Vue/app/src/pages/inputs/ModelSelection.vue @@ -2,20 +2,20 @@

{{ view_name }}

- - {{ input.display_text }} - - - - + + {{ input_data.model_dropdown.display_text }} + + + + {{ input_data.network_dropdown.display_text }} +
@@ -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", + ], } }, @@ -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) + }, } } diff --git a/Vue/app/src/store/store.js b/Vue/app/src/store/store.js index 9b37361..a6fdf24 100644 --- a/Vue/app/src/store/store.js +++ b/Vue/app/src/store/store.js @@ -17,7 +17,7 @@ const model_parameters = { const frontend_state = { state: { - "selected_model": "luomi", + selected_model: "luomi", }, mutations: {