Commit 5f15d104f09623bf35bb10a5d73bd6d19d2637d4
1 parent
4eeb47a2
make color_field editable
Showing
3 changed files
with
36 additions
and
14 deletions
Show diff stats
view/jqgrid.anubis
| ... | ... | @@ -53,7 +53,8 @@ define String |
| 53 | 53 | "}", |
| 54 | 54 | date(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, formatter: \"date\", formatoptions: { newformat: \"Y-M-d\" }}", |
| 55 | 55 | time(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true }", |
| 56 | - datetime(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true }", | |
| 56 | + datetime(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true }", | |
| 57 | + color(label, column_name, help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", width: 60, editable:false, formatter:formatColor}", | |
| 57 | 58 | } |
| 58 | 59 | . |
| 59 | 60 | ... | ... |
view/view_table_renderer.anubis
| ... | ... | @@ -52,7 +52,7 @@ define HTML_Off_Form |
| 52 | 52 | wan("view_name"), //web arg name of the selected entry |
| 53 | 53 | 1, |
| 54 | 54 | map((String view_name) |-> ([], wav(view_name), _T(view_name)), vtm_v.get_all_view_name(unique)), |
| 55 | - success(init(_T(current_view))), | |
| 55 | + success(init(current_view)), | |
| 56 | 56 | "" |
| 57 | 57 | ), |
| 58 | 58 | hkc_view_table, |
| ... | ... | @@ -192,7 +192,8 @@ define String |
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | ] |
| 195 | - }" | |
| 195 | + } | |
| 196 | + " | |
| 196 | 197 | // ondblClickRow: function( rowid) {"+ |
| 197 | 198 | // jq_dialog_open(dialog_id(uid+"edit_table_dlg_ajax"), "'id='+rowid")+ |
| 198 | 199 | . |
| ... | ... | @@ -214,8 +215,18 @@ public define HTML_Partial_Content |
| 214 | 215 | to_jqGrid_ColModel(db, _T, rows.view_model.list)+","+ |
| 215 | 216 | // rows.json_data_string+ |
| 216 | 217 | jqGrid_options(uid, rows, _T)+ |
| 217 | - "}).jqGrid(\"gridResize\");")), | |
| 218 | - | |
| 218 | + ",loadComplete: function () { | |
| 219 | + jscolor.installByClassName(\"jscolor\"); | |
| 220 | + } | |
| 221 | + }).jqGrid(\"gridResize\"); | |
| 222 | + function formatColor(cellValue, options, rowObject) { | |
| 223 | + var colorInput = \"<input class=\\\"jscolor\\\" value=\\\"\"+ cellValue + \"\\\">\"; | |
| 224 | + return colorInput; | |
| 225 | + } | |
| 226 | + function unformatColor(cellValue, options, cellObject) { | |
| 227 | + return $(cellObject.html()).css(\"backgroundColor\").substring(1); | |
| 228 | + }")), | |
| 229 | + | |
| 219 | 230 | partial_content(jqgrid_init(lang) + [js], |
| 220 | 231 | div([], |
| 221 | 232 | sequence([ |
| ... | ... | @@ -240,7 +251,8 @@ public define HTML_Partial_Content |
| 240 | 251 | ) = |
| 241 | 252 | with current_view = vtm_v.get_view(view_name), |
| 242 | 253 | with uid = generate_random_string(20)+"_", |
| 243 | - partial_content(jq_dialog_init + jq_datetimepicker_init(lang), | |
| 254 | + partial_content([ js(js_file("js/jscolor.min.js")) | |
| 255 | + ]+jq_dialog_init + jq_datetimepicker_init(lang), | |
| 244 | 256 | [html_wave_box_wide(_T(to_upper(current_view.table_name)), |
| 245 | 257 | sequence([ |
| 246 | 258 | partial(jq_dialog_create(dialog_id(uid+action_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&table_name="+current_view.table_name)))), |
| ... | ... | @@ -266,7 +278,8 @@ public define HTML_Partial_Content |
| 266 | 278 | ) = |
| 267 | 279 | with current_view = vtm_v.get_view(view_name), |
| 268 | 280 | with uid = generate_random_string(20)+"_", |
| 269 | - partial_content( | |
| 281 | + partial_content([ js(js_file("js/jscolor.min.js")) | |
| 282 | + ]+ | |
| 270 | 283 | jq_dialog_init + |
| 271 | 284 | jq_datetimepicker_init(lang), |
| 272 | 285 | [ |
| ... | ... | @@ -395,6 +408,8 @@ public define List(CXM_Form_Field) |
| 395 | 408 | [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)], |
| 396 | 409 | datetime(s_name, c_name, value, help) then |
| 397 | 410 | [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)], |
| 411 | + color( s_name, c_name, value, help) then | |
| 412 | + [input([class("jscolor")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | |
| 398 | 413 | }, |
| 399 | 414 | edit_form_lines(db, _T, t, new_entry, reverse(line)+so_far) |
| 400 | 415 | }. |
| ... | ... | @@ -444,6 +459,8 @@ public define HTML_Partial_Content |
| 444 | 459 | with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), |
| 445 | 460 | |
| 446 | 461 | partial_content( |
| 462 | + [ js(js_file("js/jscolor.min.js")) | |
| 463 | + ]+ | |
| 447 | 464 | jq_datetimepicker_init(lang) + |
| 448 | 465 | get_editor_header(vt_elist.list), //add editor header if need. Like init ck_editor |
| 449 | 466 | sequence([ | ... | ... |
view/view_table_types.anubis
| ... | ... | @@ -16,9 +16,9 @@ public type VT_edit_selector: |
| 16 | 16 | public type VT_edit_entry: |
| 17 | 17 | hidden (String name, String value), |
| 18 | 18 | primary_key (String idx), |
| 19 | - information (String s_name, String c_name, String v_name, Int width, HK_Help_Text help), //s_name = show_name for translation, v_name = string to show | |
| 20 | - text (String s_name, String c_name, String value, HK_Help_Text help), //s_name = show_name for translation, c_name = table column name | |
| 21 | - password (String s_name, String c_name, HK_Help_Text help), //s_name = show_name for translation, c_name = table column name | |
| 19 | + information (String s_name, String c_name, String v_name, Int width, HK_Help_Text help), //s_name = show_name for translation, v_name = string to show | |
| 20 | + text (String s_name, String c_name, String value, HK_Help_Text help), //s_name = show_name for translation, c_name = table column name | |
| 21 | + password (String s_name, String c_name, HK_Help_Text help), //s_name = show_name for translation, c_name = table column name | |
| 22 | 22 | foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector, HK_Help_Text help), |
| 23 | 23 | choices_text(String s_name, String c_name, String selected, VT_edit_selector selector, HK_Help_Text help), |
| 24 | 24 | text_area (String s_name, String c_name, String value, HK_Text_Field_Attr area_att, HK_Help_Text help), //s_name = show_name for translate, c_name = table column name |
| ... | ... | @@ -26,9 +26,11 @@ public type VT_edit_entry: |
| 26 | 26 | integer (String s_name, String c_name, Int value, HK_Help_Text help), |
| 27 | 27 | float (String s_name, String c_name, Float value, HK_Help_Text help), |
| 28 | 28 | choices_int (String s_name, String c_name, Int selected, VT_edit_selector selector, HK_Help_Text help), |
| 29 | - date (String s_name, String c_name, String value, HK_Help_Text help), | |
| 30 | - time (String s_name, String c_name, String value, HK_Help_Text help), | |
| 31 | - datetime (String s_name, String c_name, String value, HK_Help_Text help). | |
| 29 | + date (String s_name, String c_name, String value, HK_Help_Text help), | |
| 30 | + time (String s_name, String c_name, String value, HK_Help_Text help), | |
| 31 | + datetime (String s_name, String c_name, String value, HK_Help_Text help), | |
| 32 | + color (String s_name, String c_name, String value, HK_Help_Text help) | |
| 33 | +. | |
| 32 | 34 | |
| 33 | 35 | public define VT_edit_entry text (String s_name, String c_name, String value) = text(s_name, c_name, value, no_help_text). |
| 34 | 36 | public define VT_edit_entry foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector) = foreign_text(s_name, c_name, selected, selector, no_help_text). |
| ... | ... | @@ -62,7 +64,9 @@ public type VT_view_model_entry: |
| 62 | 64 | choices_int (String label, String column_name, VT_edit_selector selector, HK_Help_Text help), |
| 63 | 65 | date (String label, String column_name, HK_Help_Text help), |
| 64 | 66 | time (String label, String column_name, HK_Help_Text help), |
| 65 | - datetime (String label, String column_name, HK_Help_Text help). | |
| 67 | + datetime (String label, String column_name, HK_Help_Text help), | |
| 68 | + color (String label, String column_name, HK_Help_Text help). | |
| 69 | + | |
| 66 | 70 | |
| 67 | 71 | public type VT_view_model: |
| 68 | 72 | vt_view_model(List(VT_view_model_entry) list). | ... | ... |