From 88baa46a339ffd895e0a69e8b5a4afc65bf3d6bf Mon Sep 17 00:00:00 2001 From: hayden Date: Sun, 31 Jan 2021 19:10:09 -0900 Subject: [PATCH] remove console.log + refactor categories --- frontend/src/api/mealplan.js | 1 - .../Settings/Backup/NewBackupCard.vue | 1 - .../src/components/Settings/Backup/index.vue | 1 - .../Settings/General/HomePageSettings.vue | 17 +++++++---- .../src/components/Settings/General/index.vue | 1 - .../Settings/Migration/MigrationCard.vue | 1 - .../src/components/UI/CategorySidebar.vue | 30 ++++++++++++++----- frontend/src/components/UI/SearchBar.vue | 1 - frontend/src/components/UI/SearchDialog.vue | 1 - frontend/src/main.js | 12 +++++--- frontend/src/pages/HomePage.vue | 18 ++++++----- 11 files changed, 52 insertions(+), 32 deletions(-) diff --git a/frontend/src/api/mealplan.js b/frontend/src/api/mealplan.js index 44a1be536..ca05ee12a 100644 --- a/frontend/src/api/mealplan.js +++ b/frontend/src/api/mealplan.js @@ -16,7 +16,6 @@ const mealPlanURLs = { export default { async create(postBody) { let response = await apiReq.post(mealPlanURLs.create, postBody); - console.log(JSON.stringify(postBody)); return response; }, diff --git a/frontend/src/components/Settings/Backup/NewBackupCard.vue b/frontend/src/components/Settings/Backup/NewBackupCard.vue index 31962c5b5..751f1a7e5 100644 --- a/frontend/src/components/Settings/Backup/NewBackupCard.vue +++ b/frontend/src/components/Settings/Backup/NewBackupCard.vue @@ -101,7 +101,6 @@ export default { templates: this.selectedTemplates, }; - console.log(data); await api.backups.create(data); this.loading = false; diff --git a/frontend/src/components/Settings/Backup/index.vue b/frontend/src/components/Settings/Backup/index.vue index 2ae4c86d8..830fd8ee3 100644 --- a/frontend/src/components/Settings/Backup/index.vue +++ b/frontend/src/components/Settings/Backup/index.vue @@ -75,7 +75,6 @@ export default { let response = await api.backups.requestAvailable(); this.availableBackups = response.imports; this.availableTemplates = response.templates; - console.log(this.availableBackups); }, deleteBackup() { if (this.$refs.form.validate()) { diff --git a/frontend/src/components/Settings/General/HomePageSettings.vue b/frontend/src/components/Settings/General/HomePageSettings.vue index 24f7d2c6f..a5ff936df 100644 --- a/frontend/src/components/Settings/General/HomePageSettings.vue +++ b/frontend/src/components/Settings/General/HomePageSettings.vue @@ -41,14 +41,14 @@ > mdi-menu - + mdi-delete @@ -81,13 +81,16 @@ minHeight: `200px`, }" > - + mdi-menu - + mdi-delete @@ -142,8 +145,10 @@ export default { this.homeCategories.splice(index, 1); }, saveSettings() { - console.log("Saving Settings"); - console.log(this.homeCategories); + + this.homeCategories.forEach((element, index) => { + element.position = index + 1; + }); this.$store.commit("setShowRecent", this.showRecent); this.$store.commit("setShowLimit", this.showLimit); this.$store.commit("setHomeCategories", this.homeCategories); diff --git a/frontend/src/components/Settings/General/index.vue b/frontend/src/components/Settings/General/index.vue index c61842b62..b04b7246c 100644 --- a/frontend/src/components/Settings/General/index.vue +++ b/frontend/src/components/Settings/General/index.vue @@ -58,7 +58,6 @@ export default { methods: { getOptions() { this.langOptions = this.$store.getters.getAllLangs; - console.log(this.langOptions); this.selectedLang = this.$store.getters.getActiveLang; }, }, diff --git a/frontend/src/components/Settings/Migration/MigrationCard.vue b/frontend/src/components/Settings/Migration/MigrationCard.vue index 8b1b53027..8487f237d 100644 --- a/frontend/src/components/Settings/Migration/MigrationCard.vue +++ b/frontend/src/components/Settings/Migration/MigrationCard.vue @@ -81,7 +81,6 @@ export default { async importMigration(file_name) { this.loading == true; let response = await api.migrations.import(this.folder, file_name); - console.log(response); this.$emit("imported", response.successful, response.failed); this.loading == false; }, diff --git a/frontend/src/components/UI/CategorySidebar.vue b/frontend/src/components/UI/CategorySidebar.vue index d81f6ab08..5c4b39f6c 100644 --- a/frontend/src/components/UI/CategorySidebar.vue +++ b/frontend/src/components/UI/CategorySidebar.vue @@ -5,7 +5,7 @@ {{ nav.icon }} - {{ nav.title }} + {{ nav.title | titleCase }} @@ -15,7 +15,8 @@ export default { data() { return { - links: [ + links: [], + baseLinks: [ { icon: "mdi-home", to: "/", @@ -34,14 +35,27 @@ export default { return this.$store.getters.getCategories; }, }, + watch: { + allCategories() { + this.buildSidebar(); + }, + }, mounted() { - this.allCategories.forEach(async (element) => { - this.links.push({ - title: element, - to: `/recipes/${element}`, - icon: "mdi-tag", + this.buildSidebar(); + }, + + methods: { + async buildSidebar() { + this.links = []; + this.links.push(...this.baseLinks); + this.allCategories.forEach(async (element) => { + this.links.push({ + title: element.name, + to: `/recipes/${element.slug}`, + icon: "mdi-tag", + }); }); - }); + }, }, }; diff --git a/frontend/src/components/UI/SearchBar.vue b/frontend/src/components/UI/SearchBar.vue index 84776fe37..3f9e5a6a7 100644 --- a/frontend/src/components/UI/SearchBar.vue +++ b/frontend/src/components/UI/SearchBar.vue @@ -82,7 +82,6 @@ export default { search() { if (this.search.trim() === "") this.result = this.list; else this.result = this.fuse.search(this.search.trim()); - console.log("test"); this.$emit("results", this.result); if (this.showResults === true) { diff --git a/frontend/src/components/UI/SearchDialog.vue b/frontend/src/components/UI/SearchDialog.vue index 7718045b0..8874736bf 100644 --- a/frontend/src/components/UI/SearchDialog.vue +++ b/frontend/src/components/UI/SearchDialog.vue @@ -61,7 +61,6 @@ export default { this.searchResults = results; }, emitSelect(name, slug) { - console.log(name, slug); this.$emit("select", name, slug); this.dialog = false; }, diff --git a/frontend/src/main.js b/frontend/src/main.js index a99f64d6a..09b6d8f79 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -14,17 +14,16 @@ const router = new VueRouter({ mode: process.env.NODE_ENV === "production" ? "history" : "hash", }); - new Vue({ vuetify, store, router, i18n, - render: h => h(App), + render: (h) => h(App), }).$mount("#app"); // Truncate -let filter = function(text, length, clamp) { +let truncate = function (text, length, clamp) { clamp = clamp || "..."; let node = document.createElement("div"); node.innerHTML = text; @@ -32,6 +31,11 @@ let filter = function(text, length, clamp) { return content.length > length ? content.slice(0, length) + clamp : content; }; -Vue.filter("truncate", filter); +let titleCase = function (value) { + return value.replace(/(?:^|\s|-)\S/g, (x) => x.toUpperCase()); +}; + +Vue.filter("truncate", truncate); +Vue.filter("titleCase", titleCase); export { router }; diff --git a/frontend/src/pages/HomePage.vue b/frontend/src/pages/HomePage.vue index 5d43d04cb..eeaea7e71 100644 --- a/frontend/src/pages/HomePage.vue +++ b/frontend/src/pages/HomePage.vue @@ -1,7 +1,6 @@