From 78158e7e67d951ab1523f4ac5e69449dea02489f Mon Sep 17 00:00:00 2001 From: chris2fr Date: Sat, 24 Oct 2020 13:34:38 +0200 Subject: [PATCH] Basic save function seems to work OK (somewhat alpha) --- app/app.js | 4 ++-- components/import.js | 49 ++++++++++++++++++++++++++++++++++++++++++-- index.html | 18 ++++++++++++---- scripts/storage.js | 2 +- 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app/app.js b/app/app.js index 76d84e1..8dc0a48 100644 --- a/app/app.js +++ b/app/app.js @@ -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": "", diff --git a/components/import.js b/components/import.js index 72941ee..3f77f83 100644 --- a/components/import.js +++ b/components/import.js @@ -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); } + } }; \ No newline at end of file diff --git a/index.html b/index.html index 5dcd6c1..ee0b33a 100644 --- a/index.html +++ b/index.html @@ -1269,14 +1269,24 @@ diff --git a/scripts/storage.js b/scripts/storage.js index 215c915..cb933d4 100644 --- a/scripts/storage.js +++ b/scripts/storage.js @@ -41,7 +41,7 @@ var storage = { getLocalStorage: function(key) { - console.log(key); + // console.log(key); return this.parseJSON2Native(localStorage.getItem(key)); }, /*