From 1ea67eb55022aaaa2c37b180530fa8d72e71f142 Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 19 Sep 2017 09:48:46 +0900 Subject: [PATCH] add phone (better management), email and url try to debug color edit !! (seems to work with dialog but not in jqgrid) --- view/jqgrid.anubis | 30 ++++++++++++++++++++++++++---- view/types/hk_form_entry.anubis | 5 +++-- view/types/hk_view.anubis | 2 +- view/view_table_renderer.anubis | 53 +++++++++++++++++++++++++++++++++++++++++------------ 4 files changed, 71 insertions(+), 19 deletions(-) diff --git a/view/jqgrid.anubis b/view/jqgrid.anubis index aef7b5e..9dcf2b0 100644 --- a/view/jqgrid.anubis +++ b/view/jqgrid.anubis @@ -57,6 +57,28 @@ define String " . +define String + custom_edit_color = +" editoptions: { + custom_element: function(value, options) { + var el = document.createElement('input'); + el.type='text'; + el.value = value; + var myPicker = new jscolor.color(el, {}); + myPicker.fromString(value); + return el; + }, + custom_value: function(elem, operation, value ) { + if (operation === 'get') { + return $(elem).val(); // change this to get value from color picker + } else if (operation === 'set') { + $('input',elem).val(value); // change this to set value of color picker + } + } + } +" +. + define String search_options ( @@ -108,10 +130,10 @@ define String date(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, formatter: \"date\", formatoptions: { newformat: \"Y-M-d\" }}", time(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true }", datetime(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true }", - color(label, column_name, help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", width: 60, editable:false, autoResizable: true, formatter:formatColor}", - phone(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype: 'custom', formatter:formatPhone, unformat:unformatPhone, "+custom_edit_phone+"}", - email(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype: 'custom', formatter:formatEmail, unformat:unformatEmail, "+custom_edit_email+"}", - + color(label, column_name, help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", width: 40, editable:true, autoResizable: true, formatter:formatColor, unformat:unformatColor, "+custom_edit_color+" }", + phone(label,column_name, ph_type, help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype: 'custom', formatter:formatPhone, unformat:unformatPhone, "+custom_edit_phone+"}", + email(label,column_name, help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype: 'custom', formatter:formatEmail, unformat:unformatEmail, "+custom_edit_email+"}", + url(label, column_name, help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, "+search_options(column_name)+" }", } . diff --git a/view/types/hk_form_entry.anubis b/view/types/hk_form_entry.anubis index ece70b9..7fc6e3b 100644 --- a/view/types/hk_form_entry.anubis +++ b/view/types/hk_form_entry.anubis @@ -36,8 +36,9 @@ public type HK_Form_Entry: //legacy VT_Edit time (String s_name, String c_name, String value, HK_Help_Text help), datetime (String s_name, String c_name, String value, HK_Help_Text help), color (String s_name, String c_name, String value, HK_Help_Text help), - phone (String s_name, String c_name, String value, HK_Help_Text help), - email (String s_name, String c_name, String value, HK_Help_Text help) + phone (String s_name, String c_name, String value, HK_Phone_Field_Attr ph_attr, HK_Help_Text help), + email (String s_name, String c_name, String value, HK_Help_Text help), + url (String s_name, String c_name, String value, HK_Help_Text help) . public define HK_Form_Entry text (String s_name, String c_name, String value) = text (s_name, c_name, value, no_help_text). diff --git a/view/types/hk_view.anubis b/view/types/hk_view.anubis index b2d9b30..af40b58 100644 --- a/view/types/hk_view.anubis +++ b/view/types/hk_view.anubis @@ -71,7 +71,7 @@ public type VT_view_model_entry: time (String label, String column_name, HK_Help_Text help), datetime (String label, String column_name, HK_Help_Text help), color (String label, String column_name, HK_Help_Text help), - phone (String label, String column_name, HK_Help_Text help), + phone (String label, String column_name, HK_Phone_Field_Attr phone_attr, HK_Help_Text help), email (String label, String column_name, HK_Help_Text help), url (String label, String column_name, HK_Help_Text help) . diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index 0da7f46..e2922db 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -40,8 +40,23 @@ read calexium_lib/web/jQuery/jqgrid.anubis read calexium_lib/web/CXM_form.anubis read calexium_lib/web/widgets/css_helper.anubis read calexium_lib/web/widgets/button.anubis +read calexium_lib/web/widgets/specialized_elements.anubis read calexium_lib/web/CXM_urllib.anubis +public define Phone_Type + convert + ( + HK_Phone_Field_Attr phone_attr + )= + if phone_attr is + { + generic then generic, + landline then landline, + cellphone then cellphone, + fax then fax + } +. + public define List(HK_Filter) get_view_filters ( @@ -728,11 +743,17 @@ public define List(CXM_Form_Field) datetime(s_name, c_name, value, help) then [input([class("datetimepicker")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), custom(18), mandatory), help_line(help, _T)], color( s_name, c_name, value, help) then - [input([class("jscolor")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], - phone( s_name, c_name, value, help) then - [phone_input([event(onclick, "hk_phone_call(this)")], [class("hk_input_phone")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + [input([class("jscolor"), style("background-color: #"+value+";")], label(_T(s_name), no_help), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + phone( s_name, c_name, value, phone_type, help) then + with event = (List(CoreAttrs))if phone_type = fax then [] else [event(onclick, "hk_phone_call(this)"), class("clickable")], + //with class = (List(CoreAttrs))if phone_type = fax then [] else [class("clickable")], + [phone_input(event, [], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), convert(phone_type), narrow, mandatory), help_line(help, _T)], + email( s_name, c_name, value, help) then - [email_input([event(onclick, "hk_send_email(this)")], [class("hk_input_email")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + [email_input([event(onclick, "hk_send_email(this)")], [class("clickable")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + + url( s_name, c_name, value, help) then + [url_input([event(onclick, "hk_go_url(this)")], [class("hk_input_url")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], }, edit_form_lines(db, fk_clause, table_referer, lwa, _T, t, new_entry, reverse(line)+so_far) }. @@ -768,7 +789,7 @@ public define HTML_Partial_Content with button_name = if create then "create" else "update", with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), with form_id = dialog_id+"_form", - println("renderer_edit_list_form dialog_id ["+dialog_id+"]"); + //println("renderer_edit_list_form dialog_id ["+dialog_id+"]"); partial_content( [ js(js_file("js/jscolor.min.js")), js(js_file("js/dropzone.js")), @@ -777,7 +798,9 @@ public define HTML_Partial_Content dictDefaultMessage : \""+_T("DROP_FILE_HERE")+"\", dictFileTooBig : \""+_T("FILE_TOO_BIG")+"\", }; - $('#my-awesome-dropzone').dropzone(); ")), + $('#my-awesome-dropzone').dropzone(); + console.log('renderer_edit_list_form: jscolor.installByClassName();');jscolor.installByClassName('jscolor'); +")), ]+ jq_datetimepicker_init(lang), //get_editor_header(list_entries)+ //add editor header if need. Like init ck_editor @@ -936,12 +959,15 @@ public define List(CXM_Form_Field) datetime(s_name, c_name, value, help) then [input([class("datetimepicker")], no_label, html_Id(c_name), wan(c_name), init(not_null_String(value)), custom(18), mandatory), help_line(help, _T)], color( s_name, c_name, value, help) then - [input([class("jscolor")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], - phone( s_name, c_name, value, help) then - [phone_input([event(onclick, "hk_phone_call(this)"), class("phone_click")], [class("hk_input_phone")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + [input([class("jscolor"), style("background-color: #"+value+";")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + phone( s_name, c_name, value, phone_type, help) then + with event = (List(CoreAttrs))if phone_type = fax then [] else [event(onclick, "hk_phone_call(this)")], + with class = (List(CoreAttrs))if phone_type = fax then [] else [class("clickable")], + [phone_input(event, class, label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), convert(phone_type), narrow, mandatory), help_line(help, _T)], email( s_name, c_name, value, help) then - [email_input([event(onclick, "hk_send_email(this)"), class("email_click")], [class("hk_input_email")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], - + [email_input([event(onclick, "hk_send_email(this)"), class("clickable")], [class("hk_input_email")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], + url( s_name, c_name, value, help) then + [url_input([event(onclick, "hk_go_url(this)"), class("clickable")], [class("hk_input_url")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], }. define List(Cell_Option) @@ -1030,7 +1056,10 @@ public define HTML_Partial_Content with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), with form_id = dialog_id+"_form", partial_content( - [ js(js_file("js/jscolor.min.js")) + [ js(js_file("js/jscolor.min.js")), + js_script("console.log(renderer_edit_table_form: jscolor.installByClassName();');jscolor.installByClassName('jscolor');") + //js_script("jscolor.init;") + ]+ jq_datetimepicker_init(lang), //get_editor_header(table_form.form_lines)+ //add editor header if need. Like init ck_editor -- libgit2 0.21.4