html.anubis
3.76 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 13/02/2016
* Time: 11:19
* © Calexium
*/
read hayamiki_lib/types/model/columns.anubis
read icons.anubis
public define String
to_HTML_cell_icon
(
HK_Model_Column column,
String data_name,
String general_type_name
)=
"icon("+to_Icon(column, data_name, general_type_name)+")".
public define String
to_HTML_cell_text
(
HK_Model_Column column,
String data_name,
String general_type_name
)=
"text("+to_String(column, data_name, general_type_name)+")".
public define String
to_HTML_cell_link
(
HK_Model_Column column,
String data_name,
String general_type_name
)=
"link(to_String("+data_name+".id), "+to_String(column, data_name, general_type_name)+")".
public define String
to_HTML_cell_link
(
List(HK_Model_Column) columns,
String column_name,
String data_name,
String general_type_name
)=
if get_column_type(columns, column_name) is
{
failure then "column name "+column_name+"doesn't exist",
success(column) then to_HTML_cell_link(column, data_name, general_type_name)
}.
public define String
to_HTML_cell
(
List(HK_Model_Column) columns,
String column_name,
String data_name,
String general_type_name
)=
if get_column_type(columns, column_name) is
{
failure then "column name "+column_name+"doesn't exist",
success(column) then
since column is hk_column(name, col_type, _, _),
if col_type is
{
p_key then to_HTML_cell_link(column, data_name, general_type_name),
boolean_field then to_HTML_cell_icon(column, data_name, general_type_name),
date_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
time_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
foreign_key(app,foreign_table) then to_HTML_cell_text(column, data_name, general_type_name),
integer_field then to_HTML_cell_text(column, data_name, general_type_name),
char_field(Int size) then to_HTML_cell_text(column, data_name, general_type_name),
text_field then to_HTML_cell_text(column, data_name, general_type_name),
}
}.
public define String
make_list_view_row
(
HK_Table table, //table to format
String data_name, //name of data
String indent, //indentation string to use
HK_List_View list_view //list view to generate
)=
since table is hk_table(table_name, short, model, _), //get name and model of the table
since model is hk_model( columns, _), //get all columns of table
// since display is db_display(views, _), //
with current_list_column = if list_view is
{
list_view_all then to_List_String(columns, false), //generate a list of columns string to view from columns model
list_view(v_name, v_col) then v_col
},
if current_list_column is
{
[] then "",
[h . t] then
indent+join(",\n"+indent,
//Make first column as link
[to_HTML_cell_link(columns, h, data_name, table_name)] +
//and the other set with list_view
map((String column_name) |-> to_HTML_cell(columns, column_name, data_name, table_name), t)
)
}.