Skip to content

Commit

Permalink
Enhance role and hero forms with color attribute and multiple selecti…
Browse files Browse the repository at this point in the history
…on support
  • Loading branch information
trheyi committed Nov 4, 2024
1 parent 6b7a4e8 commit 46da884
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 17 deletions.
24 changes: 16 additions & 8 deletions forms/hero.form.yao
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,13 @@
},

"Select QueryParam": {
"bind": "identity",
"bind": "identity_multiple",
"edit": {
"type": "Select",
"props": {
"allowClear": true,
"showSearch": true,
"mode": "multiple",
"query": {
"debug": true, // optional. show the debug information

Expand All @@ -440,11 +443,13 @@
// [[ $keywords ]] is the search keywords, xgen request will be send if the search is enabled
// [[ $selected ]] is the selected value, the type could be a number, string or an array. xgen request will be send if some options are selected
"wheres": [
{ "column": "name", "op": "notnull" },
{ "column": "name", "value": "[[ $keywords ]]", "op": "match" }, // if the search is enabled, the query will be executed when the user types in the search box
{
"method": "orwhere",
"column": "name",
"value": "[[ $keywords ]]"
"column": "type",
"op": "in",
"value": "[[ $selected ]]"
} // suggest showing the selected value, if the selected value is not in the search result, it will be added to the search result
],
"limit": 20, // the number of records returned, default is 100. if it's 0, use the default value
Expand All @@ -463,6 +468,8 @@
"edit": {
"type": "Select",
"props": {
"allowClear": true,
"showSearch": true,
"query": {
"debug": true, // optional. show the debug information

Expand All @@ -480,8 +487,9 @@
// [[ $keywords ]] is the search keywords, xgen request will be send if the search is enabled
// [[ $selected ]] is the selected value, the type could be a number, string or an array. xgen request will be send if some options are selected
"wheres": [
{ "field": "name", "is": "not null" },
{ "field": "name", "match": "[[ $keywords ]]" }, // if the search is enabled, the query will be executed when the user types in the search box
{ "or": true, ":value": "[[ $selected ]]" } // suggest showing the selected value, if the selected value is not in the search result, it will be added to the search result
{ "or": true, "field": "value", "eq": "[[ $selected ]]" } // suggest showing the selected value, if the selected value is not in the search result, it will be added to the search result
],

"limit": 20, // the number of records returned, default is 100. if it's 0, use the default value
Expand Down Expand Up @@ -543,12 +551,12 @@
// @see QueryParams for more details
// You can use the query variables
// [[ $keywords ]] is the search keywords, xgen request will be send if the search is enabled
// [[ $selected ]] is the selected value, the type could be a number, string or an array. xgen request will be send if some options are selected
"wheres": [
{ "column": "name", "op": "notnull" },
{ "column": "name", "value": "[[ $keywords ]]", "op": "match" }, // if the search is enabled, the query will be executed when the user types in the search box
{
"method": "orwhere",
"column": "name",
"column": "type",
"value": "[[ $keywords ]]"
} // suggest showing the selected value, if the selected value is not in the search result, it will be added to the search result
],
Expand Down Expand Up @@ -583,10 +591,10 @@
// @see QueryDSL for more details
// You can use the query variables
// [[ $keywords ]] is the search keywords, xgen request will be send if the search is enabled
// [[ $selected ]] is the selected value, the type could be a number, string or an array. xgen request will be send if some options are selected
"wheres": [
{ "field": "name", "is": "not null" },
{ "field": "name", "match": "[[ $keywords ]]" }, // if the search is enabled, the query will be executed when the user types in the search box
{ "or": true, ":value": "[[ $selected ]]" } // suggest showing the selected value, if the selected value is not in the search result, it will be added to the search result
{ "or": true, ":type": "[[ $keywords ]]" } // suggest showing the selected value, if the selected value is not in the search result, it will be added to the search result
],

"limit": 20, // the number of records returned, default is 100. if it's 0, use the default value
Expand Down
3 changes: 2 additions & 1 deletion forms/role.form.yao
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"columns": [
{ "name": "角色名称", "width": 24 },
{ "name": "角色类型", "width": 24 },
{ "name": "图标", "width": 24 }
{ "name": "图标", "width": 24 },
{ "name": "颜色", "width": 24 }
]
}
]
Expand Down
8 changes: 8 additions & 0 deletions models/role.mod.yao
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
"type": "string",
"length": 200,
"nullable": true
},
{
"name": "color",
"label": "颜色",
"comment": "颜色",
"type": "string",
"length": 20,
"nullable": true
}
],
"relations": {},
Expand Down
10 changes: 5 additions & 5 deletions scripts/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ function setData() {

Process(
"models.role.Insert",
["name", "type", "icon"],
["name", "type", "icon", "color"],
[
["法师", "mage", "icon-shield"],
["战士", "fighter", "material-favorite"],
["坦克", "tank", "icon-pocket"],
["辅助", "support", ""],
["法师", "mage", "icon-shield", "primary"],
["战士", "fighter", "material-favorite", "danger"],
["坦克", "tank", "icon-pocket", "success"],
["辅助", "support", "", "warning"],
]
);
}
4 changes: 2 additions & 2 deletions tables/hero.tab.yao
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@
"props": {
"query": {
"from": "role",
"select": ["name", "type"],
"labelField": "name",
"valueField": "type"
"valueField": "type",
"colorField": "color"
}
}
},
Expand Down
14 changes: 13 additions & 1 deletion tables/role.tab.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"columns": [
{ "name": "角色名称" },
{ "name": "角色类型" },
{ "name": "角色图标" }
{ "name": "角色图标" },
{ "name": "角色颜色" }
],
"operation": {
"fold": false,
Expand Down Expand Up @@ -136,6 +137,17 @@
"type": "Input",
"props": {}
}
},
"角色颜色": {
"bind": "color",
"view": {
"type": "Text",
"props": {}
},
"edit": {
"type": "Input",
"props": {}
}
}
}
}
Expand Down

0 comments on commit 46da884

Please sign in to comment.