Commit d5159c4a058cbdb604ec5d7d847de371424e245b
1 parent
5ef0dd2a
add email and phone fields in the renderer.
Jqrid now show 30 lines as default and the editing can be made by double click on the line
Showing
1 changed file
with
84 additions
and
14 deletions
Show diff stats
view/view_table_renderer.anubis
| @@ -176,11 +176,27 @@ define String | @@ -176,11 +176,27 @@ define String | ||
| 176 | editurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', | 176 | editurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', |
| 177 | iconSet: \"fontAwesome\", | 177 | iconSet: \"fontAwesome\", |
| 178 | autowidth:true, | 178 | autowidth:true, |
| 179 | - shrinkToFit:true, | ||
| 180 | - rowNum:10, | 179 | + shrinkToFit:false, |
| 180 | + rowNum:30, | ||
| 181 | + rowList:[5,10,30,50], | ||
| 181 | cellEdit: false, | 182 | cellEdit: false, |
| 182 | cellsubmit: 'remote', | 183 | cellsubmit: 'remote', |
| 183 | - cellurl: '?aws_controller=hk_c&aws_action=update_row&table_name="+rows.table_name+"', | 184 | + cellurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', |
| 185 | + editurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', | ||
| 186 | + onSelectRow: function (rowid, status, e) { | ||
| 187 | + var $self = $(this), savedRow = $self.jqGrid(\"getGridParam\", \"savedRow\"); | ||
| 188 | + if (savedRow.length > 0 && savedRow[0].id !== rowid) { | ||
| 189 | + $self.jqGrid(\"restoreRow\", savedRow[0].id); | ||
| 190 | + } | ||
| 191 | + }, | ||
| 192 | + ondblClickRow: function (rowid, iRow, iCol, e) { | ||
| 193 | + var $self = $(this), savedRow = $self.jqGrid(\"getGridParam\", \"savedRow\"); | ||
| 194 | + if (savedRow.length > 0 && savedRow[0].id !== rowid) { | ||
| 195 | + $self.jqGrid(\"restoreRow\", savedRow[0].id); | ||
| 196 | + } | ||
| 197 | + $self.jqGrid(\"editRow\", rowid, { focusField: e.target }); | ||
| 198 | + }, | ||
| 199 | + | ||
| 184 | pager: '#"+uid+"_pager', | 200 | pager: '#"+uid+"_pager', |
| 185 | caption:"+to_JSON_String(_T(to_upper(rows.table_name)))+", | 201 | caption:"+to_JSON_String(_T(to_upper(rows.table_name)))+", |
| 186 | actionsNavOptions: { | 202 | actionsNavOptions: { |
| @@ -218,7 +234,7 @@ public define HTML_Partial_Content | @@ -218,7 +234,7 @@ public define HTML_Partial_Content | ||
| 218 | )= | 234 | )= |
| 219 | with filter_clause = if clause = "" then "" else "&clause="+url_quote(clause), | 235 | with filter_clause = if clause = "" then "" else "&clause="+url_quote(clause), |
| 220 | with referer_arg = "&"+to_Web_arg(table_referer, ""), | 236 | with referer_arg = "&"+to_Web_arg(table_referer, ""), |
| 221 | - with js = js_inline(jquery_ready("$(\"#"+uid+"_grid\").jqGrid({\n"+ | 237 | + with js = js_inline(jquery_ready("var lastSel;$(\"#"+uid+"_grid\").jqGrid({\n"+ |
| 222 | "url:'?aws_controller=hk_c&aws_action=grid_view&table_name="+rows.table_name+"&view_name="+rows.view_name+filter_clause+referer_arg+"',"+ | 238 | "url:'?aws_controller=hk_c&aws_action=grid_view&table_name="+rows.table_name+"&view_name="+rows.view_name+filter_clause+referer_arg+"',"+ |
| 223 | "datatype: \"json\","+ | 239 | "datatype: \"json\","+ |
| 224 | to_jqGrid_ColModel(db, table_referer, _T, rows.view_model.list)+","+ | 240 | to_jqGrid_ColModel(db, table_referer, _T, rows.view_model.list)+","+ |
| @@ -234,6 +250,24 @@ public define HTML_Partial_Content | @@ -234,6 +250,24 @@ public define HTML_Partial_Content | ||
| 234 | } | 250 | } |
| 235 | function unformatColor(cellValue, options, cellObject) { | 251 | function unformatColor(cellValue, options, cellObject) { |
| 236 | return $(cellObject.html()).css(\"backgroundColor\").substring(1); | 252 | return $(cellObject.html()).css(\"backgroundColor\").substring(1); |
| 253 | + } | ||
| 254 | + function formatPhone(cellValue, options, rowObject) { | ||
| 255 | + var phoneInput = '<span class=\"hk_phone_call\"><img src=\\\"/icons/16x16/phone.png\\\" onclick=\"hk_phone_call(this);\">' + cellValue + '</span>'; | ||
| 256 | + return phoneInput; | ||
| 257 | + } | ||
| 258 | + function unformatPhone(cellValue, options, cellObject) { | ||
| 259 | + var jqo = $(cellObject); | ||
| 260 | + var ret = jqo.text(); | ||
| 261 | + return ret; | ||
| 262 | + } | ||
| 263 | + function formatEmail(cellValue, options, rowObject) { | ||
| 264 | + var phoneInput = '<span class=\"hk_send_email\"><img src=\\\"/icons/16x16/email_edit.png\\\" onclick=\"hk_send_email(this);\">' + cellValue + '</span>'; | ||
| 265 | + return phoneInput; | ||
| 266 | + } | ||
| 267 | + function unformatEmail(cellValue, options, cellObject) { | ||
| 268 | + var jqo = $(cellObject); | ||
| 269 | + var ret = jqo.text(); | ||
| 270 | + return ret; | ||
| 237 | }")), | 271 | }")), |
| 238 | 272 | ||
| 239 | partial_content(jqgrid_init(lang) + [js], | 273 | partial_content(jqgrid_init(lang) + [js], |
| @@ -443,6 +477,10 @@ public define List(CXM_Form_Field) | @@ -443,6 +477,10 @@ public define List(CXM_Form_Field) | ||
| 443 | [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)], | 477 | [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)], |
| 444 | color( s_name, c_name, value, help) then | 478 | color( s_name, c_name, value, help) then |
| 445 | [input([class("jscolor")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | 479 | [input([class("jscolor")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], |
| 480 | + phone( s_name, c_name, value, help) then | ||
| 481 | + [input([class("hk_input_phone")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | ||
| 482 | + email( s_name, c_name, value, help) then | ||
| 483 | + [input([class("hk_input_email")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | ||
| 446 | }, | 484 | }, |
| 447 | edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far) | 485 | edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far) |
| 448 | }. | 486 | }. |
| @@ -542,25 +580,33 @@ public define HTML_Partial_Content | @@ -542,25 +580,33 @@ public define HTML_Partial_Content | ||
| 542 | with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), | 580 | with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), |
| 543 | 581 | ||
| 544 | partial_content( | 582 | partial_content( |
| 545 | - [ js(js_file("js/jscolor.min.js")) | 583 | + [ js(js_file("js/jscolor.min.js")), |
| 584 | + js(js_file("js/dropzone.js")), | ||
| 585 | + js_inline(jquery_ready("Dropzone.options.myAwesomeDropzone = { | ||
| 586 | + maxFiles: 100, | ||
| 587 | + dictDefaultMessage : \""+_T("DROP_FILE_HERE")+"\", | ||
| 588 | + dictFileTooBig : \""+_T("FILE_TOO_BIG")+"\", | ||
| 589 | + }; | ||
| 590 | + $('#my-awesome-dropzone').dropzone(); ")), | ||
| 546 | ]+ | 591 | ]+ |
| 547 | jq_datetimepicker_init(lang) + | 592 | jq_datetimepicker_init(lang) + |
| 548 | get_editor_header(list_entries), //add editor header if need. Like init ck_editor | 593 | get_editor_header(list_entries), //add editor header if need. Like init ck_editor |
| 549 | sequence([ | 594 | sequence([ |
| 550 | cxm_form( table_name, lwa, | 595 | cxm_form( table_name, lwa, |
| 551 | - edit_form_lines(db, "", table_referer, _T, list_entries, create, [])+ | 596 | + |
| 552 | [ one_line_fields([ | 597 | [ one_line_fields([ |
| 553 | submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), | 598 | submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), |
| 554 | submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), | 599 | submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), |
| 555 | submit(hkc_cancel, failure, _T("CANCEL")) | 600 | submit(hkc_cancel, failure, _T("CANCEL")) |
| 556 | - ]) | ||
| 557 | - ] | ||
| 558 | - )]+ | ||
| 559 | - if id = "none" then | 601 | + ]), |
| 602 | + hr | ||
| 603 | + ]+edit_form_lines(db, "", table_referer, _T, list_entries, create, []) | ||
| 604 | + + | ||
| 605 | + (if id = "none" then | ||
| 560 | [] | 606 | [] |
| 561 | else | 607 | else |
| 562 | map( (HK_Form_Tab tab) | 608 | map( (HK_Form_Tab tab) |
| 563 | - |-> | 609 | + |-> |
| 564 | since tab is hk_form_tab(fk_table_name, fk_col_name, list_view_name), | 610 | since tab is hk_form_tab(fk_table_name, fk_col_name, list_view_name), |
| 565 | with referer = hk_referer(table_name, id, fk_table_name, fk_col_name), | 611 | with referer = hk_referer(table_name, id, fk_table_name, fk_col_name), |
| 566 | if table_in_list_view_only(db, _T, lang, web_site_directory, fk_table_name, list_view_name, "edit", "", referer, fk_clause, vtm) is | 612 | if table_in_list_view_only(db, _T, lang, web_site_directory, fk_table_name, list_view_name, "edit", "", referer, fk_clause, vtm) is |
| @@ -569,7 +615,18 @@ public define HTML_Partial_Content | @@ -569,7 +615,18 @@ public define HTML_Partial_Content | ||
| 569 | success(p_content) then partial(p_content) | 615 | success(p_content) then partial(p_content) |
| 570 | } | 616 | } |
| 571 | //text("Foreign Key from table ["+fk_table_name+"] columns ["+fk_col_name+"] view to use ["+list_view_name+"]") | 617 | //text("Foreign Key from table ["+fk_table_name+"] columns ["+fk_col_name+"] view to use ["+list_view_name+"]") |
| 572 | - ,list_tabs) | 618 | + ,list_tabs))+ |
| 619 | + [ hr, | ||
| 620 | + one_line_fields([ | ||
| 621 | + submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), | ||
| 622 | + submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), | ||
| 623 | + submit(hkc_cancel, failure, _T("CANCEL")) | ||
| 624 | + ]) | ||
| 625 | + ] | ||
| 626 | + ), | ||
| 627 | + | ||
| 628 | + form("my-awesome-dropzone",[class("dropzone")], "upload_csv_file&step=2&format=csv&table_name="+table_name, [], literal("")), | ||
| 629 | + ] | ||
| 573 | )). | 630 | )). |
| 574 | 631 | ||
| 575 | //Edit table part | 632 | //Edit table part |
| @@ -639,6 +696,11 @@ public define List(CXM_Form_Field) | @@ -639,6 +696,11 @@ public define List(CXM_Form_Field) | ||
| 639 | [input([class("datetimepicker")], no_label, html_Id(c_name), wan(c_name), init(value), custom(18), mandatory), help_line(help, _T)], | 696 | [input([class("datetimepicker")], no_label, html_Id(c_name), wan(c_name), init(value), custom(18), mandatory), help_line(help, _T)], |
| 640 | color( s_name, c_name, value, help) then | 697 | color( s_name, c_name, value, help) then |
| 641 | [input([class("jscolor")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | 698 | [input([class("jscolor")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], |
| 699 | + phone( s_name, c_name, value, help) then | ||
| 700 | + [input([class("hk_input_phone")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | ||
| 701 | + email( s_name, c_name, value, help) then | ||
| 702 | + [input([class("hk_input_email")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], | ||
| 703 | + | ||
| 642 | }. | 704 | }. |
| 643 | 705 | ||
| 644 | define List(Cell_Option) | 706 | define List(Cell_Option) |
| @@ -691,8 +753,15 @@ define CXM_Form_Field | @@ -691,8 +753,15 @@ define CXM_Form_Field | ||
| 691 | ) | 753 | ) |
| 692 | ) | 754 | ) |
| 693 | . | 755 | . |
| 756 | +public define List(CXM_Form_Field) | ||
| 757 | + get_hidden | ||
| 758 | + ( | ||
| 759 | + List(HK_Form_Table_Attribute) table_attrs | ||
| 760 | + )= | ||
| 761 | + map((HK_Form_Table_Attribute attr) |-> since attr is hidden(n, v), hidden(html_Id(""), wan(n), wav(v)), table_attrs) | ||
| 762 | +. | ||
| 694 | 763 | ||
| 695 | -public define HTML_Partial_Content | 764 | +public define HTML_Partial_Content |
| 696 | renderer_edit_table_form | 765 | renderer_edit_table_form |
| 697 | ( | 766 | ( |
| 698 | SQLite3DataBase db, | 767 | SQLite3DataBase db, |
| @@ -721,7 +790,8 @@ public define HTML_Partial_Content | @@ -721,7 +790,8 @@ public define HTML_Partial_Content | ||
| 721 | jq_datetimepicker_init(lang) + | 790 | jq_datetimepicker_init(lang) + |
| 722 | get_editor_header(table_form.form_lines), //add editor header if need. Like init ck_editor | 791 | get_editor_header(table_form.form_lines), //add editor header if need. Like init ck_editor |
| 723 | sequence([ | 792 | sequence([ |
| 724 | - cxm_form( table_name, [], lwa, | 793 | + cxm_form( table_name, [], lwa, |
| 794 | + get_hidden(table_form.table_attr)+ | ||
| 725 | [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+ | 795 | [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+ |
| 726 | [ one_line_fields([ | 796 | [ one_line_fields([ |
| 727 | submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), | 797 | submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), |