Commit 312e7153516d9c1a11948ceff143e800012f00f1

Authored by totoro
1 parent 46219dd3

create vt_view_row_header and add db_id in vt_view_row

database/db_types.anubis
... ... @@ -35,6 +35,17 @@ public define String
35 35 none then "none",
36 36 db_id(_idx) then abs_to_decimal(_idx)
37 37 }.
  38 +
  39 +public define Int
  40 + to_Int
  41 + (
  42 + DB_id idx
  43 + )=
  44 + if idx is
  45 + {
  46 + none then (Int)-1,
  47 + db_id(_idx) then _idx
  48 + }.
38 49  
39 50 public define String
40 51 to_String
... ...
database/vtm/view_table_renderer.anubis
... ... @@ -28,6 +28,7 @@ read calexium_lib/web/jQuery/CXM_jquery_datatable_types.anubis
28 28 read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis
29 29 read calexium_lib/web/CXM_form.anubis
30 30 read calexium_lib/web/widgets/css_helper.anubis
  31 +read calexium_lib/web/widgets/button.anubis
31 32  
32 33 define CXM_Form_Field
33 34 help_line
... ... @@ -93,7 +94,6 @@ public define HTML_Partial_Content
93 94 List(Web_arg) lwa,
94 95 VT_edit vt_elist
95 96 ) =
96   - //if tb is tool_box(lang, _T, _, _, db, _) then
97 97 with table_name = vt_elist.table_name,
98 98 with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"),
99 99 partial_content(jq_datetimepicker_init(lang),
... ... @@ -127,18 +127,14 @@ public define Maybe(HTML_Partial_Content)
127 127 // View table part
128 128 define HTML_Row(HTML_Off_Form) make_line
129 129 (
130   - //ToolBox tb,
131 130 String table_name,
132 131 String action_name, //default is "edit_table", but can be surcharged for own use
133 132 List(VT_view_entry) entries,
134 133 List(HTML_Cell(HTML_Off_Form)) so_far
135   - //Int odd_even
136 134 )=
137 135 if entries is
138 136 {
139   - [] then
140   - //with line = if odd_even = 0 then "tr_even" else "tr_odd",
141   - row( [], reverse(so_far)),
  137 + [] then row( [], reverse(so_far)),
142 138 [h . t] then
143 139 with cell = if h is
144 140 {
... ... @@ -149,19 +145,28 @@ define HTML_Row(HTML_Off_Form) make_line
149 145 make_line(table_name, action_name, t, [cell . so_far])
150 146 }.
151 147  
152   -define List(HTML_Row(HTML_Off_Form)) make_lines
  148 +define List(HTML_Row(HTML_Off_Form))
  149 + make_lines
153 150 (
154   -// ToolBox tb,
  151 + (String) -> String _T, //translator
155 152 String table_name,
156 153 String action_name,
157 154 List(VT_view_row) entries,
158 155 List(HTML_Row(HTML_Off_Form)) so_far
159   -// Int odd_even
160 156 )=
161 157 if entries is
162 158 {
163 159 [] then reverse(so_far),
164   - [h . t] then make_lines(table_name, action_name, t, [make_line(table_name, action_name, h.list, []). so_far] )
  160 + [h . t] then
  161 + //compute each line
  162 + //prepare here the first cell for actioner
  163 + with actions_cell = (HTML_Cell(HTML_Off_Form))
  164 + cell([],
  165 + sequence([
  166 + 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))]))))
  167 + ])
  168 + ),
  169 + make_lines(_T, table_name, action_name, t, [make_line(table_name, action_name, h.list, [actions_cell]). so_far] )
165 170 }.
166 171  
167 172 // View table part
... ... @@ -172,7 +177,6 @@ define HTML_Header_Row(HTML_Off_Form)
172 177 List(VT_view_entry) entries,
173 178 List(HTML_Header_Cell(HTML_Off_Form)) so_far
174 179 )=
175   - //if tb is tool_box(lang, _T, _, _, db, _) then
176 180 if entries is
177 181 {
178 182 [] then header_row( [], reverse(so_far)),
... ... @@ -186,20 +190,22 @@ define HTML_Header_Row(HTML_Off_Form)
186 190 make_header(_T, t, [cell . so_far])
187 191 }.
188 192  
  193 +
189 194  
190   -public define HTML_Partial_Content view_table_form
  195 +public define HTML_Partial_Content
  196 + view_table_form
191 197 (
192 198 (String) -> String _T,
193 199 String action_name,
194 200 VT_view rows
195 201 )=
196   - //if tb is tool_box(_, _T, _, _, db, _) then
  202 + with action_header_cell = header_cell((HTML_Off_Form)text(_T("ACTION"))),
197 203 partial_content(div( [/*class("tableau")*/],
198 204 sequence(
199 205 [ actioner(same,same, link([class("my_button")],_T("NEW")),"edit_table",[("table_name", rows.table_name)]),
200 206 table([core_attrs([id("table_view"), class("tableau display compact nowrap")])],
201   - make_header(_T, rows.header.list, []),
202   - make_lines(rows.table_name, action_name, rows.list, []))
  207 + make_header(_T, rows.header.list, [action_header_cell]),
  208 + make_lines(_T, rows.table_name, action_name, rows.list, []))
203 209 ]
204 210 )
205 211 ))
... ...
database/vtm/view_table_types.anubis
... ... @@ -38,12 +38,15 @@ public type VT_view_entry:
38 38 text(String text),
39 39 link(String id, String text),
40 40 icon(String icon_path).
  41 +
  42 +public type VT_view_row_header:
  43 + vt_view_row_header(List(VT_view_entry) list).
41 44  
42 45 public type VT_view_row:
43   - vt_view_row(List(VT_view_entry) list).
  46 + vt_view_row(Int db_id, List(VT_view_entry) list).
44 47  
45 48 public type VT_view:
46   - vt_view(String table_name, String view_name, VT_view_row header, List(VT_view_row) list).
  49 + vt_view(String table_name, String view_name, VT_view_row_header header, List(VT_view_row) list).
47 50  
48 51  
49 52 public type VT_action:
... ...