|
| |
1
| +/* |
|
| |
2
| + * Created by PyramIDE. |
|
| |
3
| + * User: Totoro |
|
| |
4
| + * Date: 30/11/2011 |
|
| |
5
| + * Time: 21:22 |
|
| |
6
| + * |
|
| |
7
| + */ |
|
| |
8
| + |
|
| |
9
| +read hayamiki_lib/view/view_table_types.anubis |
|
| |
10
| +read hayamiki_lib/view/view_table_manager_types.anubis |
|
| |
11
| +read hayamiki_lib/view/view_table_manager.anubis |
|
| |
12
| +read hayamiki_lib/types/hayamiki.anubis |
|
| |
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_web_arg_utils.anubis |
|
| |
24
| +read calexium_lib/web/CXM_making_a_web_site.anubis |
|
| |
25
| +read calexium_lib/web/CXM_multihost_http_server.anubis |
|
| |
26
| +read calexium_lib/web/jQuery/CXM_jquery_datatable.anubis |
|
| |
27
| +read calexium_lib/web/jQuery/CXM_jquery_datatable_types.anubis |
|
| |
28
| +read calexium_lib/web/jQuery/CXM_jquery_dialog.anubis |
|
| |
29
| +read calexium_lib/web/jQuery/CXM_jquery_button.anubis |
|
| |
30
| +read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis |
|
| |
31
| +read calexium_lib/web/CXM_form.anubis |
|
| |
32
| +read calexium_lib/web/widgets/css_helper.anubis |
|
| |
33
| +read calexium_lib/web/widgets/button.anubis |
|
| |
34
| + |
|
| |
35
| +define CXM_Form_Field |
|
| |
36
| + help_line |
|
| |
37
| + ( |
|
| |
38
| + HK_Help_Text help, |
|
| |
39
| + (String) -> String _T |
|
| |
40
| + )= |
|
| |
41
| + if help is |
|
| |
42
| + { |
|
| |
43
| + no_help_text then empty, |
|
| |
44
| + help_text_TAG(tag) then explain(_T(tag)), |
|
| |
45
| + help_text(str) then explain(str) |
|
| |
46
| + }. |
|
| |
47
| + |
|
| |
48
| + |
|
| |
49
| + //Edit table part |
|
| |
50
| +public define List(CXM_Form_Field) |
|
| |
51
| + edit_form_lines |
|
| |
52
| + ( |
|
| |
53
| + SQLite3DataBase db, |
|
| |
54
| + (String) -> String _T, |
|
| |
55
| + List(VT_edit_entry) list, |
|
| |
56
| + List(CXM_Form_Field) so_far |
|
| |
57
| + )= |
|
| |
58
| + if list is |
|
| |
59
| + { |
|
| |
60
| + [] then reverse(so_far), |
|
| |
61
| + [ h . t] then |
|
| |
62
| + with line = |
|
| |
63
| + if h is |
|
| |
64
| + { |
|
| |
65
| + hidden(name, value) then |
|
| |
66
| + //print("hidden "+name+" = "+value); |
|
| |
67
| + [hidden(html_Id(""), wan(name), wav(value))], |
|
| |
68
| + primary_key(idx) then |
|
| |
69
| + [hidden(html_Id(""), wan("id"), wav(idx))], |
|
| |
70
| + information(s_name, c_name, value, width, help) then |
|
| |
71
| + [input_readonly(label(_T(s_name), no_help), wan(c_name), init(value), if width > 0 then custom(width) else narrow), help_line(help, _T)], |
|
| |
72
| + text(s_name, c_name, value, help) then |
|
| |
73
| + [input(label(_T(s_name), no_help), wan(c_name), init(value), narrow, mandatory), help_line(help, _T)], |
|
| |
74
| + password(s_name, c_name, help) then |
|
| |
75
| + [password_input(label(_T(s_name), no_help), wan(c_name+"_1"), init(""), narrow, non_mandatory), |
|
| |
76
| + password_input(label(_T(s_name), no_help), wan(c_name+"_2"), init(""), narrow, non_mandatory), |
|
| |
77
| + help_line(help, _T)], |
|
| |
78
| + |
|
| |
79
| + foreign_text(s_name, c_name, value, select, help) then |
|
| |
80
| + [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(to_String(value))), mandatory), help_line(help, _T)], |
|
| |
81
| + choices_text(s_name, c_name, value, select, help) then |
|
| |
82
| + [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(value)), mandatory), help_line(help, _T)], |
|
| |
83
| + text_area(s_name, c_name, value, help) then |
|
| |
84
| + [text_area([],label(_T(s_name), no_help), html_Id(""), wan(c_name), init(value), narrow, (Int)5, mandatory), help_line(help, _T)], |
|
| |
85
| + boolean(s_name, c_name, value, help) then |
|
| |
86
| + [checkboxr([],label(_T(s_name), no_help), html_Id(""), wan(c_name), wav(c_name),value, mandatory), help_line(help, _T)], |
|
| |
87
| + integer(s_name, c_name, value, help) then |
|
| |
88
| + [input(label(_T(s_name), no_help), wan(c_name), init(abs_to_decimal(value)), small, mandatory), help_line(help, _T)], |
|
| |
89
| + choices_int(s_name, c_name, value, select, help) then |
|
| |
90
| + [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(to_String(value))), mandatory), help_line(help, _T)], |
|
| |
91
| + date(s_name, c_name, value, help) then |
|
| |
92
| + [input([class("datepicker")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(value), small, non_mandatory), help_line(help, _T)], |
|
| |
93
| + time(s_name, c_name, value, help) then |
|
| |
94
| + [input([class("timepicker")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(value), small, non_mandatory), help_line(help, _T)], |
|
| |
95
| + datetime(s_name, c_name, value, help) then |
|
| |
96
| + [input([class("datetimepicker")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(value), custom(18), mandatory), help_line(help, _T)], |
|
| |
97
| + }, |
|
| |
98
| + edit_form_lines(db, _T, t, reverse(line)+so_far) |
|
| |
99
| + }. |
|
| |
100
| + |
|
| |
101
| +public define HTML_Partial_Content |
|
| |
102
| + edit_table_page |
|
| |
103
| + ( |
|
| |
104
| + SQLite3DataBase db, |
|
| |
105
| + (String) -> String _T, |
|
| |
106
| + String lang, |
|
| |
107
| + List(Web_arg) lwa, |
|
| |
108
| + VT_edit vt_elist |
|
| |
109
| + ) = |
|
| |
110
| + with table_name = vt_elist.table_name, |
|
| |
111
| + with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"), |
|
| |
112
| + partial_content(jq_datetimepicker_init(lang), |
|
| |
113
| + cxm_form( table_name, lwa, |
|
| |
114
| + edit_form_lines(db, _T, vt_elist.list, [])+ |
|
| |
115
| + [ submit("create", failure, button_name, [("table_name", table_name)]) ] |
|
| |
116
| + )). |
|
| |
117
| + |
|
| |
118
| +public define Maybe(HTML_Partial_Content) |
|
| |
119
| + edit_table_content |
|
| |
120
| + ( |
|
| |
121
| + SQLite3DataBase db, |
|
| |
122
| + (String) -> String _T, |
|
| |
123
| + String lang, |
|
| |
124
| + List(Web_arg) lwa, |
|
| |
125
| + String table, |
|
| |
126
| + VT_action action, |
|
| |
127
| + VTM vtm |
|
| |
128
| + ) = |
|
| |
129
| + if vtm_get_edit(table, vtm.edit_list) is |
|
| |
130
| + { |
|
| |
131
| + failure then failure, |
|
| |
132
| + success(vtm_e) then |
|
| |
133
| + since vtm_e is vtm_edit(_, get_edit), |
|
| |
134
| + success(edit_table_page(db, _T, lang, lwa, get_edit(db, action))) |
|
| |
135
| + }. |
|
| |
136
| + |
|
| |
137
| + |
|
| |
138
| + // View table part |
|
| |
139
| +define HTML_Row(HTML_Off_Form) make_line |
|
| |
140
| + ( |
|
| |
141
| + String table_name, |
|
| |
142
| + String action_name, //default is "edit_table", but can be surcharged for own use |
|
| |
143
| + List(VT_view_entry) entries, |
|
| |
144
| + List(HTML_Cell(HTML_Off_Form)) so_far |
|
| |
145
| + )= |
|
| |
146
| + if entries is |
|
| |
147
| + { |
|
| |
148
| + [] then row( [], reverse(so_far)), |
|
| |
149
| + [h . t] then |
|
| |
150
| + with cell = if h is |
|
| |
151
| + { |
|
| |
152
| + text(string) then cell((HTML_Off_Form)text(string)), |
|
| |
153
| +// link(id, string) then cell((HTML_Off_Form)actioner(same,same, link(string), action_name, [("table_name", table_name),("id",id)])), |
|
| |
154
| + link(id, string) then cell((HTML_Off_Form)literal(jq_dialog_open(string, dialog_id(action_name+"_dlg_ajax"), "'id="+id+"'"))), |
|
| |
155
| + link_id_action(id, name, action) then cell((HTML_Off_Form)actioner(same,same, link(name), action, [("id",id)])), |
|
| |
156
| + icon(icon_path) then cell((HTML_Off_Form)image([], icon_path, "")) |
|
| |
157
| + }, |
|
| |
158
| + make_line(table_name, action_name, t, [cell . so_far]) |
|
| |
159
| + }. |
|
| |
160
| + |
|
| |
161
| +define List(HTML_Row(HTML_Off_Form)) |
|
| |
162
| + make_lines |
|
| |
163
| + ( |
|
| |
164
| + (String) -> String _T, //translator |
|
| |
165
| + String table_name, |
|
| |
166
| + String action_name, |
|
| |
167
| + List(VT_view_row) entries, |
|
| |
168
| + List(HTML_Row(HTML_Off_Form)) so_far |
|
| |
169
| + )= |
|
| |
170
| + if entries is |
|
| |
171
| + { |
|
| |
172
| + [] then reverse(so_far), |
|
| |
173
| + [h . t] then |
|
| |
174
| + //compute each line |
|
| |
175
| + //prepare here the first cell for actioner |
|
| |
176
| + with actions_cell = (HTML_Cell(HTML_Off_Form)) |
|
| |
177
| + cell([], |
|
| |
178
| + sequence([ |
|
| |
179
| + partial(img_button_confirm(icn16_cross, _T("CONFIRMATION_REQUEST"), _T("CONFIRM_LINE_DELETION") , _T("OK"), _T("CANCEL"), jQuery_actioner(same, jqlink, "hk_del_row" + format_extra_operands([("table_name", table_name),("id",to_String(h.db_id))])))), |
|
| |
180
| + partial(img_button(icn16_edit, [event(onclick, jq_dialog_open(dialog_id(action_name+"_dlg_ajax"), "'id="+to_String(h.db_id)+"'"))], "", [])), |
|
| |
181
| + ]) |
|
| |
182
| + ), |
|
| |
183
| + make_lines(_T, table_name, action_name, t, [make_line(table_name, action_name, h.list, [actions_cell]). so_far] ) |
|
| |
184
| + }. |
|
| |
185
| + |
|
| |
186
| + // View table part |
|
| |
187
| +define HTML_Header_Row(HTML_Off_Form) |
|
| |
188
| + make_header |
|
| |
189
| + ( |
|
| |
190
| + (String) -> String _T, //translator |
|
| |
191
| + List(VT_view_entry) entries, |
|
| |
192
| + List(HTML_Header_Cell(HTML_Off_Form)) so_far |
|
| |
193
| + )= |
|
| |
194
| + if entries is |
|
| |
195
| + { |
|
| |
196
| + [] then header_row( [], reverse(so_far)), |
|
| |
197
| + [h . t] then |
|
| |
198
| + with cell = if h is |
|
| |
199
| + { |
|
| |
200
| + text(string) then header_cell((HTML_Off_Form)text(_T(string))), |
|
| |
201
| + link(id, string) then header_cell((HTML_Off_Form)actioner(same,same, link(string),"edit_table",[])), //TODO |
|
| |
202
| + link_id_action(id, text, action) then header_cell((HTML_Off_Form)actioner(same,same, link(text),action,[("id",id)])), //TODO |
|
| |
203
| + icon(icon_path) then header_cell((HTML_Off_Form)image([], icon_path, "")) |
|
| |
204
| + }, |
|
| |
205
| + make_header(_T, t, [cell . so_far]) |
|
| |
206
| + }. |
|
| |
207
| + |
|
| |
208
| + |
|
| |
209
| + |
|
| |
210
| +public define HTML_Partial_Content |
|
| |
211
| + view_table_form |
|
| |
212
| + ( |
|
| |
213
| + (String) -> String _T, |
|
| |
214
| + String action_name, |
|
| |
215
| + VT_view rows |
|
| |
216
| + )= |
|
| |
217
| + with action_header_cell = header_cell((HTML_Off_Form)text(_T("ACTION"))), |
|
| |
218
| + partial_content( |
|
| |
219
| + div( [/*class("tableau")*/], |
|
| |
220
| + sequence( |
|
| |
221
| + [ |
|
| |
222
| + partial(jquery_button(jQuery_button(button, "edit_table_"+rows.table_name, "", _T("NEW"), jQuery_actioner(same, jqlink, "edit_table&table_name="+rows.table_name)))), |
|
| |
223
| + //dialog used by datatable entries |
|
| |
224
| + partial(jq_dialog_create(dialog_id(action_name+"_dlg_ajax"), ajax("?a=ajax_edit_table&table_name="+rows.table_name))), |
|
| |
225
| + |
|
| |
226
| + table([core_attrs([id("table_view"), class("tableau display compact nowrap")])], |
|
| |
227
| + make_header(_T, rows.header.list, [action_header_cell]), |
|
| |
228
| + make_lines(_T, rows.table_name, action_name, rows.list, [])) |
|
| |
229
| + ] |
|
| |
230
| + ) |
|
| |
231
| + )) |
|
| |
232
| + . |
|
| |
233
| + |
|
| |
234
| +public define HTML_Partial_Content |
|
| |
235
| + view_table_page |
|
| |
236
| + ( |
|
| |
237
| + (String) -> String _T, |
|
| |
238
| + String lang, |
|
| |
239
| + String web_site_directory, |
|
| |
240
| + String action_name, |
|
| |
241
| + VT_view rows |
|
| |
242
| + ) = |
|
| |
243
| + |
|
| |
244
| +// if tb is tool_box(lang, _T, _, _, db, _) then |
|
| |
245
| +// println("view_table_page - lang : "+lang); |
|
| |
246
| +// println("view_table_page - web_site_directory : "+web_site_directory); |
|
| |
247
| + partial_content(jq_dialog_init + jq_datetimepicker_init(lang), |
|
| |
248
| + [partial(html_wave_box_wide(_T(to_upper(rows.table_name)), |
|
| |
249
| + jquery_datatable("table_view", view_table_form(_T, action_name, rows), true, false, jq_dt_pt_full_numbers, false, scrollY(500), true, true, true, lang, no_extra, web_site_directory)))]). |
|
| |
250
| + |
|
| |
251
| +public define Maybe(HTML_Partial_Content) |
|
| |
252
| + view_table_content |
|
| |
253
| + ( |
|
| |
254
| + SQLite3DataBase db, |
|
| |
255
| + (String) -> String _T, |
|
| |
256
| + String lang, |
|
| |
257
| + String web_site_directory, |
|
| |
258
| + String table, |
|
| |
259
| + String view_name, |
|
| |
260
| + String action_name, |
|
| |
261
| + VTM vtm |
|
| |
262
| + ) = |
|
| |
263
| + if vtm_get_view(table, vtm.view_list) is |
|
| |
264
| + { |
|
| |
265
| + failure then failure, |
|
| |
266
| + success(vtm_v) then |
|
| |
267
| + since vtm_v is vtm_view(_, get_view), |
|
| |
268
| + success(view_table_page(_T, lang, web_site_directory, action_name, get_view(db, view_name))) |
|
| |
269
| + }. |