From 0d0833cbb9c237f377631c4aa4b4eb5c78133b39 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Wed, 29 Jun 2022 19:10:33 +1000
Subject: Refactor to provide default-option access to non-top-level components

---
 src/components/SettingsModal.vue | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

(limited to 'src/components/SettingsModal.vue')

diff --git a/src/components/SettingsModal.vue b/src/components/SettingsModal.vue
index b11c84c..2e4d217 100644
--- a/src/components/SettingsModal.vue
+++ b/src/components/SettingsModal.vue
@@ -93,7 +93,7 @@
 import {defineComponent, PropType} from 'vue';
 import SButton from './SButton.vue';
 import CloseIcon from './icon/CloseIcon.vue';
-import {UiOptions, OptionType} from '../lib';
+import {UiOptions, OptionType, getDefaultLytOpts, getDefaultUiOpts} from '../lib';
 import {LayoutOptions} from '../layout';
 
 export default defineComponent({
@@ -141,11 +141,11 @@ export default defineComponent({
 					this.$emit('setting-chg', 'LYT', 'minTileSz', {save: false});
 				}
 			}
-			//
+			// Notify App
 			this.$emit('setting-chg', optionType, option,
 				{save, relayout: optionType == 'LYT', reinit: optionType == 'UI' && option == 'useReducedTree'});
+			// Possibly make saved-indicator appear/animate
 			if (save){
-				// Make saved-indicator appear/animate
 				if (!this.saved){
 					this.saved = true;
 				} else {
@@ -157,7 +157,15 @@ export default defineComponent({
 			}
 		},
 		onReset(){
-			this.$emit('reset');
+			// Restore default options
+			let defaultLytOpts = getDefaultLytOpts();
+			let defaultUiOpts = getDefaultUiOpts(defaultLytOpts);
+			let needReinit = this.uiOpts.useReducedTree != defaultUiOpts.useReducedTree;
+			Object.assign(this.lytOpts, defaultLytOpts);
+			Object.assign(this.uiOpts, defaultUiOpts);
+			// Notify App
+			this.$emit('reset', needReinit);
+			// Clear saved-indicator
 			this.saved = false;
 		},
 		pxToDisplayStr(px: number): string {
-- 
cgit v1.2.3

