diff --git a/app/app.js b/app/app.js index f62976f..247b711 100644 --- a/app/app.js +++ b/app/app.js @@ -127,17 +127,9 @@ var app = new Vue({ }, onVersionChange: function() { - //Save previous state storage.setVersionedLocalStorage(this.$root.sections.meta.version,"sections",this.$root.sections); - - // console.log(["version",this.currentVersion,this.$root.sections.meta.version]); - this.$root.sections = storage.getVersionedLocalStorage(this.currentVersion,"sections"); - // console.log(["Root Sections",this.$root.sections]); - storage.setLocalStorage(this.$root.sections); // Perhaps optimisation to come - - //console.log(["version",this.currentVersion,this.$root.sections.meta.version]); - + storage.setLocalStorage(this.$root.sections);// Perhaps optimisation to come }, /** diff --git a/components/section_meta.js b/components/section_meta.js index 16777a5..facb052 100644 --- a/components/section_meta.js +++ b/components/section_meta.js @@ -43,7 +43,7 @@ var sectionMetaComponent = { // Save the data to localStorage //NOTE: I'm initially not concerned about performance here/ //storage.setLocalStorage("section.basics", val); - + console.log([val, oldVal]); //this.$root.sections.basics = val; }, deep: true @@ -51,10 +51,30 @@ var sectionMetaComponent = { }, methods: { - addProfile: function() + + versionChange: function() { - var item = models.newDefaultMeta(); - this.$root.sections.meta.profiles.push(item); + storage.setVersionedLocalStorage(this.$root.currentVersion,"sections",null); + storage.setVersionedLocalStorage(this.$root.sections.meta.version,"sections",this.$root.sections); //this.$root.sections); + var versions = storage.getLocalStorage("versions"); + var index = versions.indexOf(this.$root.currentVersion); + if ( index > -1) { + versions.splice(index,1); + this.$root.versions = versions; + storage.setLocalStorage("versions",versions); + } + this.$root.currentVersion = this.$root.sections.meta.version; + storage.setLocalStorage("currentVersion",this.$root.currentVersion); + + /* + var oldVersion = this.$root.currentVersion; + var newVersion = this.$root.sections.meta.version; + storage.setVersionedLocalStorage(newVersion,"sections",this.$root.sections); + storage.setVersionedLocalStorage(oldVersion,"sections",null); + this.$root.currentVersion = newVersion; + storage.setLocalStorage("currentVersion",newVersion); + */ } + } }; \ No newline at end of file diff --git a/index.html b/index.html index fd065d4..84ffa33 100644 --- a/index.html +++ b/index.html @@ -317,7 +317,7 @@