Basic save function seems to work OK (somewhat alpha)

This commit is contained in:
chris2fr 2020-10-24 13:34:38 +02:00
parent fb276af821
commit 78158e7e67
4 changed files with 64 additions and 9 deletions

View File

@ -90,7 +90,7 @@ var app = new Vue({
this.loadFromStorage(); this.loadFromStorage();
// Quick Fix // Quick Fix
storage.setVersionedLocalStorage(this.$root.sections.meta.version, "sections", this.$root.sections); storage.setVersionedLocalStorage(this.$root.sections.meta.version, "sections", this.$root.sections);
console.log([this.$root.sections.meta.version,this.$root.sections]); // console.log([this.$root.sections.meta.version,this.$root.sections]);
//if (!this.availableVersions.hasKey(this.$root.sections.meta.version)) //if (!this.availableVersions.hasKey(this.$root.sections.meta.version))
// this.availableVersions.push(this.$root.sections.meta.version); // this.availableVersions.push(this.$root.sections.meta.version);
// console.log([this.versions[0],storage.getVersionedLocalStorage(this.versions[0])]); // console.log([this.versions[0],storage.getVersionedLocalStorage(this.versions[0])]);
@ -167,7 +167,7 @@ var app = new Vue({
loadCountryCodes: function() loadCountryCodes: function()
{ {
console.log("loadCountryCodes(): data", countryCodes); // console.log("loadCountryCodes(): data", countryCodes);
this.countryCodes.push({ this.countryCodes.push({
"code": "", "code": "",

View File

@ -15,6 +15,7 @@ var importComponent = {
data: function() data: function()
{ {
return { return {
item: {},
json: "" json: ""
}; };
}, },
@ -33,6 +34,8 @@ var importComponent = {
storage.setLocalStorage("sections", this.$root.sections); storage.setLocalStorage("sections", this.$root.sections);
storage.setVersionedLocalStorage(this.$root.sections.meta.version, "sections", this.$root.sections);
router.push("section/basics"); router.push("section/basics");
}, },
@ -42,8 +45,50 @@ var importComponent = {
}, },
importVersion: function(version) { importVersion: function(version) {
this.sections = storage.getVersionedLocalStorage(version,"sections"); //console.log(version);
router.push("section/basics"); this.$root.sections = storage.getVersionedLocalStorage(version,"sections");
storage.setLocalStorage("sections",this.$root.sections);
// this.loadFromStorage();
// router.push("section/basics");
},
deleteVersion: function(version) {
var versions = storage.getLocalStorage("versions");
var index = versions.indexOf(version);
if (index > -1 && confirm("Are you sure you wish to delete " + version + "?")) {
versions.splice(index, 1);
// storage.setVersionedLocalStorage(version,"sections",null)
storage.setLocalStorage("versions",versions);
this.$root.versions = versions;
}
},
deleteClicked: function(index)
{
console.log(index);
var response = confirm("Are you sure you want to delete this position? " + index);
if (response == true)
{
this.$root.versions.splice(index, 1);
}
},
moveUpClicked: function(index)
{
console.log(index);
this.$root.moveArrayPosition(this.$root.versions, index, index - 1);
},
moveDownClicked: function(index)
{
console.log(index);
this.$root.moveArrayPosition(this.$root.versions, index, index + 1);
} }
} }
}; };

View File

@ -1269,14 +1269,24 @@
<template type="text/x-template" id="import-template" lang="html"> <template type="text/x-template" id="import-template" lang="html">
<div id="import-root"> <div id="import-root">
<p> <p>
Past existing resume JSON and import to continue editing. Paste existing resume JSON and import to continue editing.
</p> </p>
<textarea rows="20" class="w3-input w3-border" type="text" v-model="json"></textarea> <textarea rows="20" class="w3-input w3-border" type="text" v-model="json"></textarea>
<button class="w3-btn w3-white w3-border w3-border-blue w3-round" v-on:click="importJson">Import</button> <button class="w3-btn w3-white w3-border w3-border-blue w3-round" v-on:click="importJson">Import</button>
<br/> <br/>
<button class="w3-btn w3-white w3-border w3-border-blue w3-round" v-on:click="importVersion" v-bind:version="version" v-for="(version, v_index) in $root.versions"> <BR/>
{{ version }} <form class="w3-card-4 margin-top-32" v-for="(version, v_index) in this.$root.versions">
</button> <card-header v-bind:label="version" v-bind:id="v_index" v-on:delete-clicked="deleteClicked" v-on:move-up-clicked="moveUpClicked" v-on:move-down-clicked="moveDownClicked"></card-header>
<div class="w3-container w3-hide" v-bind:id="'content' + v_index">
<button class="w3-btn w3-white w3-border w3-border-blue w3-round" v-on:click="importVersion(version,$event)">
Load {{ version }}
</button>
<button class="w3-btn w3-white w3-border w3-border-blue w3-round" v-on:click="deleteVersion(version,$event)">
Delete {{ version }}
</button>
</div>
</form>
</div> </div>
</template> </template>

View File

@ -41,7 +41,7 @@ var storage = {
getLocalStorage: function(key) getLocalStorage: function(key)
{ {
console.log(key); // console.log(key);
return this.parseJSON2Native(localStorage.getItem(key)); return this.parseJSON2Native(localStorage.getItem(key));
}, },
/* /*