html.anubis
5.55 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 13/02/2016
* Time: 11:19
* © David RENÉ
*/
read system/string.anubis
read tools/basis.anubis
read xlib/web/CXM_making_a_web_site.anubis
read xlib/web/CXM_web_action.anubis
read hayamiki_lib/types/hayamiki.anubis
read icons.anubis
read columns.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_id_action
(
HK_Model_Column column,
String data_name,
String general_type_name,
WEB_Action_Name action_name
)=
"link_id_action(to_String("+data_name+".id), "+to_String(column, data_name, general_type_name)+", "+to_Anubis_Source(action_name)+")".
public define String
to_HTML_cell_link
(
List(HK_Model_Column) columns,
String column_name,
String data_name,
String general_type_name,
WEB_Action_Name action_name
)=
if get_column_type_from_name(columns, column_name) is
{
failure then "column name "+column_name+"doesn't exist",
success(column) then
if action_name = no_action then
to_HTML_cell_link(column, data_name, general_type_name)
else
to_HTML_cell_link_id_action(column, data_name, general_type_name, action_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_from_name(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
if name = "id" then
to_HTML_cell_link(column, data_name, general_type_name)
else
to_HTML_cell_text(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(choices) then to_HTML_cell_text(column, data_name, general_type_name),
float_field then to_HTML_cell_text(column, data_name, general_type_name),
char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name),
password_field(min_size) then
"text(\"********\")",
//to_HTML_cell_text(column, data_name, general_type_name),
text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
color_field then to_HTML_cell_text(column, data_name, general_type_name),
phone_field(_) then to_HTML_cell_text(column, data_name, general_type_name),
// mobile_field then to_HTML_cell_text(column, data_name, general_type_name),
url_field then to_HTML_cell_text(column, data_name, general_type_name),
email_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_Viewer 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, l_filters, _) then v_col
},
with action_name = if list_view is
{
list_view_all then no_action,
list_view(_, _, _, an) then an
},
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, action_name)] +
//and the other set with list_view
map((String column_name) |-> to_HTML_cell(columns, column_name, data_name, table_name), t)
)
}.