add NEVER_UNIT automation

This commit is contained in:
smilerz
2023-04-24 10:59:48 -05:00
parent 5d5eb45b5a
commit 8fa00972bd
6 changed files with 178 additions and 82 deletions

View File

@ -23,7 +23,7 @@ export class Models {
false: undefined,
},
},
tree: {default: undefined},
tree: { default: undefined },
},
},
delete: {
@ -50,7 +50,7 @@ export class Models {
type: "lookup",
field: "target",
list: "self",
sticky_options: [{id: 0, name: "tree_root"}],
sticky_options: [{ id: 0, name: "tree_root" }],
},
},
},
@ -71,7 +71,7 @@ export class Models {
food_onhand: true,
shopping: true,
},
tags: [{field: "supermarket_category", label: "name", color: "info"}],
tags: [{ field: "supermarket_category", label: "name", color: "info" }],
// REQUIRED: unordered array of fields that can be set during create
create: {
// if not defined partialUpdate will use the same parameters, prepending 'id'
@ -177,7 +177,7 @@ export class Models {
field: "substitute_siblings",
label: "substitute_siblings", // form.label always translated in utils.getForm()
help_text: "substitute_siblings_help", // form.help_text always translated
condition: {field: "parent", value: true, condition: "field_exists"},
condition: { field: "parent", value: true, condition: "field_exists" },
},
substitute_children: {
form_field: true,
@ -186,7 +186,7 @@ export class Models {
field: "substitute_children",
label: "substitute_children",
help_text: "substitute_children_help",
condition: {field: "numchild", value: 0, condition: "gt"},
condition: { field: "numchild", value: 0, condition: "gt" },
},
inherit_fields: {
form_field: true,
@ -196,7 +196,7 @@ export class Models {
field: "inherit_fields",
list: "FOOD_INHERIT_FIELDS",
label: "InheritFields",
condition: {field: "food_children_exist", value: true, condition: "preference_equals"},
condition: { field: "food_children_exist", value: true, condition: "preference_equals" },
help_text: "InheritFields_help",
},
child_inherit_fields: {
@ -207,7 +207,7 @@ export class Models {
field: "child_inherit_fields",
list: "FOOD_INHERIT_FIELDS",
label: "ChildInheritFields", // form.label always translated in utils.getForm()
condition: {field: "numchild", value: 0, condition: "gt"},
condition: { field: "numchild", value: 0, condition: "gt" },
help_text: "ChildInheritFields_help", // form.help_text always translated
},
reset_inherit: {
@ -217,7 +217,7 @@ export class Models {
field: "reset_inherit",
label: "reset_children",
help_text: "reset_children_help",
condition: {field: "numchild", value: 0, condition: "gt"},
condition: { field: "numchild", value: 0, condition: "gt" },
},
form_function: "FoodCreateDefault",
},
@ -281,7 +281,7 @@ export class Models {
apiName: "Unit",
paginated: true,
create: {
params: [["name", "plural_name", "description", "base_unit", "open_data_slug",]],
params: [["name", "plural_name", "description", "base_unit", "open_data_slug"]],
form: {
show_help: true,
name: {
@ -311,24 +311,24 @@ export class Models {
form_field: true,
type: "choice",
options: [
{value: "g", text: "g"},
{value: "kg", text: "kg"},
{value: "ounce", text: "ounce"},
{value: "pound", text: "pound"},
{value: "ml", text: "ml"},
{value: "l", text: "l"},
{value: "fluid_ounce", text: "fluid_ounce"},
{value: "pint", text: "pint"},
{value: "quart", text: "quart"},
{value: "gallon", text: "gallon"},
{value: "tbsp", text: "tbsp"},
{value: "tsp", text: "tsp"},
{value: "imperial_fluid_ounce", text: "imperial_fluid_ounce"},
{value: "imperial_pint", text: "imperial_pint"},
{value: "imperial_quart", text: "imperial_quart"},
{value: "imperial_gallon", text: "imperial_gallon"},
{value: "imperial_tbsp", text: "imperial_tbsp"},
{value: "imperial_tsp", text: "imperial_tsp"},
{ value: "g", text: "g" },
{ value: "kg", text: "kg" },
{ value: "ounce", text: "ounce" },
{ value: "pound", text: "pound" },
{ value: "ml", text: "ml" },
{ value: "l", text: "l" },
{ value: "fluid_ounce", text: "fluid_ounce" },
{ value: "pint", text: "pint" },
{ value: "quart", text: "quart" },
{ value: "gallon", text: "gallon" },
{ value: "tbsp", text: "tbsp" },
{ value: "tsp", text: "tsp" },
{ value: "imperial_fluid_ounce", text: "imperial_fluid_ounce" },
{ value: "imperial_pint", text: "imperial_pint" },
{ value: "imperial_quart", text: "imperial_quart" },
{ value: "imperial_gallon", text: "imperial_gallon" },
{ value: "imperial_tbsp", text: "imperial_tbsp" },
{ value: "imperial_tsp", text: "imperial_tsp" },
],
field: "base_unit",
label: "Base Unit",
@ -470,7 +470,7 @@ export class Models {
static SUPERMARKET = {
name: "Supermarket",
apiName: "Supermarket",
ordered_tags: [{field: "category_to_supermarket", label: "category::name", color: "info"}],
ordered_tags: [{ field: "category_to_supermarket", label: "category::name", color: "info" }],
create: {
params: [["name", "description", "category_to_supermarket"]],
form: {
@ -553,11 +553,11 @@ export class Models {
form_field: true,
type: "choice",
options: [
{value: "FOOD_ALIAS", text: "Food_Alias"},
{value: "UNIT_ALIAS", text: "Unit_Alias"},
{value: "KEYWORD_ALIAS", text: "Keyword_Alias"},
{value: "DESCRIPTION_REPLACE", text: "Description_Replace"},
{value: "INSTRUCTION_REPLACE", text: "Instruction_Replace"},
{ value: "FOOD_ALIAS", text: "Food_Alias" },
{ value: "UNIT_ALIAS", text: "Unit_Alias" },
{ value: "KEYWORD_ALIAS", text: "Keyword_Alias" },
{ value: "DESCRIPTION_REPLACE", text: "Description_Replace" },
{ value: "INSTRUCTION_REPLACE", text: "Instruction_Replace" },
],
field: "type",
label: "Type",
@ -625,9 +625,8 @@ export class Models {
label: "Disabled",
placeholder: "",
},
form_function: "AutomationOrderDefault"
form_function: "AutomationOrderDefault",
},
},
}
@ -641,7 +640,7 @@ export class Models {
},
},
create: {
params: [['food', 'base_amount', 'base_unit', 'converted_amount', 'converted_unit', 'open_data_slug']],
params: [["food", "base_amount", "base_unit", "converted_amount", "converted_unit", "open_data_slug"]],
form: {
show_help: true,
// TODO add proper help texts for everything
@ -695,9 +694,7 @@ export class Models {
help_text: "open_data_help_text",
optional: true,
},
},
},
}
@ -711,7 +708,7 @@ export class Models {
},
},
create: {
params: [['name', 'icon', 'unit', 'description','order']],
params: [["name", "icon", "unit", "description", "order"]],
form: {
show_help: true,
name: {
@ -764,7 +761,6 @@ export class Models {
optional: true,
},
},
},
}
@ -852,7 +848,7 @@ export class Models {
params: ["filter_list"],
},
create: {
params: [["name",]],
params: [["name"]],
form: {
name: {
form_field: true,
@ -1017,7 +1013,7 @@ export class Actions {
},
],
},
ok_label: {function: "translate", phrase: "Save"},
ok_label: { function: "translate", phrase: "Save" },
},
}
static UPDATE = {
@ -1052,7 +1048,7 @@ export class Actions {
},
],
},
ok_label: {function: "translate", phrase: "Delete"},
ok_label: { function: "translate", phrase: "Delete" },
instruction: {
form_field: true,
type: "instruction",
@ -1079,17 +1075,17 @@ export class Actions {
suffix: "s",
params: ["query", "page", "pageSize", "options"],
config: {
query: {default: undefined},
page: {default: 1},
pageSize: {default: 25},
query: { default: undefined },
page: { default: 1 },
pageSize: { default: 25 },
},
}
static MERGE = {
function: "merge",
params: ["source", "target"],
config: {
source: {type: "string"},
target: {type: "string"},
source: { type: "string" },
target: { type: "string" },
},
form: {
title: {
@ -1104,7 +1100,7 @@ export class Actions {
},
],
},
ok_label: {function: "translate", phrase: "Merge"},
ok_label: { function: "translate", phrase: "Merge" },
instruction: {
form_field: true,
type: "instruction",
@ -1138,8 +1134,8 @@ export class Actions {
function: "move",
params: ["source", "target"],
config: {
source: {type: "string"},
target: {type: "string"},
source: { type: "string" },
target: { type: "string" },
},
form: {
title: {
@ -1154,7 +1150,7 @@ export class Actions {
},
],
},
ok_label: {function: "translate", phrase: "Move"},
ok_label: { function: "translate", phrase: "Move" },
instruction: {
form_field: true,
type: "instruction",