food edit modal - reset children inheritance
This commit is contained in:
@ -1029,6 +1029,7 @@ export default {
|
||||
if (!this.searchFiltered()) {
|
||||
params.options.query.last_viewed = this.ui.recently_viewed
|
||||
}
|
||||
console.log(params)
|
||||
return params
|
||||
},
|
||||
searchFiltered: function (ignore_string = false) {
|
||||
|
@ -271,29 +271,27 @@ export default {
|
||||
if (type_match && field?.condition) {
|
||||
const value = this.item1[field?.condition?.field]
|
||||
const preference = getUserPreference(field?.condition?.field)
|
||||
console.log("condition", field?.condition?.condition)
|
||||
checks = false
|
||||
switch (field?.condition?.condition) {
|
||||
case "field_exists":
|
||||
if ((value != undefined) === field.condition.value) {
|
||||
checks = true
|
||||
} else {
|
||||
checks = false
|
||||
}
|
||||
break
|
||||
case "preference__array_exists":
|
||||
if (preference?.length > 0 === field.condition.value) {
|
||||
checks = true
|
||||
} else {
|
||||
checks = false
|
||||
}
|
||||
break
|
||||
case "preference_equals":
|
||||
if (preference === field.condition.value) {
|
||||
checks = true
|
||||
} else {
|
||||
checks = false
|
||||
}
|
||||
break
|
||||
case "gt":
|
||||
if (value > field.condition.value) {
|
||||
checks = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return type_match && checks
|
||||
|
@ -326,5 +326,6 @@
|
||||
"make_now": "Make Now",
|
||||
"recipe_filter": "Recipe Filter",
|
||||
"book_filter_help": "Include recipes from recipe filter instead of assigning each recipe",
|
||||
"filter": "Filter"
|
||||
"reset_children": "Reset Child Inheritance",
|
||||
"reset_children_help": "Overwrite all children with values from inherited fields."
|
||||
}
|
||||
|
@ -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", "inherit_fields", "ignore_shopping"]],
|
||||
params: [["name", "description", "recipe", "food_onhand", "supermarket_category", "inherit", "inherit_fields", "ignore_shopping", "reset_inherit"]],
|
||||
|
||||
form: {
|
||||
show_help: true,
|
||||
@ -135,6 +135,14 @@ export class Models {
|
||||
label: i18n.t("InheritFields"),
|
||||
condition: { field: "food_children_exist", value: true, condition: "preference_equals" },
|
||||
},
|
||||
reset_inherit: {
|
||||
form_field: true,
|
||||
type: "checkbox",
|
||||
field: "reset_inherit",
|
||||
label: i18n.t("reset_children"),
|
||||
help_text: i18n.t("reset_children_help"),
|
||||
condition: { field: "numchild", value: 0, condition: "gt" },
|
||||
},
|
||||
form_function: "FoodCreateDefault",
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user