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();
// Quick Fix
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))
// this.availableVersions.push(this.$root.sections.meta.version);
// console.log([this.versions[0],storage.getVersionedLocalStorage(this.versions[0])]);
@ -167,7 +167,7 @@ var app = new Vue({
loadCountryCodes: function()
{
console.log("loadCountryCodes(): data", countryCodes);
// console.log("loadCountryCodes(): data", countryCodes);
this.countryCodes.push({
"code": "",

View File

@ -15,6 +15,7 @@ var importComponent = {
data: function()
{
return {
item: {},
json: ""
};
},
@ -33,6 +34,8 @@ var importComponent = {
storage.setLocalStorage("sections", this.$root.sections);
storage.setVersionedLocalStorage(this.$root.sections.meta.version, "sections", this.$root.sections);
router.push("section/basics");
},
@ -42,8 +45,50 @@ var importComponent = {
},
importVersion: function(version) {
this.sections = storage.getVersionedLocalStorage(version,"sections");
router.push("section/basics");
//console.log(version);
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">
<div id="import-root">
<p>
Past existing resume JSON and import to continue editing.
Paste existing resume JSON and import to continue editing.
</p>
<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>
<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">
{{ version }}
</button>
<BR/>
<form class="w3-card-4 margin-top-32" v-for="(version, v_index) in this.$root.versions">
<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>
</template>

View File

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