remove console.log + refactor categories

This commit is contained in:
hayden 2021-01-31 19:10:09 -09:00
commit 88baa46a33
11 changed files with 52 additions and 32 deletions

View file

@ -16,7 +16,6 @@ const mealPlanURLs = {
export default { export default {
async create(postBody) { async create(postBody) {
let response = await apiReq.post(mealPlanURLs.create, postBody); let response = await apiReq.post(mealPlanURLs.create, postBody);
console.log(JSON.stringify(postBody));
return response; return response;
}, },

View file

@ -101,7 +101,6 @@ export default {
templates: this.selectedTemplates, templates: this.selectedTemplates,
}; };
console.log(data);
await api.backups.create(data); await api.backups.create(data);
this.loading = false; this.loading = false;

View file

@ -75,7 +75,6 @@ export default {
let response = await api.backups.requestAvailable(); let response = await api.backups.requestAvailable();
this.availableBackups = response.imports; this.availableBackups = response.imports;
this.availableTemplates = response.templates; this.availableTemplates = response.templates;
console.log(this.availableBackups);
}, },
deleteBackup() { deleteBackup() {
if (this.$refs.form.validate()) { if (this.$refs.form.validate()) {

View file

@ -41,14 +41,14 @@
> >
<v-list-item <v-list-item
v-for="(item, index) in homeCategories" v-for="(item, index) in homeCategories"
:key="item" :key="`${item.name}-${index}`"
> >
<v-list-item-icon> <v-list-item-icon>
<v-icon>mdi-menu</v-icon> <v-icon>mdi-menu</v-icon>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-content> <v-list-item-content>
<v-list-item-title v-text="item"></v-list-item-title> <v-list-item-title v-text="item.name"></v-list-item-title>
</v-list-item-content> </v-list-item-content>
<v-list-item-icon @click="deleteActiveCategory(index)"> <v-list-item-icon @click="deleteActiveCategory(index)">
<v-icon>mdi-delete</v-icon> <v-icon>mdi-delete</v-icon>
@ -81,13 +81,16 @@
minHeight: `200px`, minHeight: `200px`,
}" }"
> >
<v-list-item v-for="item in categories" :key="item"> <v-list-item
v-for="(item, index) in categories"
:key="`${item.name}-${index}`"
>
<v-list-item-icon> <v-list-item-icon>
<v-icon>mdi-menu</v-icon> <v-icon>mdi-menu</v-icon>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-content> <v-list-item-content>
<v-list-item-title v-text="item"></v-list-item-title> <v-list-item-title v-text="item.name"></v-list-item-title>
</v-list-item-content> </v-list-item-content>
<v-list-item-icon @click="deleteActiveCategory(index)"> <v-list-item-icon @click="deleteActiveCategory(index)">
<v-icon>mdi-delete</v-icon> <v-icon>mdi-delete</v-icon>
@ -142,8 +145,10 @@ export default {
this.homeCategories.splice(index, 1); this.homeCategories.splice(index, 1);
}, },
saveSettings() { 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("setShowRecent", this.showRecent);
this.$store.commit("setShowLimit", this.showLimit); this.$store.commit("setShowLimit", this.showLimit);
this.$store.commit("setHomeCategories", this.homeCategories); this.$store.commit("setHomeCategories", this.homeCategories);

View file

@ -58,7 +58,6 @@ export default {
methods: { methods: {
getOptions() { getOptions() {
this.langOptions = this.$store.getters.getAllLangs; this.langOptions = this.$store.getters.getAllLangs;
console.log(this.langOptions);
this.selectedLang = this.$store.getters.getActiveLang; this.selectedLang = this.$store.getters.getActiveLang;
}, },
}, },

View file

@ -81,7 +81,6 @@ export default {
async importMigration(file_name) { async importMigration(file_name) {
this.loading == true; this.loading == true;
let response = await api.migrations.import(this.folder, file_name); let response = await api.migrations.import(this.folder, file_name);
console.log(response);
this.$emit("imported", response.successful, response.failed); this.$emit("imported", response.successful, response.failed);
this.loading == false; this.loading == false;
}, },

View file

@ -5,7 +5,7 @@
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{ nav.icon }}</v-icon> <v-icon>{{ nav.icon }}</v-icon>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-title>{{ nav.title }}</v-list-item-title> <v-list-item-title>{{ nav.title | titleCase }}</v-list-item-title>
</v-list-item> </v-list-item>
</v-list> </v-list>
</v-navigation-drawer> </v-navigation-drawer>
@ -15,7 +15,8 @@
export default { export default {
data() { data() {
return { return {
links: [ links: [],
baseLinks: [
{ {
icon: "mdi-home", icon: "mdi-home",
to: "/", to: "/",
@ -34,15 +35,28 @@ export default {
return this.$store.getters.getCategories; return this.$store.getters.getCategories;
}, },
}, },
watch: {
allCategories() {
this.buildSidebar();
},
},
mounted() { mounted() {
this.buildSidebar();
},
methods: {
async buildSidebar() {
this.links = [];
this.links.push(...this.baseLinks);
this.allCategories.forEach(async (element) => { this.allCategories.forEach(async (element) => {
this.links.push({ this.links.push({
title: element, title: element.name,
to: `/recipes/${element}`, to: `/recipes/${element.slug}`,
icon: "mdi-tag", icon: "mdi-tag",
}); });
}); });
}, },
},
}; };
</script> </script>

View file

@ -82,7 +82,6 @@ export default {
search() { search() {
if (this.search.trim() === "") this.result = this.list; if (this.search.trim() === "") this.result = this.list;
else this.result = this.fuse.search(this.search.trim()); else this.result = this.fuse.search(this.search.trim());
console.log("test");
this.$emit("results", this.result); this.$emit("results", this.result);
if (this.showResults === true) { if (this.showResults === true) {

View file

@ -61,7 +61,6 @@ export default {
this.searchResults = results; this.searchResults = results;
}, },
emitSelect(name, slug) { emitSelect(name, slug) {
console.log(name, slug);
this.$emit("select", name, slug); this.$emit("select", name, slug);
this.dialog = false; this.dialog = false;
}, },

View file

@ -14,17 +14,16 @@ const router = new VueRouter({
mode: process.env.NODE_ENV === "production" ? "history" : "hash", mode: process.env.NODE_ENV === "production" ? "history" : "hash",
}); });
new Vue({ new Vue({
vuetify, vuetify,
store, store,
router, router,
i18n, i18n,
render: h => h(App), render: (h) => h(App),
}).$mount("#app"); }).$mount("#app");
// Truncate // Truncate
let filter = function(text, length, clamp) { let truncate = function (text, length, clamp) {
clamp = clamp || "..."; clamp = clamp || "...";
let node = document.createElement("div"); let node = document.createElement("div");
node.innerHTML = text; node.innerHTML = text;
@ -32,6 +31,11 @@ let filter = function(text, length, clamp) {
return content.length > length ? content.slice(0, length) + clamp : content; 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 }; export { router };

View file

@ -1,7 +1,6 @@
<template> <template>
<div> <div>
<CategorySidebar/> <CategorySidebar />
<CardSection <CardSection
v-if="showRecent" v-if="showRecent"
title="Recent" title="Recent"
@ -11,7 +10,7 @@
<CardSection <CardSection
:sortable="true" :sortable="true"
v-for="(section, index) in recipeByCategory" v-for="(section, index) in recipeByCategory"
:key="index" :key="section.name + section.position"
:title="section.name" :title="section.name"
:recipes="section.recipes" :recipes="section.recipes"
:card-limit="showLimit" :card-limit="showLimit"
@ -50,12 +49,17 @@ export default {
}, },
}, },
async mounted() { async mounted() {
await this.buildPage();
this.recipeByCategory.sort((a, b) => a.position - b.position);
},
methods: {
async buildPage() {
this.homeCategories.forEach(async (element) => { this.homeCategories.forEach(async (element) => {
let recipes = await this.getRecipeByCategory(element); let recipes = await this.getRecipeByCategory(element.slug);
recipes.position = element.position;
this.recipeByCategory.push(recipes); this.recipeByCategory.push(recipes);
}); });
}, },
methods: {
async getRecipeByCategory(category) { async getRecipeByCategory(category) {
return await api.categories.get_recipes_in_category(category); return await api.categories.get_recipes_in_category(category);
}, },