From 397896069dcd30fef94b1b883d21ad3a67d99f65 Mon Sep 17 00:00:00 2001 From: Jason Snelders Date: Tue, 26 Nov 2019 14:36:59 +1100 Subject: [PATCH] Refactoring and adding Projects section --- app/app.js | 23 ++- app/page_registration.js | 10 ++ components/import.js | 7 +- components/section_awards.js | 2 +- components/section_basics.js | 6 +- components/section_education.js | 4 +- components/section_interests.js | 4 +- components/section_languages.js | 2 +- components/section_projects.js | 97 ++++++++++++ components/section_publications.js | 2 +- components/section_references.js | 2 +- components/section_skills.js | 4 +- components/section_volunteer.js | 4 +- components/section_work.js | 4 +- index.html | 170 +++++++++++++++++++- scripts.js | 224 --------------------------- scripts/models.js | 240 +++++++++++++++++++++++++++++ scripts/scripts.js | 4 + scripts/storage.js | 35 +++++ 19 files changed, 595 insertions(+), 249 deletions(-) create mode 100644 components/section_projects.js delete mode 100644 scripts.js create mode 100644 scripts/models.js create mode 100644 scripts/scripts.js create mode 100644 scripts/storage.js diff --git a/app/app.js b/app/app.js index b02061e..1bd9bb8 100644 --- a/app/app.js +++ b/app/app.js @@ -21,6 +21,7 @@ var router = new VueRouter({ { path: '/section/languages', component: sectionLanguagesComponent }, { path: '/section/interests', component: sectionInterestsComponent }, { path: '/section/references', component: sectionReferencesComponent }, + { path: '/section/projects', component: sectionProjectsComponent }, { path: '/preview', component: previewResumeComponent }, { path: '/import', component: importComponent }, @@ -74,7 +75,9 @@ var app = new Vue({ created() { - this.sections = sections.getDefaultSections(); + this.sections = models.newDefaultSections(); + + console.log("this.sections=", this.sections); //-- Register all components pageComponents.registerComponents(); @@ -147,7 +150,7 @@ var app = new Vue({ loadFromStorage: function() { - var savedData = helpers.getLocalStorage("sections"); + var savedData = storage.getLocalStorage("sections"); this.populateSections(savedData); }, @@ -239,6 +242,16 @@ var app = new Vue({ }, + projectEndDate: function(index) + { + var endDate = this.$root.sections.projects[index].endDate; + + if (endDate == "") return "Current"; + + return endDate; + }, + + dateMonthYear: function(dateString) { var dt = new Date(dateString); @@ -275,7 +288,7 @@ var app = new Vue({ if (response == true) { - this.sections = sections.getDefaultSections(); + this.sections = models.newDefaultSections(); alert("Your resume has been cleared."); } @@ -287,7 +300,7 @@ var app = new Vue({ { var response = confirm("Resume saved"); - helpers.setLocalStorage("sections", this.$root.sections); + storage.setLocalStorage("sections", this.$root.sections); alert("Resume saved"); return false; @@ -500,7 +513,7 @@ var app = new Vue({ // //NOTE: I'm initially not concerned about performance here. // if (val.status == "loaded") // { - // helpers.setLocalStorage("sections", val.sections); + // storage.setLocalStorage("sections", val.sections); // } // }, // deep: true diff --git a/app/page_registration.js b/app/page_registration.js index f31fb74..13ff1bb 100644 --- a/app/page_registration.js +++ b/app/page_registration.js @@ -171,6 +171,15 @@ var pageComponents = { fontAwesomeIcon: "fas fa-list" }); + this.registerComponent({ + id: "projects", + path: "#/section/projects", + type: "page", + title: "Projects", + description: "", + fontAwesomeIcon: "fas fa-project-diagram" + }); + this.registerComponent({ id: "previewResume", path: "#/preview", @@ -207,6 +216,7 @@ var pageComponents = { fontAwesomeIcon: "fas fa-info-circle" }); + } }; diff --git a/components/import.js b/components/import.js index d8abffd..ef242da 100644 --- a/components/import.js +++ b/components/import.js @@ -33,9 +33,14 @@ var importComponent = { var data = JSON.parse(this.json); + // Reset first + this.$root.sections = models.newDefaultSections(); + this.$root.populateSections(data); - helpers.setLocalStorage("sections", this.$root.sections); + storage.setLocalStorage("sections", this.$root.sections); + + router.push("section/basics"); }, diff --git a/components/section_awards.js b/components/section_awards.js index d2de6fa..1783ae5 100644 --- a/components/section_awards.js +++ b/components/section_awards.js @@ -29,7 +29,7 @@ var sectionAwardsComponent = { methods: { addAward: function() { - var item = this.$root.getDefaultAward(); + var item = models.newDefaultAward(); this.$root.sections.awards.push(item); }, diff --git a/components/section_basics.js b/components/section_basics.js index ab9e231..b68d0b6 100644 --- a/components/section_basics.js +++ b/components/section_basics.js @@ -7,7 +7,7 @@ var sectionBasicsComponent = { mounted: function() { - var savedData = helpers.getLocalStorage("section.basics"); + var savedData = storage.getLocalStorage("section.basics"); if (savedData) { @@ -58,7 +58,7 @@ var sectionBasicsComponent = { { // Save the data to localStorage //NOTE: I'm initially not concerned about performance here/ - //helpers.setLocalStorage("section.basics", val); + //storage.setLocalStorage("section.basics", val); //this.$root.sections.basics = val; }, @@ -73,7 +73,7 @@ var sectionBasicsComponent = { methods: { addProfile: function() { - var item = sections.getDefaultBasicProfile(); + var item = models.newDefaultBasic(); this.$root.sections.basics.profiles.push(item); } } diff --git a/components/section_education.js b/components/section_education.js index 4280c0f..493c7ce 100644 --- a/components/section_education.js +++ b/components/section_education.js @@ -29,13 +29,13 @@ var sectionEducationComponent = { methods: { addEducation: function() { - var item = sections.getDefaultEducation(); + var item = models.getDefaultEducation(); this.$root.sections.education.push(item); }, addCourse: function(index) { - var item = sections.getDefaultEducationCourse(); + var item = models.newDefaultEducationCourse(); this.$root.sections.education[index].courses.push(item); }, diff --git a/components/section_interests.js b/components/section_interests.js index 4b75e2d..627a2cb 100644 --- a/components/section_interests.js +++ b/components/section_interests.js @@ -29,13 +29,13 @@ var sectionInterestsComponent = { methods: { addInterest: function() { - var item = sections.getDefaultInterest(); + var item = models.wDefaultInterest(); this.$root.sections.interests.push(item); }, addKeyword: function(index) { - var item = sections.getDefaultInterestKeywoard(); + var item = models.newDefaultInterestKeyword(); //console.log("addHighlight(" + index + ")", this.$root.sections.interests[index]); this.$root.sections.interests[index].keywords.push(item); }, diff --git a/components/section_languages.js b/components/section_languages.js index 34c19c4..cc04ffa 100644 --- a/components/section_languages.js +++ b/components/section_languages.js @@ -29,7 +29,7 @@ var sectionLanguagesComponent = { methods: { addLanguage: function() { - var item = sections.getDefaultInterest(); + var item = models.wDefaultInterest(); this.$root.sections.languages.push(item); }, diff --git a/components/section_projects.js b/components/section_projects.js new file mode 100644 index 0000000..59e0ebf --- /dev/null +++ b/components/section_projects.js @@ -0,0 +1,97 @@ +var sectionProjectsComponent = { + template: '#section-projects-template', + + + + mounted: function() + { + + }, + + + + destroyed: function() + { + + }, + + + + data: function() + { + return { + item: {} + }; + }, + + + + methods: { + addProject: function() + { + var item = models.newDefaultProject(); + this.$root.sections.projects.push(item); + }, + + addHighlight: function(index) + { + if (!this.$root.sections.projects[index].highlights) + { + // May not exist from an import, so add the property. + this.$set(this.$root.sections.projects[index], "highlights", []); + } + + var item = models.newDefaultProjectHighlight(); + this.$root.sections.projects[index].highlights.push(item); + + console.log("this.$root.sections.projects[" + index + "]=", this.$root.sections.projects[index]); + }, + + addKeyword: function(index) + { + if (!this.$root.sections.projects[index].keywords) + { + // May not exist from an import, so add the property. + this.$set(this.$root.sections.projects[index], "keywords", []); + } + + var item = models.newDefaultProjectKeyword(); + this.$root.sections.projects[index].keywords.push(item); + }, + + addRole: function(index) + { + if (!this.$root.sections.projects[index].roles) + { + // May not exist from an import, so add the property. + this.$set(this.$root.sections.projects[index], "roles", []); + } + + var item = models.newDefaultProjectRole(); + this.$root.sections.projects[index].roles.push(item); + }, + + + deleteClicked: function(index) + { + var response = confirm("Are you sure you want to delete this project?"); + + if (response == true) + { + this.$root.sections.projects.splice(index, 1); + } + }, + + + moveUpClicked: function(index) + { + this.$root.moveArrayPosition(this.$root.sections.work, index, index - 1); + }, + + + moveDownClicked: function(index) + { + this.$root.moveArrayPosition(this.$root.sections.work, index, index + 1); + } + } +}; \ No newline at end of file diff --git a/components/section_publications.js b/components/section_publications.js index c383971..04d6b7d 100644 --- a/components/section_publications.js +++ b/components/section_publications.js @@ -29,7 +29,7 @@ var sectionPublicationsComponent = { methods: { addPublication: function() { - var item = sections.getDefaultWork(); + var item = models.newDefaultWork(); this.$root.sections.publications.push(item); }, diff --git a/components/section_references.js b/components/section_references.js index bcd3a10..980c3b9 100644 --- a/components/section_references.js +++ b/components/section_references.js @@ -29,7 +29,7 @@ var sectionReferencesComponent = { methods: { addReference: function() { - var item = sections.getDefaultReference(); + var item = models.newDefaultReference(); this.$root.sections.references.push(item); }, diff --git a/components/section_skills.js b/components/section_skills.js index fb482ad..f18466e 100644 --- a/components/section_skills.js +++ b/components/section_skills.js @@ -29,13 +29,13 @@ var sectionSkillsComponent = { methods: { addSkill: function() { - var item = this.$root.getDefaultSkill(); + var item = models.newDefaultSkill(); this.$root.sections.skills.push(item); }, addKeyword: function(index) { - var item = sections.getDefaultSkillKeywoard(); + var item = models.newDefaultSkillKeyword(); //console.log("addHighlight(" + index + ")", this.$root.sections.volunteer[index]); this.$root.sections.skills[index].keywords.push(item); }, diff --git a/components/section_volunteer.js b/components/section_volunteer.js index dc0f384..cdc4bfb 100644 --- a/components/section_volunteer.js +++ b/components/section_volunteer.js @@ -29,13 +29,13 @@ var sectionVolunteerComponent = { methods: { addPosition: function() { - var item = sections.getDefaultVolunteer(); + var item = models.newDefaultVolunteer(); this.$root.sections.volunteer.push(item); }, addHighlight: function(index) { - var item = sections.getDefaulVolunteerHighlight(); + var item = models.newDefaultVolunteerHighlight(); //console.log("addHighlight(" + index + ")", this.$root.sections.volunteer[index]); this.$root.sections.volunteer[index].highlights.push(item); }, diff --git a/components/section_work.js b/components/section_work.js index bd95af5..940b7ba 100644 --- a/components/section_work.js +++ b/components/section_work.js @@ -29,13 +29,13 @@ var sectionWorkComponent = { methods: { addPosition: function() { - var item = sections.getDefaultWork(); + var item = models.newDefaultWork(); this.$root.sections.work.push(item); }, addHighlight: function(index) { - var item = sections.getDefaultWorkHighlight(); + var item = models.newDefaultWorkHighlight(); this.$root.sections.work[index].highlights.push(item); }, diff --git a/index.html b/index.html index 054f758..1349dc8 100644 --- a/index.html +++ b/index.html @@ -64,6 +64,7 @@   Languages   Interests   References +   Projects
@@ -111,7 +112,7 @@