Yet Another Correction for when we change the current name of the current version

This commit is contained in:
chris2fr 2020-10-24 21:51:45 +02:00
parent e763a7c9fd
commit bb7ae1f55a
4 changed files with 38 additions and 14 deletions

View File

@ -127,17 +127,9 @@ var app = new Vue({
}, },
onVersionChange: function() { onVersionChange: function() {
//Save previous state
storage.setVersionedLocalStorage(this.$root.sections.meta.version,"sections",this.$root.sections); 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"); this.$root.sections = storage.getVersionedLocalStorage(this.currentVersion,"sections");
// console.log(["Root Sections",this.$root.sections]); storage.setLocalStorage(this.$root.sections);// Perhaps optimisation to come
storage.setLocalStorage(this.$root.sections); // Perhaps optimisation to come
//console.log(["version",this.currentVersion,this.$root.sections.meta.version]);
}, },
/** /**

View File

@ -43,7 +43,7 @@ var sectionMetaComponent = {
// Save the data to localStorage // Save the data to localStorage
//NOTE: I'm initially not concerned about performance here/ //NOTE: I'm initially not concerned about performance here/
//storage.setLocalStorage("section.basics", val); //storage.setLocalStorage("section.basics", val);
console.log([val, oldVal]);
//this.$root.sections.basics = val; //this.$root.sections.basics = val;
}, },
deep: true deep: true
@ -51,10 +51,30 @@ var sectionMetaComponent = {
}, },
methods: { methods: {
addProfile: function()
versionChange: function()
{ {
var item = models.newDefaultMeta(); storage.setVersionedLocalStorage(this.$root.currentVersion,"sections",null);
this.$root.sections.meta.profiles.push(item); 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);
*/
}
} }
}; };

View File

@ -317,7 +317,7 @@
<form class="w3-container w3-card-4"> <form class="w3-container w3-card-4">
<p> <p>
<label for="version" class="w3-text-blue"><b>Version</b></label> <label for="version" class="w3-text-blue"><b>Version</b></label>
<input id="version" class="w3-input w3-border" type="text" v-model="$root.sections.meta.version" required> <input id="version" class="w3-input w3-border" type="text" @input="versionChange" v-model="$root.sections.meta.version" required>
<small id="versionHelp" class="form-help text-muted">Version of this CV.</small> <small id="versionHelp" class="form-help text-muted">Version of this CV.</small>
</p> </p>
<p> <p>

View File

@ -67,4 +67,16 @@ var storage = {
localStorage.removeItem(key); localStorage.removeItem(key);
}, },
updateVersion: function()
{
// console.log(["version",this.currentVersion,this.$root.sections.meta.version]);
// console.log(["Root Sections",this.$root.sections]);
//console.log(["version",this.currentVersion,this.$root.sections.meta.version]);
}
} }