diff --git a/src/main.js b/src/main.js index 2bb4421..385ba4c 100644 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ const store = createStore({ processedBotPassId: null, loginFormData: null, + taskViewData: null, }, mutations: { saveProcessedWiki(state, processedWikiData) { @@ -23,6 +24,9 @@ const store = createStore({ }, saveLoginFormData(state, loginFormData) { state.loginFormData = loginFormData; + }, + saveTaskViewData(state, taskViewData) { + state.taskViewData = taskViewData; } }, getters: { @@ -36,6 +40,9 @@ const store = createStore({ }, getLoginFormData(state) { return state.loginFormData; + }, + getTaskViewData(state) { + return state.taskViewData; } } }); diff --git a/src/views/Tasks.vue b/src/views/Tasks.vue index 1d580d4..551caa0 100644 --- a/src/views/Tasks.vue +++ b/src/views/Tasks.vue @@ -228,6 +228,27 @@ export default { targetElement.focus(); })(); }, + commitChoices() { + const taskData = { + generatorModalChosenGenerator: this.generatorModalChosenGenerator, + addTaskModalChosenTask: this.addTaskModalChosenTask, + expandedTasks: this.expandedTasks, + tasks: this.tasks, + taskPages: this.taskPages + }; + + this.$store.commit("saveTaskViewData", taskData); + }, + restoreFromState() { + const taskData = this.$store.getters.getTaskViewData; + if (taskData === null) { + return; + } + + for (const key of Object.keys(taskData)) { + this[key] = taskData[key]; + } + }, getGeneratorOptionInputId(optionId) { return `generator-option-${this.generatorModalChosenGenerator}-${optionId}`; }, @@ -346,7 +367,13 @@ export default { this.addTaskModalOpen = false; document.removeEventListener("keydown", this.onAddTaskModalKeydown); } - } + }, + created: function() { + this.restoreFromState(); + }, + beforeUnmount: function() { + this.commitChoices(); + }, };