fix translations in helper libraries models.js and utils.js
This commit is contained in:
@ -1,39 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<b-form-group
|
<b-form-group v-bind:label="label" class="mb-3">
|
||||||
v-bind:label="label"
|
<b-form-select v-model="new_value" :placeholder="placeholder" :options="translatedOptions"></b-form-select>
|
||||||
class="mb-3">
|
|
||||||
<b-form-select v-model="new_value" :placeholder="placeholder" :options="options"></b-form-select>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ChoiceInput',
|
name: "ChoiceInput",
|
||||||
props: {
|
props: {
|
||||||
field: {type: String, default: 'You Forgot To Set Field Name'},
|
field: { type: String, default: "You Forgot To Set Field Name" },
|
||||||
label: {type: String, default: 'Text Field'},
|
label: { type: String, default: "Text Field" },
|
||||||
value: {type: String, default: ''},
|
value: { type: String, default: "" },
|
||||||
options: [],
|
options: [],
|
||||||
placeholder: {type: String, default: 'You Should Add Placeholder Text'},
|
placeholder: { type: String, default: "You Should Add Placeholder Text" },
|
||||||
show_merge: {type: Boolean, default: false},
|
show_merge: { type: Boolean, default: false },
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
new_value: undefined,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.new_value = this.value
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'new_value': function () {
|
|
||||||
this.$root.$emit('change', this.field, this.new_value)
|
|
||||||
},
|
},
|
||||||
},
|
data() {
|
||||||
methods: {
|
return {
|
||||||
}
|
new_value: undefined,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.new_value = this.value
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
new_value: function () {
|
||||||
|
this.$root.$emit("change", this.field, this.new_value)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
translatedOptions() {
|
||||||
|
return this.options.map((x) => {
|
||||||
|
return { ...x, text: this.$t(x.text) }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -67,6 +67,9 @@ export default {
|
|||||||
this.field = this.form?.field ?? "You Forgot To Set Field Name"
|
this.field = this.form?.field ?? "You Forgot To Set Field Name"
|
||||||
this.label = this.form?.label ?? ""
|
this.label = this.form?.label ?? ""
|
||||||
this.sticky_options = this.form?.sticky_options ?? []
|
this.sticky_options = this.form?.sticky_options ?? []
|
||||||
|
this.sticky_options = this.sticky_options.map((x) => {
|
||||||
|
return { ...x, name: this.$t(x.name) }
|
||||||
|
})
|
||||||
this.list_label = this.form?.list_label ?? undefined
|
this.list_label = this.form?.list_label ?? undefined
|
||||||
if (this.list_label?.includes("::")) {
|
if (this.list_label?.includes("::")) {
|
||||||
this.list_label = this.list_label.split("::")[1]
|
this.list_label = this.list_label.split("::")[1]
|
||||||
@ -74,7 +77,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
modelName() {
|
modelName() {
|
||||||
return this?.model?.name ?? this.$t("Search")
|
return this.$t(this?.model?.name) ?? this.$t("Search")
|
||||||
},
|
},
|
||||||
useMultiple() {
|
useMultiple() {
|
||||||
return this.form?.multiple || this.form?.ordered || false
|
return this.form?.multiple || this.form?.ordered || false
|
||||||
|
@ -334,5 +334,6 @@
|
|||||||
"last_viewed": "Letztens besucht",
|
"last_viewed": "Letztens besucht",
|
||||||
"sort_by": "Sortiere nach",
|
"sort_by": "Sortiere nach",
|
||||||
"Random Recipes": "Zufällige Rezepte",
|
"Random Recipes": "Zufällige Rezepte",
|
||||||
"recipe_filter": "Rezept-Filter"
|
"recipe_filter": "Rezept-Filter",
|
||||||
|
"parameter_count": "Parameter {count}"
|
||||||
}
|
}
|
||||||
|
@ -360,5 +360,6 @@
|
|||||||
"Ratings": "Ratings",
|
"Ratings": "Ratings",
|
||||||
"Internal": "Internal",
|
"Internal": "Internal",
|
||||||
"Units": "Units",
|
"Units": "Units",
|
||||||
"Random Recipes": "Random Recipes"
|
"Random Recipes": "Random Recipes",
|
||||||
|
"parameter_count": "Parameter {count}"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Utility CLASS to define model configurations
|
* Utility CLASS to define model configurations
|
||||||
* */
|
* */
|
||||||
import i18n from "@/i18n"
|
|
||||||
|
|
||||||
// TODO this needs rethought and simplified
|
// TODO this needs rethought and simplified
|
||||||
// maybe a function that returns a single dictionary based on action?
|
// maybe a function that returns a single dictionary based on action?
|
||||||
@ -51,7 +50,7 @@ export class Models {
|
|||||||
type: "lookup",
|
type: "lookup",
|
||||||
field: "target",
|
field: "target",
|
||||||
list: "self",
|
list: "self",
|
||||||
sticky_options: [{ id: 0, name: i18n.t("tree_root") }],
|
sticky_options: [{ id: 0, name: "tree_root" }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -59,7 +58,7 @@ export class Models {
|
|||||||
|
|
||||||
// MODELS - inherits and takes precedence over MODEL_TYPES and ACTIONS
|
// MODELS - inherits and takes precedence over MODEL_TYPES and ACTIONS
|
||||||
static FOOD = {
|
static FOOD = {
|
||||||
name: i18n.t("Food"), // *OPTIONAL* : parameters will be built model -> model_type -> default
|
name: "Food", // *OPTIONAL* : parameters will be built model -> model_type -> default
|
||||||
apiName: "Food", // *REQUIRED* : the name that is used in api.ts for this model
|
apiName: "Food", // *REQUIRED* : the name that is used in api.ts for this model
|
||||||
model_type: this.TREE, // *OPTIONAL* : model specific params for api, if not present will attempt modeltype_create then default_create
|
model_type: this.TREE, // *OPTIONAL* : model specific params for api, if not present will attempt modeltype_create then default_create
|
||||||
paginated: true,
|
paginated: true,
|
||||||
@ -100,15 +99,15 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "", // form.placeholder always translated
|
||||||
subtitle_field: "full_name",
|
subtitle_field: "full_name",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
recipe: {
|
recipe: {
|
||||||
@ -116,31 +115,31 @@ export class Models {
|
|||||||
type: "lookup",
|
type: "lookup",
|
||||||
field: "recipe",
|
field: "recipe",
|
||||||
list: "RECIPE",
|
list: "RECIPE",
|
||||||
label: i18n.t("Recipe"),
|
label: "Recipe", // form.label always translated in utils.getForm()
|
||||||
help_text: i18n.t("food_recipe_help"),
|
help_text: "food_recipe_help", // form.help_text always translated
|
||||||
},
|
},
|
||||||
onhand: {
|
onhand: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
field: "food_onhand",
|
field: "food_onhand",
|
||||||
label: i18n.t("OnHand"),
|
label: "OnHand",
|
||||||
help_text: i18n.t("OnHand_help"),
|
help_text: "OnHand_help",
|
||||||
},
|
},
|
||||||
ignore_shopping: {
|
ignore_shopping: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
field: "ignore_shopping",
|
field: "ignore_shopping",
|
||||||
label: i18n.t("Ignore_Shopping"),
|
label: "Ignore_Shopping",
|
||||||
help_text: i18n.t("ignore_shopping_help"),
|
help_text: "ignore_shopping_help",
|
||||||
},
|
},
|
||||||
shopping_category: {
|
shopping_category: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "lookup",
|
type: "lookup",
|
||||||
field: "supermarket_category",
|
field: "supermarket_category",
|
||||||
list: "SHOPPING_CATEGORY",
|
list: "SHOPPING_CATEGORY",
|
||||||
label: i18n.t("Shopping_Category"),
|
label: "Shopping_Category",
|
||||||
allow_create: true,
|
allow_create: true,
|
||||||
help_text: i18n.t("shopping_category_help"),
|
help_text: "shopping_category_help", // form.help_text always translated
|
||||||
},
|
},
|
||||||
substitute: {
|
substitute: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -149,17 +148,17 @@ export class Models {
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
field: "substitute",
|
field: "substitute",
|
||||||
list: "FOOD",
|
list: "FOOD",
|
||||||
label: i18n.t("Substitutes"),
|
label: "Substitutes",
|
||||||
allow_create: false,
|
allow_create: false,
|
||||||
help_text: i18n.t("substitute_help"),
|
help_text: "substitute_help",
|
||||||
},
|
},
|
||||||
substitute_siblings: {
|
substitute_siblings: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
advanced: true,
|
advanced: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
field: "substitute_siblings",
|
field: "substitute_siblings",
|
||||||
label: i18n.t("substitute_siblings"),
|
label: "substitute_siblings", // form.label always translated in utils.getForm()
|
||||||
help_text: i18n.t("substitute_siblings_help"),
|
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: {
|
substitute_children: {
|
||||||
@ -167,8 +166,8 @@ export class Models {
|
|||||||
advanced: true,
|
advanced: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
field: "substitute_children",
|
field: "substitute_children",
|
||||||
label: i18n.t("substitute_children"),
|
label: "substitute_children",
|
||||||
help_text: i18n.t("substitute_children_help"),
|
help_text: "substitute_children_help",
|
||||||
condition: { field: "numchild", value: 0, condition: "gt" },
|
condition: { field: "numchild", value: 0, condition: "gt" },
|
||||||
},
|
},
|
||||||
inherit_fields: {
|
inherit_fields: {
|
||||||
@ -178,9 +177,9 @@ export class Models {
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
field: "inherit_fields",
|
field: "inherit_fields",
|
||||||
list: "FOOD_INHERIT_FIELDS",
|
list: "FOOD_INHERIT_FIELDS",
|
||||||
label: i18n.t("InheritFields"),
|
label: "InheritFields",
|
||||||
condition: { field: "food_children_exist", value: true, condition: "preference_equals" },
|
condition: { field: "food_children_exist", value: true, condition: "preference_equals" },
|
||||||
help_text: i18n.t("InheritFields_help"),
|
help_text: "InheritFields_help",
|
||||||
},
|
},
|
||||||
child_inherit_fields: {
|
child_inherit_fields: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -189,17 +188,17 @@ export class Models {
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
field: "child_inherit_fields",
|
field: "child_inherit_fields",
|
||||||
list: "FOOD_INHERIT_FIELDS",
|
list: "FOOD_INHERIT_FIELDS",
|
||||||
label: i18n.t("ChildInheritFields"),
|
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: i18n.t("ChildInheritFields_help"),
|
help_text: "ChildInheritFields_help", // form.help_text always translated
|
||||||
},
|
},
|
||||||
reset_inherit: {
|
reset_inherit: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
advanced: true,
|
advanced: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
field: "reset_inherit",
|
field: "reset_inherit",
|
||||||
label: i18n.t("reset_children"),
|
label: "reset_children",
|
||||||
help_text: i18n.t("reset_children_help"),
|
help_text: "reset_children_help",
|
||||||
condition: { field: "numchild", value: 0, condition: "gt" },
|
condition: { field: "numchild", value: 0, condition: "gt" },
|
||||||
},
|
},
|
||||||
form_function: "FoodCreateDefault",
|
form_function: "FoodCreateDefault",
|
||||||
@ -215,7 +214,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static KEYWORD = {
|
static KEYWORD = {
|
||||||
name: i18n.t("Keyword"), // *OPTIONAL: parameters will be built model -> model_type -> default
|
name: "Keyword", // *OPTIONAL: parameters will be built model -> model_type -> default
|
||||||
apiName: "Keyword",
|
apiName: "Keyword",
|
||||||
model_type: this.TREE,
|
model_type: this.TREE,
|
||||||
paginated: true,
|
paginated: true,
|
||||||
@ -232,21 +231,21 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "emoji",
|
type: "emoji",
|
||||||
field: "icon",
|
field: "icon",
|
||||||
label: i18n.t("Icon"),
|
label: "Icon",
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -258,7 +257,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static UNIT = {
|
static UNIT = {
|
||||||
name: i18n.t("Unit"),
|
name: "Unit",
|
||||||
apiName: "Unit",
|
apiName: "Unit",
|
||||||
paginated: true,
|
paginated: true,
|
||||||
create: {
|
create: {
|
||||||
@ -268,14 +267,14 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -284,7 +283,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SHOPPING_LIST = {
|
static SHOPPING_LIST = {
|
||||||
name: i18n.t("Shopping_list"),
|
name: "Shopping_list",
|
||||||
apiName: "ShoppingListEntry",
|
apiName: "ShoppingListEntry",
|
||||||
list: {
|
list: {
|
||||||
params: ["id", "checked", "supermarket", "options"],
|
params: ["id", "checked", "supermarket", "options"],
|
||||||
@ -297,7 +296,7 @@ export class Models {
|
|||||||
type: "lookup",
|
type: "lookup",
|
||||||
field: "unit",
|
field: "unit",
|
||||||
list: "UNIT",
|
list: "UNIT",
|
||||||
label: i18n.t("Unit"),
|
label: "Unit",
|
||||||
allow_create: true,
|
allow_create: true,
|
||||||
},
|
},
|
||||||
food: {
|
food: {
|
||||||
@ -305,7 +304,7 @@ export class Models {
|
|||||||
type: "lookup",
|
type: "lookup",
|
||||||
field: "food",
|
field: "food",
|
||||||
list: "FOOD",
|
list: "FOOD",
|
||||||
label: i18n.t("Food"),
|
label: "Food", // form.label always translated in utils.getForm()
|
||||||
allow_create: true,
|
allow_create: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -313,7 +312,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static RECIPE_BOOK = {
|
static RECIPE_BOOK = {
|
||||||
name: i18n.t("Recipe_Book"),
|
name: "Recipe_Book",
|
||||||
apiName: "RecipeBook",
|
apiName: "RecipeBook",
|
||||||
create: {
|
create: {
|
||||||
params: [["name", "description", "icon", "filter"]],
|
params: [["name", "description", "icon", "filter"]],
|
||||||
@ -322,27 +321,27 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "emoji",
|
type: "emoji",
|
||||||
field: "icon",
|
field: "icon",
|
||||||
label: i18n.t("Icon"),
|
label: "Icon",
|
||||||
},
|
},
|
||||||
filter: {
|
filter: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "lookup",
|
type: "lookup",
|
||||||
field: "filter",
|
field: "filter",
|
||||||
label: i18n.t("Custom Filter"),
|
label: "Custom Filter",
|
||||||
list: "CUSTOM_FILTER",
|
list: "CUSTOM_FILTER",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -350,7 +349,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SHOPPING_CATEGORY = {
|
static SHOPPING_CATEGORY = {
|
||||||
name: i18n.t("Shopping_Category"),
|
name: "Shopping_Category",
|
||||||
apiName: "SupermarketCategory",
|
apiName: "SupermarketCategory",
|
||||||
create: {
|
create: {
|
||||||
params: [["name", "description"]],
|
params: [["name", "description"]],
|
||||||
@ -359,14 +358,14 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -374,7 +373,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SHOPPING_CATEGORY_RELATION = {
|
static SHOPPING_CATEGORY_RELATION = {
|
||||||
name: i18n.t("Shopping_Category_Relation"),
|
name: "Shopping_Category_Relation",
|
||||||
apiName: "SupermarketCategoryRelation",
|
apiName: "SupermarketCategoryRelation",
|
||||||
create: {
|
create: {
|
||||||
params: [["category", "supermarket", "order"]],
|
params: [["category", "supermarket", "order"]],
|
||||||
@ -383,14 +382,14 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -398,7 +397,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SUPERMARKET = {
|
static SUPERMARKET = {
|
||||||
name: i18n.t("Supermarket"),
|
name: "Supermarket",
|
||||||
apiName: "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: {
|
create: {
|
||||||
@ -408,14 +407,14 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
categories: {
|
categories: {
|
||||||
@ -425,7 +424,7 @@ export class Models {
|
|||||||
list_label: "category::name",
|
list_label: "category::name",
|
||||||
ordered: true, // ordered lookups assume working with relation field
|
ordered: true, // ordered lookups assume working with relation field
|
||||||
field: "category_to_supermarket",
|
field: "category_to_supermarket",
|
||||||
label: i18n.t("Categories"),
|
label: "Categories", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -441,7 +440,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static AUTOMATION = {
|
static AUTOMATION = {
|
||||||
name: i18n.t("Automation"),
|
name: "Automation",
|
||||||
apiName: "Automation",
|
apiName: "Automation",
|
||||||
paginated: true,
|
paginated: true,
|
||||||
list: {
|
list: {
|
||||||
@ -456,47 +455,74 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "description",
|
field: "description",
|
||||||
label: i18n.t("Description"),
|
label: "Description",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "choice",
|
type: "choice",
|
||||||
options: [
|
options: [
|
||||||
{ value: "FOOD_ALIAS", text: i18n.t("Food_Alias") },
|
{ value: "FOOD_ALIAS", text: "Food_Alias" },
|
||||||
{ value: "UNIT_ALIAS", text: i18n.t("Unit_Alias") },
|
{ value: "UNIT_ALIAS", text: "Unit_Alias" },
|
||||||
{ value: "KEYWORD_ALIAS", text: i18n.t("Keyword_Alias") },
|
{ value: "KEYWORD_ALIAS", text: "Keyword_Alias" },
|
||||||
],
|
],
|
||||||
field: "type",
|
field: "type",
|
||||||
label: i18n.t("Type"),
|
label: "Type",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
param_1: {
|
param_1: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "param_1",
|
field: "param_1",
|
||||||
label: i18n.t("Parameter") + " 1",
|
label: {
|
||||||
|
function: "translate",
|
||||||
|
phrase: "parameter_count",
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
token: "count",
|
||||||
|
attribute: "1",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
param_2: {
|
param_2: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "param_2",
|
field: "param_2",
|
||||||
label: i18n.t("Parameter") + " 2",
|
label: {
|
||||||
|
function: "translate",
|
||||||
|
phrase: "parameter_count",
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
token: "count",
|
||||||
|
attribute: "2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
param_3: {
|
param_3: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "param_3",
|
field: "param_3",
|
||||||
label: i18n.t("Parameter") + " 3",
|
label: {
|
||||||
|
function: "translate",
|
||||||
|
phrase: "parameter_count",
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
token: "count",
|
||||||
|
attribute: "3",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -504,7 +530,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static RECIPE = {
|
static RECIPE = {
|
||||||
name: i18n.t("Recipe"),
|
name: "Recipe",
|
||||||
apiName: "Recipe",
|
apiName: "Recipe",
|
||||||
list: {
|
list: {
|
||||||
params: [
|
params: [
|
||||||
@ -546,7 +572,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CUSTOM_FILTER = {
|
static CUSTOM_FILTER = {
|
||||||
name: i18n.t("Custom Filter"),
|
name: "Custom Filter",
|
||||||
apiName: "CustomFilter",
|
apiName: "CustomFilter",
|
||||||
|
|
||||||
create: {
|
create: {
|
||||||
@ -556,7 +582,7 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -566,14 +592,14 @@ export class Models {
|
|||||||
field: "shared",
|
field: "shared",
|
||||||
list: "USER",
|
list: "USER",
|
||||||
list_label: "username",
|
list_label: "username",
|
||||||
label: i18n.t("shared_with"),
|
label: "shared_with",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
static USER_NAME = {
|
static USER_NAME = {
|
||||||
name: i18n.t("User"),
|
name: "User",
|
||||||
apiName: "User",
|
apiName: "User",
|
||||||
list: {
|
list: {
|
||||||
params: ["filter_list"],
|
params: ["filter_list"],
|
||||||
@ -581,7 +607,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static MEAL_TYPE = {
|
static MEAL_TYPE = {
|
||||||
name: i18n.t("Meal_Type"),
|
name: "Meal_Type",
|
||||||
apiName: "MealType",
|
apiName: "MealType",
|
||||||
list: {
|
list: {
|
||||||
params: ["filter_list"],
|
params: ["filter_list"],
|
||||||
@ -589,7 +615,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static MEAL_PLAN = {
|
static MEAL_PLAN = {
|
||||||
name: i18n.t("Meal_Plan"),
|
name: "Meal_Plan",
|
||||||
apiName: "MealPlan",
|
apiName: "MealPlan",
|
||||||
list: {
|
list: {
|
||||||
params: ["options"],
|
params: ["options"],
|
||||||
@ -597,7 +623,7 @@ export class Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static USERFILE = {
|
static USERFILE = {
|
||||||
name: i18n.t("File"),
|
name: "File",
|
||||||
apiName: "UserFile",
|
apiName: "UserFile",
|
||||||
paginated: false,
|
paginated: false,
|
||||||
list: {
|
list: {
|
||||||
@ -612,27 +638,27 @@ export class Models {
|
|||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: "Name",
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
file: {
|
file: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "file",
|
type: "file",
|
||||||
field: "file",
|
field: "file",
|
||||||
label: i18n.t("File"),
|
label: "File", // form.label always translated in utils.getForm()
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
static USER = {
|
static USER = {
|
||||||
name: i18n.t("User"),
|
name: "User",
|
||||||
apiName: "User",
|
apiName: "User",
|
||||||
paginated: false,
|
paginated: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
static STEP = {
|
static STEP = {
|
||||||
name: i18n.t("Step"),
|
name: "Step",
|
||||||
apiName: "Step",
|
apiName: "Step",
|
||||||
list: {
|
list: {
|
||||||
params: ["recipe", "query", "page", "pageSize", "options"],
|
params: ["recipe", "query", "page", "pageSize", "options"],
|
||||||
@ -652,10 +678,11 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ok_label: i18n.t("Save"),
|
ok_label: { function: "translate", phrase: "Save" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
static UPDATE = {
|
static UPDATE = {
|
||||||
@ -669,6 +696,7 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -685,10 +713,11 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ok_label: i18n.t("Delete"),
|
ok_label: { function: "translate", phrase: "Delete" },
|
||||||
instruction: {
|
instruction: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "instruction",
|
type: "instruction",
|
||||||
@ -736,10 +765,11 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ok_label: i18n.t("Merge"),
|
ok_label: { function: "translate", phrase: "Merge" },
|
||||||
instruction: {
|
instruction: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "instruction",
|
type: "instruction",
|
||||||
@ -756,6 +786,7 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -784,10 +815,11 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ok_label: i18n.t("Move"),
|
ok_label: { function: "translate", phrase: "Move" },
|
||||||
instruction: {
|
instruction: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "instruction",
|
type: "instruction",
|
||||||
@ -804,6 +836,7 @@ export class Actions {
|
|||||||
token: "type",
|
token: "type",
|
||||||
from: "model",
|
from: "model",
|
||||||
attribute: "name",
|
attribute: "name",
|
||||||
|
translate: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -346,7 +346,7 @@ export function getConfig(model, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
name: model.name,
|
name: i18n.t(model.name),
|
||||||
apiName: model.apiName,
|
apiName: model.apiName,
|
||||||
}
|
}
|
||||||
// spread operator merges dictionaries - last item in list takes precedence
|
// spread operator merges dictionaries - last item in list takes precedence
|
||||||
@ -388,8 +388,11 @@ export function getForm(model, action, item1, item2) {
|
|||||||
value = v
|
value = v
|
||||||
}
|
}
|
||||||
if (value?.form_field) {
|
if (value?.form_field) {
|
||||||
|
for (const [i, h] of Object.entries(value)) {
|
||||||
|
// console.log("formfield", i)
|
||||||
|
}
|
||||||
value["value"] = item1?.[value?.field] ?? undefined
|
value["value"] = item1?.[value?.field] ?? undefined
|
||||||
value["help"] = item1?.[value?.help_text_field] ?? value?.help_text ?? undefined
|
value["help"] = item1?.[value?.help_text_field] ?? formTranslate(value?.help_text) ?? undefined
|
||||||
value["subtitle"] = item1?.[value?.subtitle_field] ?? value?.subtitle ?? undefined
|
value["subtitle"] = item1?.[value?.subtitle_field] ?? value?.subtitle ?? undefined
|
||||||
form.fields.push({
|
form.fields.push({
|
||||||
...value,
|
...value,
|
||||||
@ -406,23 +409,31 @@ export function getForm(model, action, item1, item2) {
|
|||||||
}
|
}
|
||||||
function formTranslate(translate, model, item1, item2) {
|
function formTranslate(translate, model, item1, item2) {
|
||||||
if (typeof translate !== "object") {
|
if (typeof translate !== "object") {
|
||||||
return translate
|
return i18n.t(translate)
|
||||||
}
|
}
|
||||||
let phrase = translate.phrase
|
let phrase = translate.phrase
|
||||||
let options = {}
|
let options = {}
|
||||||
let obj = undefined
|
let value = undefined
|
||||||
translate?.params.forEach(function (x, index) {
|
translate?.params?.forEach(function (x, index) {
|
||||||
switch (x.from) {
|
switch (x?.from) {
|
||||||
case "item1":
|
case "item1":
|
||||||
obj = item1
|
value = item1[x.attribute]
|
||||||
break
|
break
|
||||||
case "item2":
|
case "item2":
|
||||||
obj = item2
|
value = item2[x.attribute]
|
||||||
break
|
break
|
||||||
case "model":
|
case "model":
|
||||||
obj = model
|
value = model[x.attribute]
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
value = x.attribute
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x.translate) {
|
||||||
|
options[x.token] = i18n.t(value)
|
||||||
|
} else {
|
||||||
|
options[x.token] = value
|
||||||
}
|
}
|
||||||
options[x.token] = obj[x.attribute]
|
|
||||||
})
|
})
|
||||||
return i18n.t(phrase, options)
|
return i18n.t(phrase, options)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user