diff --git a/cookbook/serializer.py b/cookbook/serializer.py index d6dae4316..b161d0865 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -650,7 +650,7 @@ class CustomFilterSerializer(SpacedModelSerializer, WritableNestedModelSerialize class RecipeBookSerializer(SpacedModelSerializer, WritableNestedModelSerializer): shared = UserNameSerializer(many=True) - filter = CustomFilterSerializer(required=False) + filter = CustomFilterSerializer(allow_null=True, required=False) def create(self, validated_data): validated_data['created_by'] = self.context['request'].user diff --git a/vue/src/apps/CookbookView/CookbookView.vue b/vue/src/apps/CookbookView/CookbookView.vue index 03cc2e533..90f0c92aa 100644 --- a/vue/src/apps/CookbookView/CookbookView.vue +++ b/vue/src/apps/CookbookView/CookbookView.vue @@ -44,7 +44,14 @@ - + @@ -95,8 +102,8 @@ export default { this.cookbooks = result.data }) }, - openBook: function (book) { - if (book === this.current_book) { + openBook: function (book, keepopen = false) { + if (book === this.current_book && !keepopen) { this.current_book = undefined this.recipes = [] return @@ -111,18 +118,7 @@ export default { apiClient.listRecipeBookEntrys({ query: { book: book } }).then((result) => { this.recipes = result.data - if (book_contents.filter) { - var promises = [] - var page = 1 - this.appendRecipeFilter(page, book_contents).then((count) => { - while (count.total > 0) { - page++ - promises.push(this.appendRecipeFilter(page, book_contents)) - count.total = count.total - count.page - } - Promise.all(promises).then() - }) - } + if (book_contents.filter) this.appendRecipeFilter(1, book_contents) this.loading = false }) }, @@ -142,7 +138,7 @@ export default { }, appendRecipeFilter: function (page, book) { let params = { page: page, options: { query: { filter: book.filter.id } } } - return this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params).then((results) => { + this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params).then((results) => { let recipes = results.data.results.map((x) => { return { id: (Math.random() * 1999) ^ 1999, @@ -152,8 +148,11 @@ export default { recipe_content: x, } }) + this.recipes.push(...recipes) - return { total: results.data.count - results.data.results.length, page: results.data.results.length } + if (results.data.next) { + this.appendRecipeFilter(page + 1, book) + } }) }, }, diff --git a/vue/src/components/CookbookEditCard.vue b/vue/src/components/CookbookEditCard.vue index 0dc21fd62..a1043c6e3 100644 --- a/vue/src/components/CookbookEditCard.vue +++ b/vue/src/components/CookbookEditCard.vue @@ -100,6 +100,7 @@ export default { this.editing = false this.saveData() this.$emit("editing", false) + this.$emit("reload") } }, updateEmoji: function (item, value) { @@ -109,6 +110,7 @@ export default { }, saveData: function () { let apiClient = new ApiApiFactory() + console.log(this.book_copy) apiClient .updateRecipeBook(this.book_copy.id, this.book_copy) diff --git a/vue/src/components/CookbookSlider.vue b/vue/src/components/CookbookSlider.vue index 8449f8de0..6a38d0a72 100644 --- a/vue/src/components/CookbookSlider.vue +++ b/vue/src/components/CookbookSlider.vue @@ -1,235 +1,223 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file +