Skip to content

Commit

Permalink
System & Add-on settings: Add dirty indicator & Improve dirty handling (
Browse files Browse the repository at this point in the history
#2779)

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Sep 30, 2024
1 parent e500ffe commit bdb54a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<f7-page @page:afterin="onPageAfterIn" @page:beforeout="onPageBeforeOut">
<f7-navbar :title="'Configure ' + addon.label" back-link="Back">
<f7-navbar :title="'Configure ' + addon.label + dirtyIndicator" back-link="Back">
<f7-nav-right>
<f7-link @click="save()" v-if="$theme.md" icon-md="material:save" icon-only />
<f7-link @click="save()" v-if="!$theme.md">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<f7-page @page:afterin="onPageAfterIn" @page:beforeout="onPageBeforeOut">
<f7-navbar :title="service.label" back-link="Settings">
<f7-navbar :title="service.label + dirtyIndicator" back-link="Settings">
<f7-nav-right>
<f7-link @click="save()" v-if="$theme.md" icon-md="material:save" icon-only />
<f7-link @click="save()" v-if="!$theme.md">
Expand All @@ -21,6 +21,9 @@
</template>

<script>
import fastDeepEqual from 'fast-deep-equal/es6'
import cloneDeep from 'lodash/cloneDeep'
import ConfigSheet from '@/components/config/config-sheet.vue'
import DirtyMixin from '../dirty-mixin'
Expand All @@ -35,14 +38,15 @@ export default {
service: {},
configDescriptions: null,
config: null,
savedConfig: {},
loading: true
}
},
watch: {
config: {
handler: function () {
if (!this.loading) {
this.dirty = true
this.dirty = !fastDeepEqual(this.config, this.savedConfig)
}
},
deep: true
Expand All @@ -60,6 +64,7 @@ export default {
if (this.serviceId === 'org.openhab.i18n') {
this.$f7.emit('sidebarRefresh', this.config.locale)
}
this.savedConfig = cloneDeep(this.config)
this.dirty = false
this.$f7router.back()
},
Expand Down Expand Up @@ -91,6 +96,7 @@ export default {
this.$oh.api.get('/rest/services/' + this.serviceId + '/config').then(data3 => {
this.config = data3
this.savedConfig = cloneDeep(this.config)
this.$nextTick(() => {
this.loading = false
})
Expand Down

0 comments on commit bdb54a5

Please sign in to comment.