From a463959a365a5d618a79c96a26f6506e700d6ea3 Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Thu, 1 Oct 2020 01:43:07 +0300
Subject: Initial work on highlighting changed settings. Some refactoring to
 simplify addition of new settings

---
 .../settings_modal/helpers/boolean_setting.vue     | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 src/components/settings_modal/helpers/boolean_setting.vue

(limited to 'src/components/settings_modal/helpers/boolean_setting.vue')

diff --git a/src/components/settings_modal/helpers/boolean_setting.vue b/src/components/settings_modal/helpers/boolean_setting.vue
new file mode 100644
index 00000000..11b354ed
--- /dev/null
+++ b/src/components/settings_modal/helpers/boolean_setting.vue
@@ -0,0 +1,57 @@
+<template>
+  <label
+    class="BooleanSetting"
+  >
+    <Checkbox
+      :checked="state"
+      @change="update"
+      :disabled="disabled"
+      >
+      <span
+        v-if="!!$slots.default"
+        class="label"
+        >
+        <slot />
+      </span>
+    </Checkbox>
+    <span v-if="isChanged">
+      <strong>CHANGED</strong>
+    </span>
+  </label>
+</template>
+
+<script>
+import { get, set } from 'lodash'
+import Checkbox from 'src/components/checkbox/checkbox.vue'
+export default {
+  props: [
+    'path',
+    'disabled'
+  ],
+  components: {
+    Checkbox
+  },
+  computed: {
+    pathDefault () {
+      const [firstSegment, ...rest] = this.path.split('.')
+      return [firstSegment + 'DefaultValue', ...rest].join('.')
+    },
+    state () {
+      return get(this.$parent, this.path)
+    },
+    isChanged () {
+      return get(this.$parent, this.path) !== get(this.$parent, this.pathDefault)
+    }
+  },
+  methods: {
+    update (e) {
+      set(this.$parent, this.path, e)
+    }
+  }
+}
+</script>
+
+<style lang="scss">
+.BooleanSetting {
+}
+</style>
-- 
cgit v1.2.3-70-g09d2


From e695506c514e49964dfd81c7db5c5b4d4918f47d Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Sat, 17 Oct 2020 22:28:49 +0300
Subject: proper modified icon + popup

---
 .../settings_modal/helpers/boolean_setting.vue     | 10 ++---
 .../settings_modal/helpers/modified_icon.vue       | 46 ++++++++++++++++++++++
 src/i18n/en.json                                   |  1 +
 3 files changed, 52 insertions(+), 5 deletions(-)
 create mode 100644 src/components/settings_modal/helpers/modified_icon.vue

(limited to 'src/components/settings_modal/helpers/boolean_setting.vue')

diff --git a/src/components/settings_modal/helpers/boolean_setting.vue b/src/components/settings_modal/helpers/boolean_setting.vue
index 11b354ed..f7c392cd 100644
--- a/src/components/settings_modal/helpers/boolean_setting.vue
+++ b/src/components/settings_modal/helpers/boolean_setting.vue
@@ -6,30 +6,30 @@
       :checked="state"
       @change="update"
       :disabled="disabled"
-      >
+    >
       <span
         v-if="!!$slots.default"
         class="label"
         >
         <slot />
       </span>
+      <ModifiedIcon :changed="isChanged" />
     </Checkbox>
-    <span v-if="isChanged">
-      <strong>CHANGED</strong>
-    </span>
   </label>
 </template>
 
 <script>
 import { get, set } from 'lodash'
 import Checkbox from 'src/components/checkbox/checkbox.vue'
+import ModifiedIcon from './modified_icon.vue'
 export default {
   props: [
     'path',
     'disabled'
   ],
   components: {
-    Checkbox
+    Checkbox,
+    ModifiedIcon
   },
   computed: {
     pathDefault () {
diff --git a/src/components/settings_modal/helpers/modified_icon.vue b/src/components/settings_modal/helpers/modified_icon.vue
new file mode 100644
index 00000000..27e0a9c5
--- /dev/null
+++ b/src/components/settings_modal/helpers/modified_icon.vue
@@ -0,0 +1,46 @@
+<template>
+  <span
+    v-if="changed"
+    class="ModifiedIcon"
+    >
+    <Popover
+      trigger="hover"
+      >
+      <i
+        slot="trigger"
+        class="icon icon-wrench"
+        />
+      <div
+        class="modified-tooltip"
+        slot="content"
+        >
+      {{ $t('settings.setting_changed') }}
+      </div>
+    </Popover>
+  </span>
+</template>
+
+<script>
+import Popover from 'src/components/popover/popover.vue'
+export default {
+  props: ['changed'],
+  components: { Popover }
+}
+</script>
+
+<style lang="scss">
+.ModifiedIcon {
+  display: inline-block;
+  position: relative;
+
+  .icon {
+    display: inline-block;
+  }
+
+  .modified-tooltip {
+    margin: 0.5em 1em;
+    min-width: 10em;
+    text-align: center;
+  }
+}
+</style>
diff --git a/src/i18n/en.json b/src/i18n/en.json
index d3d57562..e25bda8f 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -240,6 +240,7 @@
   "settings": {
     "app_name": "App name",
     "security": "Security",
+    "setting_changed": "Setting is different from default",
     "enter_current_password_to_confirm": "Enter your current password to confirm your identity",
     "mfa": {
       "otp": "OTP",
-- 
cgit v1.2.3-70-g09d2


From 66f3e72b545a7f92d2569baa0fd52275a29d629a Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Mon, 1 Feb 2021 20:08:36 +0200
Subject: update branch with recent develop changes (FA, added settings)

---
 .../settings_modal/helpers/boolean_setting.vue     |  6 +--
 .../settings_modal/helpers/modified_icon.vue       | 46 -------------------
 .../settings_modal/helpers/modified_indicator.vue  | 51 ++++++++++++++++++++++
 .../helpers/shared_computed_object.js              |  1 -
 src/components/settings_modal/tabs/general_tab.vue |  8 ++--
 src/modules/config.js                              |  2 -
 6 files changed, 58 insertions(+), 56 deletions(-)
 delete mode 100644 src/components/settings_modal/helpers/modified_icon.vue
 create mode 100644 src/components/settings_modal/helpers/modified_indicator.vue

(limited to 'src/components/settings_modal/helpers/boolean_setting.vue')

diff --git a/src/components/settings_modal/helpers/boolean_setting.vue b/src/components/settings_modal/helpers/boolean_setting.vue
index f7c392cd..b600b63b 100644
--- a/src/components/settings_modal/helpers/boolean_setting.vue
+++ b/src/components/settings_modal/helpers/boolean_setting.vue
@@ -13,7 +13,7 @@
         >
         <slot />
       </span>
-      <ModifiedIcon :changed="isChanged" />
+      <ModifiedIndicator :changed="isChanged" />
     </Checkbox>
   </label>
 </template>
@@ -21,7 +21,7 @@
 <script>
 import { get, set } from 'lodash'
 import Checkbox from 'src/components/checkbox/checkbox.vue'
-import ModifiedIcon from './modified_icon.vue'
+import ModifiedIndicator from './modified_indicator.vue'
 export default {
   props: [
     'path',
@@ -29,7 +29,7 @@ export default {
   ],
   components: {
     Checkbox,
-    ModifiedIcon
+    ModifiedIndicator
   },
   computed: {
     pathDefault () {
diff --git a/src/components/settings_modal/helpers/modified_icon.vue b/src/components/settings_modal/helpers/modified_icon.vue
deleted file mode 100644
index 27e0a9c5..00000000
--- a/src/components/settings_modal/helpers/modified_icon.vue
+++ /dev/null
@@ -1,46 +0,0 @@
-<template>
-  <span
-    v-if="changed"
-    class="ModifiedIcon"
-    >
-    <Popover
-      trigger="hover"
-      >
-      <i
-        slot="trigger"
-        class="icon icon-wrench"
-        />
-      <div
-        class="modified-tooltip"
-        slot="content"
-        >
-      {{ $t('settings.setting_changed') }}
-      </div>
-    </Popover>
-  </span>
-</template>
-
-<script>
-import Popover from 'src/components/popover/popover.vue'
-export default {
-  props: ['changed'],
-  components: { Popover }
-}
-</script>
-
-<style lang="scss">
-.ModifiedIcon {
-  display: inline-block;
-  position: relative;
-
-  .icon {
-    display: inline-block;
-  }
-
-  .modified-tooltip {
-    margin: 0.5em 1em;
-    min-width: 10em;
-    text-align: center;
-  }
-}
-</style>
diff --git a/src/components/settings_modal/helpers/modified_indicator.vue b/src/components/settings_modal/helpers/modified_indicator.vue
new file mode 100644
index 00000000..b75a2811
--- /dev/null
+++ b/src/components/settings_modal/helpers/modified_indicator.vue
@@ -0,0 +1,51 @@
+<template>
+  <span
+    v-if="changed"
+    class="ModifiedIndicator"
+    >
+    <Popover
+      trigger="hover"
+      >
+      <span slot="trigger">
+        &nbsp;
+          <FAIcon
+            icon="wrench"
+          />
+      </span>
+      <div
+        class="modified-tooltip"
+        slot="content"
+        >
+      {{ $t('settings.setting_changed') }}
+      </div>
+    </Popover>
+  </span>
+</template>
+
+<script>
+import Popover from 'src/components/popover/popover.vue'
+import { library } from '@fortawesome/fontawesome-svg-core'
+import { faWrench } from '@fortawesome/free-solid-svg-icons'
+
+library.add(
+  faWrench
+)
+
+export default {
+  props: ['changed'],
+  components: { Popover }
+}
+</script>
+
+<style lang="scss">
+.ModifiedIndicator {
+  display: inline-block;
+  position: relative;
+
+  .modified-tooltip {
+    margin: 0.5em 1em;
+    min-width: 10em;
+    text-align: center;
+  }
+}
+</style>
diff --git a/src/components/settings_modal/helpers/shared_computed_object.js b/src/components/settings_modal/helpers/shared_computed_object.js
index 3cbcd288..2c833c0c 100644
--- a/src/components/settings_modal/helpers/shared_computed_object.js
+++ b/src/components/settings_modal/helpers/shared_computed_object.js
@@ -9,7 +9,6 @@ const SharedComputedObject = () => ({
     .map(key => [
       key + 'DefaultValue',
       function () {
-        console.log(this.$store.getters.defaultConfig)
         return this.$store.getters.defaultConfig[key]
       }
     ])
diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue
index 92cd2069..f93f4ea0 100644
--- a/src/components/settings_modal/tabs/general_tab.vue
+++ b/src/components/settings_modal/tabs/general_tab.vue
@@ -12,9 +12,9 @@
           </BooleanSetting>
         </li>
         <li v-if="instanceWallpaperUsed">
-          <Checkbox v-model="hideInstanceWallpaper">
+          <BooleanSetting path="hideInstanceWallpaper">
             {{ $t('settings.hide_wallpaper') }}
-          </Checkbox>
+          </BooleanSetting>
         </li>
       </ul>
     </div>
@@ -64,9 +64,9 @@
           </BooleanSetting>
         </li>
         <li>
-          <Checkbox v-model="virtualScrolling">
+          <BooleanSetting path="virtualScrolling">
             {{ $t('settings.virtual_scrolling') }}
-          </Checkbox>
+          </BooleanSetting>
         </li>
       </ul>
     </div>
diff --git a/src/modules/config.js b/src/modules/config.js
index 444808cf..f992519e 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -80,7 +80,6 @@ const config = {
   getters: {
     defaultConfig (state, getters, rootState, rootGetters) {
       const { instance } = rootState
-      console.log('DC', instance.minimalScopesMode)
       return {
         ...defaultState,
         ...Object.fromEntries(
@@ -90,7 +89,6 @@ const config = {
     },
     mergedConfig (state, getters, rootState, rootGetters) {
       const { defaultConfig } = rootGetters
-      console.log('DC2', defaultConfig.hideISP)
       return {
         ...defaultConfig,
         ...state
-- 
cgit v1.2.3-70-g09d2

