Software /
code /
prosody
Comparison
teal-src/util/dataforms.d.tl @ 12614:d498e7e7853a
util.dataforms: Restructure Teal definition file
The PR has been merged and there's no reason not to have nested records
and other definitions.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 15 Nov 2021 17:07:23 +0100 |
parent | 11432:113f3912c7cb |
child | 12615:b2047b82ec85 |
comparison
equal
deleted
inserted
replaced
12613:a27870dcaf24 | 12614:d498e7e7853a |
---|---|
1 local stanza_t = require "util.stanza".stanza_t | 1 local stanza_t = require "util.stanza".stanza_t |
2 | 2 |
3 local enum form_type | 3 local record lib |
4 "form" | 4 record dataform |
5 "submit" | 5 title : string |
6 "cancel" | 6 instructions : string |
7 "result" | |
8 end | |
9 | 7 |
10 local enum field_type | 8 record form_field |
11 "boolean" | |
12 "fixed" | |
13 "hidden" | |
14 "jid-multi" | |
15 "jid-single" | |
16 "list-multi" | |
17 "list-single" | |
18 "text-multi" | |
19 "text-private" | |
20 "text-single" | |
21 end | |
22 | 9 |
23 local record form_field | 10 enum field_type |
11 "boolean" | |
12 "fixed" | |
13 "hidden" | |
14 "jid-multi" | |
15 "jid-single" | |
16 "list-multi" | |
17 "list-single" | |
18 "text-multi" | |
19 "text-private" | |
20 "text-single" | |
21 end | |
24 | 22 |
25 type : field_type | 23 type : field_type |
26 var : string -- protocol name | 24 var : string -- protocol name |
27 name : string -- internal name | 25 name : string -- internal name |
28 | 26 |
29 label : string | 27 label : string |
30 desc : string | 28 desc : string |
31 | 29 |
32 datatype : string | 30 datatype : string |
33 range_min : number | 31 range_min : number |
34 range_max : number | 32 range_max : number |
35 | 33 |
36 value : any -- depends on field_type | 34 value : any -- depends on field_type |
37 options : table | 35 options : table |
38 end | 36 end |
39 | 37 |
40 local record dataform | 38 { form_field } |
41 title : string | |
42 instructions : string | |
43 { form_field } -- XXX https://github.com/teal-language/tl/pull/415 | |
44 | 39 |
45 form : function ( dataform, table, form_type ) : stanza_t | 40 enum form_type |
46 end | 41 "form" |
42 "submit" | |
43 "cancel" | |
44 "result" | |
45 end | |
47 | 46 |
48 local record lib | 47 form : function ( dataform, { string : any }, form_type ) : stanza_t |
48 end | |
49 | |
49 new : function ( dataform ) : dataform | 50 new : function ( dataform ) : dataform |
50 end | 51 end |
51 | 52 |
52 return lib | 53 return lib |