diff --git a/frontend/src/api/category.js b/frontend/src/api/category.js index b08a14e59..8c2219e58 100644 --- a/frontend/src/api/category.js +++ b/frontend/src/api/category.js @@ -6,6 +6,7 @@ const prefix = baseURL + "categories"; const categoryURLs = { getAll: `${prefix}`, + getEmpty: `${prefix}/empty`, getCategory: category => `${prefix}/${category}`, deleteCategory: category => `${prefix}/${category}`, updateCategory: category => `${prefix}/${category}`, @@ -16,6 +17,10 @@ export const categoryAPI = { let response = await apiReq.get(categoryURLs.getAll); return response.data; }, + async getEmpty() { + let response = await apiReq.get(categoryURLs.getEmpty); + return response.data; + }, async create(name) { let response = await apiReq.post(categoryURLs.getAll, { name: name }); store.dispatch("requestCategories"); @@ -34,9 +39,11 @@ export const categoryAPI = { } return response.data; }, - async delete(category) { + async delete(category, overrideRequest = false) { let response = await apiReq.delete(categoryURLs.deleteCategory(category)); - store.dispatch("requestCategories"); + if (!overrideRequest) { + store.dispatch("requestCategories"); + } return response.data; }, }; @@ -45,6 +52,7 @@ const tagPrefix = baseURL + "tags"; const tagURLs = { getAll: `${tagPrefix}`, + getEmpty: `${tagPrefix}/empty`, getTag: tag => `${tagPrefix}/${tag}`, deleteTag: tag => `${tagPrefix}/${tag}`, updateTag: tag => `${tagPrefix}/${tag}`, @@ -55,6 +63,10 @@ export const tagAPI = { let response = await apiReq.get(tagURLs.getAll); return response.data; }, + async getEmpty() { + let response = await apiReq.get(tagURLs.getEmpty); + return response.data; + }, async create(name) { let response = await apiReq.post(tagURLs.getAll, { name: name }); store.dispatch("requestTags"); @@ -73,9 +85,11 @@ export const tagAPI = { return response.data; }, - async delete(tag) { + async delete(tag, overrideRequest = false) { let response = await apiReq.delete(tagURLs.deleteTag(tag)); - store.dispatch("requestTags"); + if (!overrideRequest) { + store.dispatch("requestTags"); + } return response.data; }, }; diff --git a/frontend/src/components/UI/CardSection.vue b/frontend/src/components/UI/CardSection.vue index d29a9178e..dd6efb0f3 100644 --- a/frontend/src/components/UI/CardSection.vue +++ b/frontend/src/components/UI/CardSection.vue @@ -60,10 +60,10 @@ @@ -79,14 +79,16 @@
- + + +
@@ -109,6 +111,12 @@ export default { hardLimit: { default: 99999, }, + mobileCards: { + default: false, + }, + singleColumn: { + defualt: false, + }, recipes: Array, }, data() { @@ -117,8 +125,14 @@ export default { loading: false, }; }, + watch: { + recipes() { + this.bumpList(); + }, + }, computed: { viewScale() { + if (this.mobileCards) return true; switch (this.$vuetify.breakpoint.name) { case "xs": return true; @@ -128,10 +142,16 @@ export default { return false; } }, + effectiveHardLimit() { + return Math.min(this.hardLimit, this.recipes.length); + }, }, methods: { bumpList() { - const newCardLimit = Math.min(this.cardLimit + 20, this.hardLimit); + const newCardLimit = Math.min( + this.cardLimit + 20, + this.effectiveHardLimit + ); if (this.loading === false && newCardLimit > this.cardLimit) { this.setLoader(); @@ -141,7 +161,7 @@ export default { }, async setLoader() { this.loading = true; - await new Promise(r => setTimeout(r, 3000)); + await new Promise(r => setTimeout(r, 1000)); this.loading = false; }, }, diff --git a/frontend/src/components/UI/Dialogs/BaseDialog.vue b/frontend/src/components/UI/Dialogs/BaseDialog.vue index c0f9b04ec..eed570388 100644 --- a/frontend/src/components/UI/Dialogs/BaseDialog.vue +++ b/frontend/src/components/UI/Dialogs/BaseDialog.vue @@ -1,7 +1,11 @@