|
|
1
|
+/* |
|
|
2
|
+ * Created by PyramIDE. |
|
|
3
|
+ * User: Totoro |
|
|
4
|
+ * Date: 30/11/2011 |
|
|
5
|
+ * Time: 21:22 |
|
|
6
|
+ * |
|
|
7
|
+ */ |
|
|
8
|
+ |
|
|
9
|
+read calexium_lib/database/vtm/view_table_types.anubis |
|
|
10
|
+read calexium_lib/database/vtm/view_table_manager_types.anubis |
|
|
11
|
+read calexium_lib/database/vtm/view_table_manager.anubis |
|
|
12
|
+ |
|
|
13
|
+read system/string.anubis |
|
|
14
|
+read locale/L3.anubis |
|
|
15
|
+read tools/basis.anubis |
|
|
16
|
+ |
|
|
17
|
+read system_colors/rgb.anubis |
|
|
18
|
+read system/convert.anubis |
|
|
19
|
+ |
|
|
20
|
+//read utils.anubis |
|
|
21
|
+read locale/L3LanguageInfo.anubis |
|
|
22
|
+read calexium_lib/web/CXM_common.anubis |
|
|
23
|
+read calexium_lib/web/CXM_making_a_web_site.anubis |
|
|
24
|
+read calexium_lib/web/CXM_multihost_http_server.anubis |
|
|
25
|
+read calexium_lib/web/jQuery/CXM_jquery_datatable.anubis |
|
|
26
|
+read calexium_lib/web/jQuery/CXM_jquery_datatable_types.anubis |
|
|
27
|
+read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis |
|
|
28
|
+read calexium_lib/web/CXM_form.anubis |
|
|
29
|
+read calexium_lib/web/widgets/css_helper.anubis |
|
|
30
|
+ |
|
|
31
|
+ |
|
|
32
|
+ //Edit table part |
|
|
33
|
+public define List(CXM_Form_Field) |
|
|
34
|
+ edit_form_lines |
|
|
35
|
+ ( |
|
|
36
|
+ SQLite3DataBase db, |
|
|
37
|
+ (String) -> String _T, |
|
|
38
|
+ List(VT_edit_entry) list, |
|
|
39
|
+ List(CXM_Form_Field) so_far |
|
|
40
|
+ )= |
|
|
41
|
+ if list is |
|
|
42
|
+ { |
|
|
43
|
+ [] then reverse(so_far), |
|
|
44
|
+ [ h . t] then |
|
|
45
|
+ with line = |
|
|
46
|
+ if h is |
|
|
47
|
+ { |
|
|
48
|
+ hidden(name, value) then |
|
|
49
|
+ print("hidden "+name+" = "+value); |
|
|
50
|
+ hidden(htmlId(""), wan(name), init(value)), |
|
|
51
|
+ primary_key(idx) then |
|
|
52
|
+ hidden(htmlId(""), wan("id"), init(idx)), |
|
|
53
|
+ information(s_name, c_name, value) then |
|
|
54
|
+ input_readonly(_T(s_name), wan(c_name), init(value), narrow), |
|
|
55
|
+ text(s_name, c_name, value) then |
|
|
56
|
+ input(_T(s_name), wan(c_name), init(value), narrow, mandatory), |
|
|
57
|
+ foreign_text(s_name, c_name, value, select) then |
|
|
58
|
+ selector_c([],_T(s_name), htmlId(""), wan(c_name), 1, select.get(db), success(init(to_String(value))), mandatory), |
|
|
59
|
+ text_area(s_name, c_name, value) then |
|
|
60
|
+ text_area([],_T(s_name), htmlId(""), wan(c_name), init(value), narrow, (Int)5, mandatory), |
|
|
61
|
+ boolean(s_name, c_name, value) then |
|
|
62
|
+ checkboxr([],_T(s_name), htmlId(""), wan(c_name), wav(c_name),value, mandatory), |
|
|
63
|
+ integer(s_name, c_name, value) then |
|
|
64
|
+ input(_T(s_name), wan(c_name), init(abs_to_decimal(value)), small, mandatory) |
|
|
65
|
+ date(s_name, c_name, value) then |
|
|
66
|
+ input([class("datepicker")], _T(s_name), htmlId(c_name), wan(c_name), init(value), narrow, non_mandatory), |
|
|
67
|
+ datetime(s_name, c_name, value) then |
|
|
68
|
+ input([class("datetimepicker")], _T(s_name), htmlId(c_name), wan(c_name), init(value), narrow, mandatory), |
|
|
69
|
+ }, |
|
|
70
|
+ edit_form_lines(db, _T, t, [line . so_far]) |
|
|
71
|
+ }. |
|
|
72
|
+ |
|
|
73
|
+public define HTML_Partial_Content |
|
|
74
|
+ edit_table_page |
|
|
75
|
+ ( |
|
|
76
|
+ SQLite3DataBase db, |
|
|
77
|
+ (String) -> String _T, |
|
|
78
|
+ String lang, |
|
|
79
|
+ VT_edit vt_elist |
|
|
80
|
+ ) = |
|
|
81
|
+ //if tb is tool_box(lang, _T, _, _, db, _) then |
|
|
82
|
+ with table_name = vt_elist.table_name, |
|
|
83
|
+ partial_content(jq_datetimepicker_init(lang), |
|
|
84
|
+ partial(html_wave_box( |
|
|
85
|
+ _T(to_upper(table_name)), |
|
|
86
|
+ cxm_form( table_name, htmlId(table_name), |
|
|
87
|
+ edit_form_lines(db, _T, vt_elist.list, [])+ |
|
|
88
|
+ [ submit("create", failure, _T("CREATE"), [("table_name", table_name)]) ] |
|
|
89
|
+ )))). |
|
|
90
|
+ |
|
|
91
|
+public define Maybe(HTML_Partial_Content) |
|
|
92
|
+ edit_table_content |
|
|
93
|
+ ( |
|
|
94
|
+ SQLite3DataBase db, |
|
|
95
|
+ (String) -> String _T, |
|
|
96
|
+ String lang, |
|
|
97
|
+ String table, |
|
|
98
|
+ VT_action action, |
|
|
99
|
+ VTM vtm |
|
|
100
|
+ ) = |
|
|
101
|
+ if vtm_get_edit(table, vtm.edit_list) is |
|
|
102
|
+ { |
|
|
103
|
+ failure then failure, |
|
|
104
|
+ success(vtm_e) then |
|
|
105
|
+ since vtm_e is vtm_edit(_, get_edit), |
|
|
106
|
+ success(edit_table_page(db, _T, lang, get_edit(db, action))) |
|
|
107
|
+ }. |
|
|
108
|
+ |
|
|
109
|
+ |
|
|
110
|
+ // View table part |
|
|
111
|
+define HTML_Row(HTML_Off_Form) make_line |
|
|
112
|
+ ( |
|
|
113
|
+ //ToolBox tb, |
|
|
114
|
+ String table_name, |
|
|
115
|
+ String action_name, //default is "edit_table", but can be surcharged for own use |
|
|
116
|
+ List(VT_view_entry) entries, |
|
|
117
|
+ List(HTML_Cell(HTML_Off_Form)) so_far, |
|
|
118
|
+ Int odd_even |
|
|
119
|
+ )= |
|
|
120
|
+ if entries is |
|
|
121
|
+ { |
|
|
122
|
+ [] then |
|
|
123
|
+ with line = if odd_even = 0 then "tr_even" else "tr_odd", |
|
|
124
|
+ row( [core_attrs([class(line)])], reverse(so_far)), |
|
|
125
|
+ [h . t] then |
|
|
126
|
+ with cell = if h is |
|
|
127
|
+ { |
|
|
128
|
+ text(string) then cell((HTML_Off_Form)text(string)), |
|
|
129
|
+ link(id, string) then cell((HTML_Off_Form)actioner(same,same, link(string), action_name, [("table_name", table_name),("id",id)])) |
|
|
130
|
+ }, |
|
|
131
|
+ make_line(table_name, action_name, t, [cell . so_far], odd_even) |
|
|
132
|
+ }. |
|
|
133
|
+ |
|
|
134
|
+define List(HTML_Row(HTML_Off_Form)) make_lines |
|
|
135
|
+ ( |
|
|
136
|
+// ToolBox tb, |
|
|
137
|
+ String table_name, |
|
|
138
|
+ String action_name, |
|
|
139
|
+ List(VT_view_row) entries, |
|
|
140
|
+ List(HTML_Row(HTML_Off_Form)) so_far, |
|
|
141
|
+ Int odd_even |
|
|
142
|
+ )= |
|
|
143
|
+ if entries is |
|
|
144
|
+ { |
|
|
145
|
+ [] then reverse(so_far), |
|
|
146
|
+ [h . t] then make_lines(table_name, action_name, t, [make_line(table_name, action_name, h.list, [], odd_even). so_far], 1 - odd_even ) |
|
|
147
|
+ }. |
|
|
148
|
+ |
|
|
149
|
+ // View table part |
|
|
150
|
+define HTML_Header_Row(HTML_Off_Form) |
|
|
151
|
+ make_header |
|
|
152
|
+ ( |
|
|
153
|
+ (String) -> String _T, //translator |
|
|
154
|
+ List(VT_view_entry) entries, |
|
|
155
|
+ List(HTML_Header_Cell(HTML_Off_Form)) so_far |
|
|
156
|
+ )= |
|
|
157
|
+ //if tb is tool_box(lang, _T, _, _, db, _) then |
|
|
158
|
+ if entries is |
|
|
159
|
+ { |
|
|
160
|
+ [] then header_row( [], reverse(so_far)), |
|
|
161
|
+ [h . t] then |
|
|
162
|
+ with cell = if h is |
|
|
163
|
+ { |
|
|
164
|
+ text(string) then header_cell((HTML_Off_Form)text(_T(string))), |
|
|
165
|
+ link(id, string) then header_cell((HTML_Off_Form)actioner(same,same, link(string),"edit_table",[])) //TODO |
|
|
166
|
+ }, |
|
|
167
|
+ make_header(_T, t, [cell . so_far]) |
|
|
168
|
+ }. |
|
|
169
|
+ |
|
|
170
|
+ |
|
|
171
|
+public define HTML_Partial_Content view_table_form |
|
|
172
|
+ ( |
|
|
173
|
+ (String) -> String _T, |
|
|
174
|
+ String action_name, |
|
|
175
|
+ VT_view rows |
|
|
176
|
+ )= |
|
|
177
|
+ //if tb is tool_box(_, _T, _, _, db, _) then |
|
|
178
|
+ partial_content(div( [class("tableau")], |
|
|
179
|
+ sequence( |
|
|
180
|
+ [ actioner(same,same, link([class("my_button")],_T("NEW")),"edit_table",[("table_name", rows.table_name)]), |
|
|
181
|
+ table([core_attrs([id("table_view"), class("display compact nowrap")])], |
|
|
182
|
+ make_header(_T, rows.header.list, []), |
|
|
183
|
+ make_lines(rows.table_name, action_name, rows.list, [], 0)) |
|
|
184
|
+ ] |
|
|
185
|
+ ) |
|
|
186
|
+ )) |
|
|
187
|
+ . |
|
|
188
|
+ |
|
|
189
|
+public define HTML_Partial_Content |
|
|
190
|
+ view_table_page |
|
|
191
|
+ ( |
|
|
192
|
+ (String) -> String _T, |
|
|
193
|
+ String lang, |
|
|
194
|
+ String web_site_directory, |
|
|
195
|
+ String action_name, |
|
|
196
|
+ VT_view rows |
|
|
197
|
+ ) = |
|
|
198
|
+ |
|
|
199
|
+// if tb is tool_box(lang, _T, _, _, db, _) then |
|
|
200
|
+// println("view_table_page - lang : "+lang); |
|
|
201
|
+// println("view_table_page - web_site_directory : "+web_site_directory); |
|
|
202
|
+ partial_content( |
|
|
203
|
+ [html_wave_box_wide(_T(to_upper(rows.table_name)), |
|
|
204
|
+ jquery_datatable("table_view", view_table_form(_T, action_name, rows), true, false, jq_dt_pt_full_numbers, scrollY(500), true, true, true, lang, no_extra, web_site_directory))]). |
|
|
205
|
+ |
|
|
206
|
+public define Maybe(HTML_Partial_Content) |
|
|
207
|
+ view_table_content |
|
|
208
|
+ ( |
|
|
209
|
+ SQLite3DataBase db, |
|
|
210
|
+ (String) -> String _T, |
|
|
211
|
+ String lang, |
|
|
212
|
+ String web_site_directory, |
|
|
213
|
+ String table, |
|
|
214
|
+ String action_name, |
|
|
215
|
+ VTM vtm |
|
|
216
|
+ ) = |
|
|
217
|
+ if vtm_get_view(table, vtm.view_list) is |
|
|
218
|
+ { |
|
|
219
|
+ failure then failure, |
|
|
220
|
+ success(vtm_v) then |
|
|
221
|
+ since vtm_v is vtm_view(_, get_view), |
|
|
222
|
+ success(view_table_page(_T, lang, web_site_directory, action_name, get_view(db))) |
|
|
223
|
+ }. |
...
|
...
|
|