Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit e380ed1

Browse files
authored
Nigao/moneyschema (#430)
* money schema * money schema working * fix comments
1 parent 1da14bc commit e380ed1

File tree

7 files changed

+90
-4
lines changed

7 files changed

+90
-4
lines changed

packages/dialog/templates/en-us/common.lg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,14 @@ Please choose a value for @{name(property)} from \[@{join(foreach(turn.dialogEve
145145
- @{join(foreach(dialog.requiredProperties, property, fact(property)), ', ')}
146146

147147
# fact(property)
148+
- IF: @{turn.schema.properties[property].required}
149+
- {"title": "@{name(property)}", "value": "@{join(foreach(turn.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')}"}
150+
- ELSE:
148151
- {"title": "@{name(property)}", "value": "@{value(property, dialog[property])}"}
149152

153+
# subFact(property, subproperty)
154+
- @{dialog[property][subproperty]}
155+
150156
# confirmChange
151157
- Is there any property you want to change? (no or the property name)
152158

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# filename
2+
- @{schemaName}-@{property}.@{locale}.lg
3+
4+
# template
5+
- @{AskTemplate()}\n@{NameTemplate()}\n\[common.lg]
6+
7+
# AskTemplate
8+
- # Ask@{property}\n- @\{askString('@{property}')\}\n
9+
10+
# NameTemplate
11+
- # @{property}Name\n- @{phrase(property, locale)}\n

packages/dialog/templates/en-us/money.lu.lg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# filename
2-
- @{entityFilename()}
2+
- @{schemaName}-money.@{locale}.lu
33

44
# template
55
- $PREBUILT:money @{roles()}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"money": {
4+
"type": "object",
5+
"$mappings": ["money"],
6+
"properties": {
7+
"number": {
8+
"type": "number"
9+
},
10+
"units": {
11+
"type": "string"
12+
}
13+
},
14+
"required": ["number", "units"],
15+
"$templates": ["money.lu","money.lg", "moneyAsk.dialog","moneySet.dialog"]
16+
}
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# filename
2+
- @{schemaName}-@{property}Ask.dialog
3+
4+
# template
5+
- ```
6+
{
7+
"$schema": "@{appSchema}",
8+
"$kind": "Microsoft.OnAsk",
9+
"condition":"!$@{property} && contains(dialog.requiredProperties, '@{property}')",
10+
"actions": [
11+
{
12+
"$kind": "Microsoft.Ask",
13+
"activity": "@{callAsk()}",
14+
"expectedProperties": [
15+
"@{property}"
16+
]
17+
},
18+
]
19+
}
20+
```
21+
22+
# callAsk
23+
- @\{Ask@{property}()}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
# filename
3+
- @{schemaName}-@{property}Setmoney.dialog
4+
5+
# template
6+
- ```
7+
{
8+
"$schema": "@{appSchema}",
9+
"$kind": "Microsoft.OnSetProperty",
10+
"property": "@{property}",
11+
"entity": "money",
12+
"actions": [
13+
{
14+
"$kind": "Microsoft.SetProperty",
15+
"property": "$@{property}.number",
16+
"value": "@money['number']"
17+
},
18+
{
19+
"$kind": "Microsoft.SetProperty",
20+
"property": "$@{property}.units",
21+
"value": "@money['units']"
22+
}
23+
]
24+
}
25+
```

packages/dialog/test/commands/dialog/forms/sandwich.schema

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"$units": "inches"
1818
},
1919
"Name": {
20-
"type": "string"
20+
"type": "string",
21+
"$mappings": [
22+
"personName", "utterance"
23+
]
2124
},
2225
"Bread": {
2326
"type": "string",
@@ -55,14 +58,15 @@
5558
]
5659
},
5760
"Price": {
58-
"$ref": "template:currency.schema#/currency"
61+
"$ref": "template:money.schema#/money"
5962
}
6063
},
6164
"required": [
6265
"Name",
6366
"Bread",
6467
"Meat",
65-
"Cheese"
68+
"Cheese",
69+
"Price"
6670
],
6771
"$requires": [
6872
"standard.schema"

0 commit comments

Comments
 (0)