edit_view_list_form.anubis
2.42 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
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 09/04/2017
* Time: 16:40
* © Calexium
*/
read hayamiki_lib/types/hayamiki.anubis
read tools/basis.anubis
read tools/list.anubis
read tools/streams.anubis
read system/string.anubis
read columns.anubis
read html.anubis
define String
hk_form_tab_entries
(
List(HK_FK_View) fk_views,
String indent
)=
join(",\n",
map((HK_FK_View fk_view)
|->
since fk_view is fk_view(app_name, fk_table_name, fk_col),
indent+" hk_form_tab(\""+fk_table_name+"\", \""+fk_col+"\", \"default\")"
,
fk_views)
)
.
public define Maybe(One)
/* Generate
*/
generate_edit_view_list_form
(
Stream stream, //stream file where to write
HK_Table table, //db table name
String view_name, //name of the form
List(HK_Model_Column) l_cols, //Columns selected to be editable in this list form
List(HK_FK_View) l_fk_view //List of foreign key view to display
)=
since table is hk_table(table_name, short_name, model, display),
since model is hk_model( columns, constraints, _),
with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
if write_string(stream,
"\n\n"+
//SQL query
"define HK_Form\n"+
" _get_editable_"+table_name+"_"+view_name+"\n"+
" (\n"+
" "+type_name+" "+table_name+",\n"+
" SQLite3DataBase db\n"+
" )=\n"+
" with edit_entries = (List(HK_Form_Entry))\n"+
" [\n"+
" hidden(\"id\", to_String("+table_name+".id)),\n"+
edit_entries(l_cols, table_name, " ", [])+"\n"+
" ],\n"+
(if is_empty(l_fk_view) then
" hk_form_in_list(\""+table_name+"\", \""+view_name+"\", edit_entries, []).\n\n"
else
" with fk_view_entries = (List(HK_Form_Tab))\n"+
" [\n"+
hk_form_tab_entries(l_fk_view, " ")+"\n"+
" ],\n\n"+
" hk_form_in_list(\""+table_name+"\", \""+view_name+"\", edit_entries, fk_view_entries).\n\n"
)
) is //end of the function
{
failure then println("can't write generate_VT_view "+type_name); failure,
success(_) then success(unique)
}.