diff --git a/cookbook/admin.py b/cookbook/admin.py
index 32af3e5a2..f6213783e 100644
--- a/cookbook/admin.py
+++ b/cookbook/admin.py
@@ -10,7 +10,7 @@ from treebeard.forms import movenodeform_factory
from cookbook.managers import DICTIONARY
-from .models import (BookmarkletImport, Comment, CookLog, Food, ImportLog, Ingredient, InviteLink,
+from .models import (BookmarkletImport, Comment, CookLog, CustomFilter, Food, ImportLog, Ingredient, InviteLink,
Keyword, MealPlan, MealType, NutritionInformation, Property, PropertyType,
Recipe, RecipeBook, RecipeBookEntry, RecipeImport, SearchPreference, ShareLink,
ShoppingListEntry, ShoppingListRecipe, Space, Step, Storage,
@@ -103,6 +103,13 @@ class ConnectorConfigAdmin(admin.ModelAdmin):
admin.site.register(ConnectorConfig, ConnectorConfigAdmin)
+class CustomFilterAdmin(admin.ModelAdmin):
+ list_display = ('id', 'type', 'name')
+
+
+admin.site.register(CustomFilter, CustomFilterAdmin)
+
+
class SyncAdmin(admin.ModelAdmin):
list_display = ('storage', 'path', 'active', 'last_checked')
search_fields = ('storage__name', 'path')
diff --git a/vue3/src/components/display/BookEntryCard.vue b/vue3/src/components/display/BookEntryCard.vue
new file mode 100644
index 000000000..d38a6aaa9
--- /dev/null
+++ b/vue3/src/components/display/BookEntryCard.vue
@@ -0,0 +1,58 @@
+
+
+ {{ props.recipeOverview.name }}
+
+ {{ props.recipeOverview.description }}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vue3/src/components/display/IngredientsTable.vue b/vue3/src/components/display/IngredientsTable.vue
index 3ec583c77..944df01b1 100644
--- a/vue3/src/components/display/IngredientsTable.vue
+++ b/vue3/src/components/display/IngredientsTable.vue
@@ -33,7 +33,7 @@
{{ i.note }} |
-
+ |
|
|
@@ -73,6 +73,10 @@ const props = defineProps({
type: Number,
required: true,
},
+ showCheckbox: {
+ type: Boolean,
+ default: true
+ },
})
const tableHeaders = computed(() => {
diff --git a/vue3/src/pages/BookViewPage.vue b/vue3/src/pages/BookViewPage.vue
index 8fc76ec51..737247e82 100644
--- a/vue3/src/pages/BookViewPage.vue
+++ b/vue3/src/pages/BookViewPage.vue
@@ -3,31 +3,68 @@
-
- {{ $t('Back') }}
+ {{ book.name }}
+ {{ $t('Books') }}
+
+
+
+ {{ $t('shared_with') }}
+ {{ u.displayName }}
+
+
+ {{ book.description }}
+
+
+
+ {{ $t('Table_of_Contents') }}
+
+
+
+ {{ entry.recipeContent.name }}
+
+
+
+
+
-
- {{ book.name }}
- {{ book.description }}
+
+ page = value - 1" :length="totalItems" @next="page = page + (mdAndUp ? 2 : 1)"
+ @prev="page = page - (mdAndUp ? 2 : 1)">
-
-
-
-
-
- {{i.raw.recipeContent.name}}
- {{i.raw.recipeContent.desciption}}
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+ {{ i + 1 }}
+
+
+
+
+
+ {{ i + 2 }}
+
+
+
+
+
@@ -39,18 +76,21 @@
import {onMounted, ref} from "vue";
import {ApiApi, RecipeBook, RecipeBookEntry} from "@/openapi";
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
-import {VDataTableUpdateOptions} from "@/vuetify";
import {useRouter} from "vue-router";
+import RecipeImage from "@/components/display/RecipeImage.vue";
+import {useDisplay} from "vuetify";
+import BookEntryCard from "@/components/display/BookEntryCard.vue";
const props = defineProps({
bookId: {type: String, required: true},
})
+const {mdAndUp} = useDisplay()
const router = useRouter()
const loading = ref(false)
-const page = ref(1)
-const recipesPerPage = ref(1)
+const toc = ref(false)
+const page = ref(0)
const totalItems = ref(0)
const book = ref({} as RecipeBook)
@@ -58,13 +98,15 @@ const entries = ref([] as RecipeBookEntry[])
onMounted(() => {
loadBook()
- loadEntries({page: 1})
+
+ entries.value = []
+ loadEntries(1)
})
/**
* load the given book
*/
-function loadBook(){
+function loadBook() {
const api = new ApiApi()
loading.value = true
@@ -77,12 +119,15 @@ function loadBook(){
})
}
-function loadEntries(options: VDataTableUpdateOptions){
+function loadEntries(page: number) {
const api = new ApiApi()
- api.apiRecipeBookEntryList({book: props.bookId, page: options.page}).then(r => {
- entries.value = r.results
+ api.apiRecipeBookEntryList({book: props.bookId, page: page}).then(r => {
+ entries.value = entries.value.concat(r.results)
totalItems.value = r.count
+ if (r.next) {
+ loadEntries(page + 1)
+ }
}).catch(err => {
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
})
diff --git a/vue3/src/utils/model_utils.ts b/vue3/src/utils/model_utils.ts
index 62029ac17..36351200a 100644
--- a/vue3/src/utils/model_utils.ts
+++ b/vue3/src/utils/model_utils.ts
@@ -1,4 +1,4 @@
-import {Ingredient} from "@/openapi";
+import {Ingredient, Recipe} from "@/openapi";
/**
* returns a string representing an ingredient
@@ -7,21 +7,46 @@ import {Ingredient} from "@/openapi";
export function ingredientToString(ingredient: Ingredient) {
let content = []
- if(ingredient == undefined){
+ if (ingredient == undefined) {
return ''
}
- if(ingredient.amount != 0){
+ if (ingredient.amount != 0) {
content.push(ingredient.amount)
}
- if(ingredient.unit){
+ if (ingredient.unit) {
content.push(ingredient.unit.name)
}
- if(ingredient.food){
+ if (ingredient.food) {
content.push(ingredient.food.name)
}
- if(ingredient.note){
+ if (ingredient.note) {
content.push(`(${ingredient.note})`)
}
return content.join(' ')
+}
+
+
+/**
+ * returns a list of all ingredients used by the given recipe
+ * @param recipe recipe to return ingredients for
+ * @param t useI18N object to use for translation
+ * @param options options object for list generation
+ * showStepHeaders - add steps as a header ingredient if it's configured on the step
+ */
+export function getRecipeIngredients(recipe: Recipe, t: any, options: { showStepHeaders: boolean } = {showStepHeaders: false}) {
+ let ingredients = [] as Ingredient[]
+ recipe.steps.forEach((step, index) => {
+ if (step.showAsHeader && options.showStepHeaders && recipe.steps.length > 1 && (step.ingredients.length > 0 || step.name != '')) {
+ ingredients.push({
+ amount: 0,
+ unit: null,
+ food: null,
+ note: (step.name !== '') ? step.name : t('Step') + ' ' + (index + 1),
+ isHeader: true
+ } as Ingredient)
+ }
+ ingredients = ingredients.concat(step.ingredients)
+ })
+ return ingredients
}
\ No newline at end of file