columns.anubis
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 13/02/2016
* Time: 10:07
* © Calexium
*/
read tools/basis.anubis
transmit help.anubis
transmit fields.anubis
transmit calexium_lib/web/CXM_json.anubis
transmit hayamiki_lib/model/types/hk_model_column.anubis
transmit hayamiki_lib/model/types/hk_model_attr.anubis
transmit hayamiki_lib/model/types/hk_help_text.anubis
public define JsonValue
to_JSON
(
HK_Model_Attr hk_model_attr
)=
with members =
if hk_model_attr is
{
unique then [ json_member("hk_column_attr", json_string("unique")) ],
// indexed then [ json_member("hk_column_attr", json_string("indexed")) ],
default(value) then [ json_member("hk_column_attr", json_string("default")),
json_member("value", json_string(value))
],
not_null then [ json_member("hk_column_attr", json_string("not_null")) ]
},
json_object("_HK_COLUMN_ATTRIBUTES", members).
'HK_Model_Column' (describing a column in a table).
Description of a column:
/****** DEFAULT CONSTRUCTOR HELPER - part *******/
public define HK_Model_Column
/* Constructor helper for hk_column without help attribute.
the real type constructor will be called with the attribute no_help_text
*/
hk_column
(
String name,
HK_Model_Field type,
List(HK_Model_Attr) attributes,
)=
hk_column(name, type, attributes, no_help_text).
public define HK_Model_Column
hk_column
(
String name,
HK_Model_Field type
)=
hk_column(name, type, [], no_help_text).
_HK_COLUMN message format:
==========================
+--------------+---------------+--------------------------
| name | type | description
+--------------+---------------+--------------------------------
| "name" | String | Name of the column in table
| "field_type" | Message | computation String to be shown to summarize row content. This string is Anubis source code
| "attributes" | List(Message) | List of attributes of the table Message id is _HK_COLUMN_ATTRIBUTES
| "text" | Message | help text to use during edit screen
public define JsonValue
to_JSON
(
HK_Model_Column hk_column
)=
json_object("_HK_COLUMN",
[
json_member("name", json_string(hk_column.name)),
json_member("field_type", to_JSON(hk_column.type)),
json_member("attributes", json_array(map((HK_Model_Attr attribute) |-> to_JSON(attribute), hk_column.attributes))),
json_member("text", to_JSON(hk_column.help))
]).