Browse Source

fix: update saved state for page meta

NGPixel 5 years ago
parent
commit
a75ead44d0
1 changed files with 26 additions and 5 deletions
  1. 26 5
      client/components/editor.vue

+ 26 - 5
client/components/editor.vue

@@ -144,7 +144,15 @@ export default {
       dialogEditorSelector: false,
       dialogUnsaved: false,
       exitConfirmed: false,
-      initContentParsed: ''
+      initContentParsed: '',
+      savedState: {
+        description: '',
+        isPublished: false,
+        publishEndDate: '',
+        publishStartDate: '',
+        tags: '',
+        title: ''
+      }
     }
   },
   computed: {
@@ -159,10 +167,10 @@ export default {
         this.initContentParsed !== this.$store.get('editor/content'),
         this.locale !== this.$store.get('page/locale'),
         this.path !== this.$store.get('page/path'),
-        this.title !== this.$store.get('page/title'),
-        this.description !== this.$store.get('page/description'),
-        this.tags !== this.$store.get('page/tags'),
-        this.isPublished !== this.$store.get('page/isPublished')
+        this.savedState.title !== this.$store.get('page/title'),
+        this.savedState.description !== this.$store.get('page/description'),
+        this.savedState.tags !== this.$store.get('page/tags'),
+        this.savedState.isPublished !== this.$store.get('page/isPublished')
       ], Boolean)
     }
   },
@@ -186,6 +194,8 @@ export default {
 
     this.$store.commit('page/SET_MODE', 'edit')
 
+    this.setCurrentSavedState()
+
     this.checkoutDateActive = this.checkoutDate
   },
   mounted() {
@@ -336,6 +346,7 @@ export default {
         }
 
         this.initContentParsed = this.$store.get('editor/content')
+        this.setCurrentSavedState()
       } catch (err) {
         this.$store.commit('showNotification', {
           message: err.message,
@@ -383,6 +394,16 @@ export default {
           window.location.assign(`/${this.$store.get('page/locale')}/${this.$store.get('page/path')}`)
         }
       }, 500)
+    },
+    setCurrentSavedState () {
+      this.savedState = {
+        description: this.$store.get('page/description'),
+        isPublished: this.$store.get('page/isPublished'),
+        publishEndDate: this.$store.get('page/publishEndDate') || '',
+        publishStartDate: this.$store.get('page/publishStartDate') || '',
+        tags: this.$store.get('page/tags'),
+        title: this.$store.get('page/title')
+      }
     }
   },
   apollo: {