diff --git a/.vscode/settings.json b/.vscode/settings.json index 5eb6807..34428d1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - // "liveServer.settings.port": 5501; - editor.disableMonospaceOptimizations: true; + "liveServer.settings.port": 5501, + "editor.disableMonospaceOptimizations": true } \ No newline at end of file diff --git a/app/app.js b/app/app.js index 39ce7bc..f539d19 100644 --- a/app/app.js +++ b/app/app.js @@ -36,51 +36,68 @@ var router = new VueRouter({ var app = new Vue({ el: '#app', router: router, - components: - { + components: + { + }, + + data: + { + status: "loading", + + sections: {}, + /** + * Details of the current page/route. + */ + activePage: { + id: "", + title: "", + fontAwesomeIconCss: "" }, - data: - { - status: "loading", + countryCodes: [], - sections: {}, - /** - * Details of the current page/route. - */ - activePage: { - id: "", - title: "", - fontAwesomeIconCss: "" - }, + currentVersion: "", - countryCodes: [] - }, + versions: [] + }, - created() - { - this.sections = models.newDefaultSections(); - console.log("this.sections=", this.sections); + created() + { + this.sections = models.newDefaultSections(); + // this.versons = []; + this.versions = storage.getLocalStorage("versions"); + this.currentVersion = ""; - //-- Register all components - pageComponents.registerComponents(); + // console.log("this.sections=", this.sections); - //-- Get the component for the initial route path - var initialRoute = this.$route.path; - var component = pageComponents.getComponentByPath(initialRoute); - this.setActivePageByComponent(component); - }, - + //-- Register all components + pageComponents.registerComponents(); - destroyed() - { - }, + //-- Get the component for the initial route path + var initialRoute = this.$route.path; + var component = pageComponents.getComponentByPath(initialRoute); + this.setActivePageByComponent(component); + }, - mounted() - { + destroyed() + { + }, + + + mounted() + { this.loadCountryCodes(); this.loadFromStorage(); + this.currentVersion = this.$root.sections.meta.version + // Quick Fix + storage.setVersionedLocalStorage(this.currentVersion, "sections", 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])]); + + // this.availableVersions = this.$root.availableVersions; // Set the "current" main navigation item based on the current route. this.selectMenuItemForCurrentUrl(); @@ -109,7 +126,19 @@ var app = new Vue({ this.activePage.fontAwesomeIconCss = component.fontAwesomeIcon; }, - + 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]); + + }, /** * Reset and clear the details of the active page. @@ -120,13 +149,21 @@ var app = new Vue({ this.activePage.title = ""; this.activePage.fontAwesomeIconCss = ""; }, - + /* + * + */ loadFromStorage: function() { var savedData = storage.getLocalStorage("sections"); this.populateSections(savedData); }, + loadVersionFromStorage: function(version) + { + var savedData = storage.getLocalStorageVersion(version,"sections"); + this.populateSections(savedData); + }, + populateSections: function(data) { if (data) @@ -141,9 +178,10 @@ var app = new Vue({ } } }, + loadCountryCodes: function() { - console.log("loadCountryCodes(): data", countryCodes); + // console.log("loadCountryCodes(): data", countryCodes); this.countryCodes.push({ "code": "", @@ -159,7 +197,6 @@ var app = new Vue({ } }, - getCountryName: function(countryCode) { for (var i = 0; i < this.countryCodes.length; i++) @@ -174,12 +211,11 @@ var app = new Vue({ return ""; }, + displayLocation: function() { return this.sections.basics.location.city + ", " + this.getCountryName(this.sections.basics.location.countryCode); }, - - skillLevelAsPercent: function(index) { @@ -202,6 +238,7 @@ var app = new Vue({ return 50; } }, + languageFluencyAsPercent: function(index) { if (!this.$root.sections.skills[index]) { @@ -280,6 +317,7 @@ var app = new Vue({ return false; }, + saveResume: function() { var response = confirm("Resume saved"); diff --git a/components/import.js b/components/import.js index ef242da..f357505 100644 --- a/components/import.js +++ b/components/import.js @@ -1,35 +1,29 @@ var importComponent = { template: '#import-template', - - mounted: function() { + }, - - destroyed: function() { }, - - data: function() { return { + item: {}, json: "" }; }, - - methods: { importJson: function() { - console.log("import JSON: " + this.json); + // console.log("import JSON: " + this.json); var data = JSON.parse(this.json); @@ -40,13 +34,61 @@ var importComponent = { storage.setLocalStorage("sections", this.$root.sections); + storage.setVersionedLocalStorage(this.$root.sections.meta.version, "sections", this.$root.sections); + router.push("section/basics"); }, - validateJson: function(value) { + }, + + importVersion: function(version) { + //console.log(version); + this.$root.sections = storage.getVersionedLocalStorage(version,"sections"); + storage.setLocalStorage("sections",this.$root.sections); + this.$root.currentVersion = version; + this.$root.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 6155180..c304b13 100644 --- a/index.html +++ b/index.html @@ -57,8 +57,14 @@