food inherit attributes

This commit is contained in:
smilerz
2021-10-19 08:35:33 -05:00
parent 2ca7722afb
commit 6075ce50e7
13 changed files with 252 additions and 336 deletions

View File

@ -64,7 +64,7 @@ import { BootstrapVue } from "bootstrap-vue"
import "bootstrap-vue/dist/bootstrap-vue.css"
import { CardMixin, ApiMixin, getConfig, StandardToasts } from "@/utils/utils"
import { CardMixin, ApiMixin, getConfig, StandardToasts, getUserPreference } from "@/utils/utils"
import GenericInfiniteCards from "@/components/GenericInfiniteCards"
import GenericHorizontalCard from "@/components/GenericHorizontalCard"

View File

@ -74,7 +74,18 @@ export class Models {
// REQUIRED: unordered array of fields that can be set during create
create: {
// if not defined partialUpdate will use the same parameters, prepending 'id'
params: [["name", "description", "recipe", "ignore_shopping", "supermarket_category", "on_hand", "inherit", "ignore_inherit"]],
params: [
[
"name",
"description",
"recipe",
"ignore_shopping",
"supermarket_category",
"on_hand",
"inherit",
"ignore_inherit",
],
],
form: {
name: {
@ -404,16 +415,35 @@ export class Models {
}
static RECIPE = {
'name': i18n.t('Recipe'),
'apiName': 'Recipe',
'list': {
'params': ['query', 'keywords', 'foods', 'units', 'rating', 'books', 'keywordsOr', 'foodsOr', 'booksOr', 'internal', 'random', '_new', 'page', 'pageSize', 'options'],
name: i18n.t("Recipe"),
apiName: "Recipe",
list: {
params: [
"query",
"keywords",
"foods",
"units",
"rating",
"books",
"keywordsOr",
"foodsOr",
"booksOr",
"internal",
"random",
"_new",
"page",
"pageSize",
"options",
],
// 'config': {
// 'foods': {'type': 'string'},
// 'keywords': {'type': 'string'},
// 'books': {'type': 'string'},
// }
},
shopping: {
params: ["id", ["id", "list_recipe", "ingredients", "servings"]],
},
}
static USER_NAME = {

View File

@ -239,6 +239,68 @@ export interface Food {
* @memberof Food
*/
on_hand?: boolean;
/**
*
* @type {boolean}
* @memberof Food
*/
inherit?: boolean;
/**
*
* @type {Array<FoodIgnoreInherit>}
* @memberof Food
*/
ignore_inherit?: Array<FoodIgnoreInherit> | null;
}
/**
*
* @export
* @interface FoodIgnoreInherit
*/
export interface FoodIgnoreInherit {
/**
*
* @type {number}
* @memberof FoodIgnoreInherit
*/
id?: number;
/**
*
* @type {string}
* @memberof FoodIgnoreInherit
*/
name?: string;
/**
*
* @type {string}
* @memberof FoodIgnoreInherit
*/
field?: string;
}
/**
*
* @export
* @interface FoodInheritField
*/
export interface FoodInheritField {
/**
*
* @type {number}
* @memberof FoodInheritField
*/
id?: number;
/**
*
* @type {string}
* @memberof FoodInheritField
*/
name?: string;
/**
*
* @type {string}
* @memberof FoodInheritField
*/
field?: string;
}
/**
*
@ -736,10 +798,10 @@ export interface InlineResponse2004 {
previous?: string | null;
/**
*
* @type {Array<Step>}
* @type {Array<RecipeOverview>}
* @memberof InlineResponse2004
*/
results?: Array<Step>;
results?: Array<RecipeOverview>;
}
/**
*
@ -896,6 +958,37 @@ export interface InlineResponse2009 {
*/
results?: Array<ViewLog>;
}
/**
*
* @export
* @interface InlineResponse2009
*/
export interface InlineResponse2009 {
/**
*
* @type {number}
* @memberof InlineResponse2009
*/
count?: number;
/**
*
* @type {string}
* @memberof InlineResponse2009
*/
next?: string | null;
/**
*
* @type {string}
* @memberof InlineResponse2009
*/
previous?: string | null;
/**
*
* @type {Array<ViewLog>}
* @memberof InlineResponse2009
*/
results?: Array<ViewLog>;
}
/**
*
* @export
@ -1379,10 +1472,10 @@ export interface RecipeBook {
icon?: string | null;
/**
*
* @type {Array<ShoppingListCreatedBy>}
* @type {Array<RecipeBookShared>}
* @memberof RecipeBook
*/
shared: Array<ShoppingListCreatedBy>;
shared: Array<RecipeBookShared>;
/**
*
* @type {string}
@ -1539,6 +1632,61 @@ export interface RecipeIngredients {
*/
no_amount?: boolean;
}
/**
*
* @export
* @interface RecipeKeywords
*/
export interface RecipeIngredients {
/**
*
* @type {number}
* @memberof RecipeIngredients
*/
id?: number;
/**
*
* @type {IngredientFood}
* @memberof RecipeIngredients
*/
food: IngredientFood | null;
/**
*
* @type {FoodSupermarketCategory}
* @memberof RecipeIngredients
*/
unit: FoodSupermarketCategory | null;
/**
*
* @type {string}
* @memberof RecipeIngredients
*/
amount: string;
/**
*
* @type {string}
* @memberof RecipeIngredients
*/
note?: string | null;
/**
*
* @type {number}
* @memberof RecipeIngredients
*/
order?: number;
/**
*
* @type {boolean}
* @memberof RecipeIngredients
*/
is_header?: boolean;
/**
*
* @type {boolean}
* @memberof RecipeIngredients
*/
no_amount?: boolean;
}
/**
*
* @export
@ -1919,10 +2067,10 @@ export interface ShoppingList {
entries: Array<ShoppingListEntries> | null;
/**
*
* @type {Array<ShoppingListCreatedBy>}
* @type {Array<RecipeBookShared>}
* @memberof ShoppingList
*/
shared: Array<ShoppingListCreatedBy>;
shared: Array<RecipeBookShared>;
/**
*
* @type {boolean}
@ -2003,18 +2151,6 @@ export interface ShoppingListEntries {
* @memberof ShoppingListEntries
*/
ingredient?: number | null;
/**
*
* @type {FoodSupermarketCategory}
* @memberof ShoppingListEntries
*/
unit?: FoodSupermarketCategory | null;
/**
*
* @type {number}
* @memberof ShoppingListEntries
*/
ingredient?: number | null;
/**
*
* @type {string}
@ -2326,49 +2462,6 @@ export interface ShoppingListRecipeMealplan {
*/
mealplan_note?: string;
}
/**
*
* @export
* @interface ShoppingListRecipes
*/
export interface ShoppingListRecipes {
/**
*
* @type {number}
* @memberof ShoppingListRecipes
*/
id?: number;
/**
*
* @type {number}
* @memberof ShoppingListRecipes
*/
recipe?: number | null;
/**
*
* @type {number}
* @memberof ShoppingListRecipes
*/
mealplan?: number | null;
/**
*
* @type {string}
* @memberof ShoppingListRecipes
*/
recipe_name?: string;
/**
*
* @type {string}
* @memberof ShoppingListRecipes
*/
servings: string;
/**
*
* @type {string}
* @memberof ShoppingListRecipes
*/
mealplan_note?: string;
}
/**
*
* @export
@ -2559,147 +2652,6 @@ export enum StepTypeEnum {
Recipe = 'RECIPE'
}
/**
*
* @export
* @interface StepFile
*/
export interface StepFile {
/**
*
* @type {string}
* @memberof StepFile
*/
name: string;
/**
*
* @type {any}
* @memberof StepFile
*/
file?: any;
/**
*
* @type {number}
* @memberof StepFile
*/
id?: number;
}
/**
*
* @export
* @interface StepFood
*/
export interface StepFood {
/**
*
* @type {number}
* @memberof StepFood
*/
id?: number;
/**
*
* @type {string}
* @memberof StepFood
*/
name: string;
/**
*
* @type {string}
* @memberof StepFood
*/
description?: string;
/**
*
* @type {FoodRecipe}
* @memberof StepFood
*/
recipe?: FoodRecipe | null;
/**
*
* @type {boolean}
* @memberof StepFood
*/
ignore_shopping?: boolean;
/**
*
* @type {FoodSupermarketCategory}
* @memberof StepFood
*/
supermarket_category?: FoodSupermarketCategory | null;
/**
*
* @type {string}
* @memberof StepFood
*/
parent?: string;
/**
*
* @type {number}
* @memberof StepFood
*/
numchild?: number;
/**
*
* @type {boolean}
* @memberof StepFood
*/
on_hand?: boolean;
}
/**
*
* @export
* @interface StepIngredients
*/
export interface StepIngredients {
/**
*
* @type {number}
* @memberof StepIngredients
*/
id?: number;
/**
*
* @type {StepFood}
* @memberof StepIngredients
*/
food: StepFood | null;
/**
*
* @type {FoodSupermarketCategory}
* @memberof StepIngredients
*/
unit: FoodSupermarketCategory | null;
/**
*
* @type {string}
* @memberof StepIngredients
*/
amount: string;
/**
*
* @type {string}
* @memberof StepIngredients
*/
note?: string | null;
/**
*
* @type {number}
* @memberof StepIngredients
*/
order?: number;
/**
*
* @type {boolean}
* @memberof StepIngredients
*/
is_header?: boolean;
/**
*
* @type {boolean}
* @memberof StepIngredients
*/
no_amount?: boolean;
}
/**
*
* @export

View File

@ -220,6 +220,11 @@ export const ApiMixin = {
return {
Models: Models,
Actions: Actions,
FoodCreateDefault: function(form) {
form.inherit_ignore = getUserPreference("food_ignore_default")
form.inherit = form.supermarket_category.length > 0
return form
},
}
},
methods: {
@ -531,3 +536,11 @@ const specialCases = {
})
},
}
export const formFunctions = {
FoodCreateDefault: function(form) {
form.fields.filter((x) => x.field === "ignore_inherit")[0].value = getUserPreference("food_ignore_default")
form.fields.filter((x) => x.field === "inherit")[0].value = getUserPreference("food_ignore_default").length > 0
return form
},
}