change ingore_inherit to inherit_fields

This commit is contained in:
smilerz
2021-12-30 12:54:39 -06:00
parent 3fafd43e58
commit 79b4bc387e
18 changed files with 190 additions and 248 deletions

View File

@@ -76,7 +76,7 @@ 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", "food_onhand", "supermarket_category", "inherit", "ignore_inherit"]],
params: [["name", "description", "recipe", "food_onhand", "supermarket_category", "inherit", "inherit_fields"]],
form: {
name: {
@@ -114,19 +114,14 @@ export class Models {
label: i18n.t("Shopping_Category"),
allow_create: true,
},
inherit: {
form_field: true,
type: "checkbox",
field: "inherit",
label: i18n.t("Inherit"),
},
ignore_inherit: {
inherit_fields: {
form_field: true,
type: "lookup",
multiple: true,
field: "ignore_inherit",
field: "inherit_fields",
list: "FOOD_INHERIT_FIELDS",
label: i18n.t("IgnoreInherit"),
label: i18n.t("InheritFields"),
condition: { field: "parent", value: true, condition: "exists" },
},
full_name: {
form_field: true,

View File

@@ -214,7 +214,7 @@ export interface Food {
* @type {boolean}
* @memberof Food
*/
ignore_shopping?: boolean;
food_onhand?: boolean;
/**
*
* @type {FoodSupermarketCategory}
@@ -235,47 +235,16 @@ export interface Food {
numchild?: number;
/**
*
* @type {boolean}
* @type {Array<FoodInheritFields>}
* @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;
inherit_fields?: Array<FoodInheritFields> | null;
/**
*
* @type {string}
* @memberof FoodIgnoreInherit
* @memberof Food
*/
name?: string;
/**
*
* @type {string}
* @memberof FoodIgnoreInherit
*/
field?: string;
full_name?: string;
}
/**
*
@@ -294,13 +263,38 @@ export interface FoodInheritField {
* @type {string}
* @memberof FoodInheritField
*/
name?: string;
name?: string | null;
/**
*
* @type {string}
* @memberof FoodInheritField
*/
field?: string;
field?: string | null;
}
/**
*
* @export
* @interface FoodInheritFields
*/
export interface FoodInheritFields {
/**
*
* @type {number}
* @memberof FoodInheritFields
*/
id?: number;
/**
*
* @type {string}
* @memberof FoodInheritFields
*/
name?: string | null;
/**
*
* @type {string}
* @memberof FoodInheritFields
*/
field?: string | null;
}
/**
*
@@ -513,6 +507,12 @@ export interface ImportLogKeyword {
* @memberof ImportLogKeyword
*/
updated_at?: string;
/**
*
* @type {string}
* @memberof ImportLogKeyword
*/
full_name?: string;
}
/**
*
@@ -610,7 +610,7 @@ export interface IngredientFood {
* @type {boolean}
* @memberof IngredientFood
*/
ignore_shopping?: boolean;
food_onhand?: boolean;
/**
*
* @type {FoodSupermarketCategory}
@@ -631,22 +631,16 @@ export interface IngredientFood {
numchild?: number;
/**
*
* @type {boolean}
* @type {Array<FoodInheritFields>}
* @memberof IngredientFood
*/
on_hand?: boolean;
inherit_fields?: Array<FoodInheritFields> | null;
/**
*
* @type {boolean}
* @type {string}
* @memberof IngredientFood
*/
inherit?: boolean;
/**
*
* @type {Array<FoodIgnoreInherit>}
* @memberof IngredientFood
*/
ignore_inherit?: Array<FoodIgnoreInherit> | null;
full_name?: string;
}
/**
*
@@ -1018,6 +1012,12 @@ export interface Keyword {
* @memberof Keyword
*/
updated_at?: string;
/**
*
* @type {string}
* @memberof Keyword
*/
full_name?: string;
}
/**
*
@@ -1691,6 +1691,12 @@ export interface RecipeKeywords {
* @memberof RecipeKeywords
*/
updated_at?: string;
/**
*
* @type {string}
* @memberof RecipeKeywords
*/
full_name?: string;
}
/**
*
@@ -2996,10 +3002,10 @@ export interface UserPreference {
mealplan_autoadd_shopping?: boolean;
/**
*
* @type {string}
* @type {Array<FoodInheritFields>}
* @memberof UserPreference
*/
food_ignore_default?: string;
food_inherit_default?: Array<FoodInheritFields> | null;
/**
*
* @type {string}
@@ -3042,6 +3048,12 @@ export interface UserPreference {
* @memberof UserPreference
*/
csv_prefix?: string;
/**
*
* @type {boolean}
* @memberof UserPreference
*/
filter_to_supermarket?: boolean;
}
/**

View File

@@ -220,11 +220,6 @@ 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: {
@@ -369,6 +364,7 @@ export function getForm(model, action, item1, item2) {
if (f === "partialUpdate" && Object.keys(config).length == 0) {
config = { ...Actions.CREATE?.form, ...model.model_type?.["create"]?.form, ...model?.["create"]?.form }
config["title"] = { ...action?.form_title, ...model.model_type?.[f]?.form_title, ...model?.[f]?.form_title }
// form functions should not be inherited
if (config?.["form_function"]?.includes("Create")) {
delete config["form_function"]
}
@@ -542,8 +538,7 @@ 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
form.fields.filter((x) => x.field === "inherit_fields")[0].value = getUserPreference("food_inherit_default")
return form
},
}