Commit 601f9714449737d52f05351db81e3c22fd0b27a7

Authored by totoro
1 parent 135b0bfd

add crud web action

make uid more safe by adding _ as prefix. Sometime that uid is use as function name. This prevent that uid start with number which not allowed for function name
fix ajax combo bug by initialize each with different uid
add resolve_fk parameter in get_one_json and get_rows_json. that allows to retrieve the value of foreign instead of id
view/view_apps_renderer.anubis
@@ -22,6 +22,7 @@ define List(HTML_Row(HTML_Off_Form)) @@ -22,6 +22,7 @@ define List(HTML_Row(HTML_Off_Form))
22 ( 22 (
23 SQLite3DataBase db, 23 SQLite3DataBase db,
24 List(HK_App) apps, 24 List(HK_App) apps,
  25 + String dialog_uid,
25 (String) -> String _T, 26 (String) -> String _T,
26 )= 27 )=
27 map_append((HK_App app) |-> since app is hk_app(app_name, icon, help, tables), 28 map_append((HK_App app) |-> since app is hk_app(app_name, icon, help, tables),
@@ -34,8 +35,8 @@ define List(HTML_Row(HTML_Off_Form)) @@ -34,8 +35,8 @@ define List(HTML_Row(HTML_Off_Form))
34 [ cell(text(_table_name)), 35 [ cell(text(_table_name)),
35 cell( 36 cell(
36 sequence([ 37 sequence([
37 - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id("edit_table_dlg_ajax"), "'table_name="+table_name+"'"))], "", [])),  
38 - actioner(link([core_attrs([event(onclick, jq_dialog_open(dialog_id("edit_table_dlg_ajax"), "'table_name="+table_name+"'"))])],_T("ADD")), no_action, []) 38 + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(dialog_uid), "'table_name="+table_name+"'"))], "", [])),
  39 + actioner(link([core_attrs([event(onclick, jq_dialog_open(dialog_id(dialog_uid), "'table_name="+table_name+"'"))])],_T("ADD")), no_action, [])
39 ]) 40 ])
40 ), 41 ),
41 cell( 42 cell(
@@ -70,11 +71,12 @@ public define Maybe(HTML_Partial_Content) @@ -70,11 +71,12 @@ public define Maybe(HTML_Partial_Content)
70 String lang, 71 String lang,
71 String web_site_directory 72 String web_site_directory
72 ) = 73 ) =
  74 + with dialog_uid = "_"+generate_random_string(15)+"_cxm_dlg",
73 success(partial_content([css(css_file("hayamiki/hayamiki.css")),]+ 75 success(partial_content([css(css_file("hayamiki/hayamiki.css")),]+
74 jq_dialog_init + jq_datetimepicker_init(lang), 76 jq_dialog_init + jq_datetimepicker_init(lang),
75 sequence([ 77 sequence([
76 - partial(jq_dialog_create(dialog_id("edit_table_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table")))), /*&table_name="+rows.table_name*/  
77 - table([class("hk_table_apps")], generate_apps(db, hk_db.apps, _T)) 78 + partial(jq_dialog_create(dialog_id(dialog_uid), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+dialog_uid)))), /*&table_name="+rows.table_name*/
  79 + table([class("hk_table_apps")], generate_apps(db, hk_db.apps, dialog_uid, _T))
78 ]) 80 ])
79 )) 81 ))
80 . 82 .
view/view_table_manager_types.anubis
@@ -45,8 +45,8 @@ public type HK_Table_controller: @@ -45,8 +45,8 @@ public type HK_Table_controller:
45 (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_fields, 45 (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_fields,
46 //Read 46 //Read
47 (SQLite3DataBase db, String clause) -> Int get_count, 47 (SQLite3DataBase db, String clause) -> Int get_count,
48 - (SQLite3DataBase db, List(String) columns, DB_id) -> JsonValue get_one_json,  
49 - (SQLite3DataBase db, List(String) columns, HK_Referer referer, String clause, String order_by) -> JsonValue get_rows_json, 48 + (SQLite3DataBase db, List(String) columns, Bool resolve_fk, DB_id) -> JsonValue get_one_json,
  49 + (SQLite3DataBase db, List(String) columns, Bool resolve_fk, HK_Referer referer, String clause, String order_by) -> JsonValue get_rows_json,
50 //Update 50 //Update
51 //Delete 51 //Delete
52 (SQLite3DataBase db, List(Int) l_int) -> Maybe(One) delete, 52 (SQLite3DataBase db, List(Int) l_int) -> Maybe(One) delete,
view/view_table_renderer.anubis
@@ -114,6 +114,28 @@ public define HK_Filter @@ -114,6 +114,28 @@ public define HK_Filter
114 get_filter_from_name(filters, filter_name) 114 get_filter_from_name(filters, filter_name)
115 . 115 .
116 116
  117 +define String
  118 + ajax_combo_init_parameter
  119 + (
  120 + String combo_uid,
  121 + String f_table, //db table name
  122 + String c_name, //column name in the table
  123 + List(String) s_fields //search fields
  124 + )=
  125 +"$('#"+combo_uid+"').ajaxComboBox( '?aws_controller=hk_c&aws_action=combo_search',
  126 + {
  127 + lang: 'fr',
  128 + per_page: 15,
  129 + db_table: '"+f_table+"',
  130 + button_img: 'ajax-combobox/btn.png',
  131 + field: '"+force_nth(0, s_fields, "name")+"',
  132 + search_field: '"+join(", ", s_fields)+"',
  133 + hidden_name: '"+c_name+"',
  134 + show_string: '"+join(", ", s_fields)+"',
  135 + and_or: 'OR'
  136 + });"
  137 +.
  138 +
117 define HTML_In_Form 139 define HTML_In_Form
118 /* create a selector for choosing the view name. 140 /* create a selector for choosing the view name.
119 * The selector create an immediate action. This means when the entry is selected, the action is fired. 141 * The selector create an immediate action. This means when the entry is selected, the action is fired.
@@ -458,7 +480,7 @@ public define HTML_Partial_Content @@ -458,7 +480,7 @@ public define HTML_Partial_Content
458 with referer_arg = "&"+to_Web_arg(table_referer, ""), 480 with referer_arg = "&"+to_Web_arg(table_referer, ""),
459 481
460 482
461 - with uid = generate_random_string(20)+"_", 483 + with uid = "_"+generate_random_string(15)+"_",
462 partial_content([ js(js_file("js/jscolor.min.js")) 484 partial_content([ js(js_file("js/jscolor.min.js"))
463 ]+jq_dialog_init + jq_datetimepicker_init(lang), 485 ]+jq_dialog_init + jq_datetimepicker_init(lang),
464 [html_wave_box_wide(_T(to_upper(current_view.table_name)), 486 [html_wave_box_wide(_T(to_upper(current_view.table_name)),
@@ -583,7 +605,7 @@ define CXM_Form_Field @@ -583,7 +605,7 @@ define CXM_Form_Field
583 605
584 606
585 //Edit table part 607 //Edit table part
586 -public define List(CXM_Form_Field) 608 +public define List(CXM_Form_Field)
587 edit_form_lines 609 edit_form_lines
588 ( 610 (
589 SQLite3DataBase db, 611 SQLite3DataBase db,
@@ -655,13 +677,19 @@ public define List(CXM_Form_Field) @@ -655,13 +677,19 @@ public define List(CXM_Form_Field)
655 // ]) 677 // ])
656 // ], 678 // ],
657 679
658 - foreign_text_search(s_name, c_name, select, foreign_table_name, fields, help) then  
659 - with uid = "_"+generate_random_string(20)+"_", 680 + foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then
  681 + with uid = "_"+generate_random_string(20)+"_",
  682 + with combo_init = ajax_combo_init_parameter(uid, foreign_table_name, c_name, s_fields),
660 [ 683 [
661 - partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name)))), 684 +
  685 + partial(partial_content([ js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")),
  686 + css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")),
  687 + js_inline(jquery_ready(combo_init))],
  688 + jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name))))),
662 one_line_fields([ 689 one_line_fields([
  690 +
663 message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+ 691 message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+
664 - "<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"), 692 + "<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
665 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 693 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
666 ]), 694 ]),
667 help_line(help, _T) 695 help_line(help, _T)
@@ -669,9 +697,24 @@ public define List(CXM_Form_Field) @@ -669,9 +697,24 @@ public define List(CXM_Form_Field)
669 697
670 choices_text(s_name, c_name, value, select, help) then 698 choices_text(s_name, c_name, value, select, help) then
671 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)], 699 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)],
  700 +
672 text_area(s_name, c_name, value, txt_editor, help) then 701 text_area(s_name, c_name, value, txt_editor, help) then
673 - with id = if txt_editor is { none then "", rich_editor then c_name+"_editor"},  
674 - [text_area([],label(_T(s_name), no_help), html_Id(id), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T)], 702 + with uid = "_"+generate_random_string(20),
  703 + with id = if txt_editor is { none then "", rich_editor then uid+"_editor"},
  704 + [
  705 + if txt_editor is {
  706 + none then empty,
  707 + rich_editor then partial(partial_content(
  708 + [ js(js_file("ckeditor/ckeditor.js")),
  709 + js_inline(jquery_ready(
  710 + " var cke_instance = CKEDITOR.replace( '"+id+"' );
  711 + //cxm_cke('"+id+"');
  712 + cke_instance.on('blur', function() { cke_instance.updateElement(); });
  713 + "))],empty))
  714 + },
  715 + text_area([],label(_T(s_name), no_help), html_Id(id), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T)
  716 + ],
  717 +
675 boolean(s_name, c_name, value, help) then 718 boolean(s_name, c_name, value, help) then
676 [checkboxr([],label(_T(s_name), no_help), html_Id(""), wan(c_name), wav("true"),value, mandatory), help_line(help, _T)], 719 [checkboxr([],label(_T(s_name), no_help), html_Id(""), wan(c_name), wav("true"),value, mandatory), help_line(help, _T)],
677 integer(s_name, c_name, value, help) then 720 integer(s_name, c_name, value, help) then
@@ -696,166 +739,147 @@ public define List(CXM_Form_Field) @@ -696,166 +739,147 @@ public define List(CXM_Form_Field)
696 edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far) 739 edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far)
697 }. 740 }.
698 741
699 -define List(String)  
700 - get_rich_editor_inline  
701 - (  
702 - List(HK_Form_Entry) list  
703 - )=  
704 - map_select((HK_Form_Entry entry) |->  
705 - if entry is text_area(s_name, c_name, value, txt_editor, help) then  
706 - if txt_editor is { none then failure,  
707 - rich_editor then success(" CKEDITOR.replace( '"+c_name+"_editor' );")  
708 - }  
709 - else  
710 - failure, list)  
711 -. 742 +//define List(String)
  743 +// get_rich_editor_inline
  744 +// (
  745 +// List(HK_Form_Entry) list
  746 +// )=
  747 +// map_select((HK_Form_Entry entry) |->
  748 +// if entry is text_area(s_name, c_name, value, txt_editor, help) then
  749 +// if txt_editor is { none then failure,
  750 +// rich_editor then success(" CKEDITOR.replace( '"+c_name+"_editor' );")
  751 +// }
  752 +// else
  753 +// failure, list)
  754 +//.
712 755
713 -define List(HTML_Head_Tag)  
714 - get_editor_header  
715 - (  
716 - List(HK_Form_Entry) _list  
717 - )=  
718 - with result = get_rich_editor_inline(_list),  
719 - if length(result) > 0 then  
720 - [js(js_file("ckeditor/ckeditor.js")),  
721 - js_inline(jquery_ready(join("",result)))  
722 - ]  
723 - else  
724 - []  
725 - . 756 +// define List(HTML_Head_Tag)
  757 +// get_editor_header
  758 +// (
  759 +// List(HK_Form_Entry) _list
  760 +// )=
  761 +// with result = get_rich_editor_inline(_list),
  762 +// if length(result) > 0 then
  763 +// [
  764 +// js_inline(jquery_ready(join("",result)))
  765 +// ]
  766 +// else
  767 +// []
  768 +// .
726 769
727 -define List(String)  
728 - _get_editor_header  
729 - (  
730 - List(HK_Form_Table_Line) _lines  
731 - )=  
732 - map_append((HK_Form_Table_Line line)  
733 - |->  
734 - map_append((HK_Form_Table_Cell cell)  
735 - |->  
736 - if cell is  
737 - {  
738 - hk_form_table_cell(_, form_entry) then  
739 - if form_entry is text_area(s_name, c_name, value, txt_editor, help) then  
740 - if txt_editor is {  
741 - none then [],  
742 - rich_editor then [" CKEDITOR.replace( '"+c_name+"_editor' );"]  
743 - }  
744 - else  
745 - [],  
746 - hk_form_table_cell_table(_, t_lines) then  
747 - _get_editor_header(t_lines)  
748 - },  
749 - line.form_table_cells),  
750 - _lines)  
751 -. 770 +//define List(String)
  771 +// _get_editor_header
  772 +// (
  773 +// List(HK_Form_Table_Line) _lines
  774 +// )=
  775 +// map_append((HK_Form_Table_Line line)
  776 +// |->
  777 +// map_append((HK_Form_Table_Cell cell)
  778 +// |->
  779 +// if cell is
  780 +// {
  781 +// hk_form_table_cell(_, form_entry) then
  782 +// if form_entry is text_area(s_name, c_name, value, txt_editor, help) then
  783 +// if txt_editor is {
  784 +// none then [],
  785 +// rich_editor then [" CKEDITOR.replace( '"+c_name+"_editor' );"]
  786 +// }
  787 +// else
  788 +// [],
  789 +// hk_form_table_cell_table(_, t_lines) then
  790 +// _get_editor_header(t_lines)
  791 +// },
  792 +// line.form_table_cells),
  793 +// _lines)
  794 +//.
752 795
753 -define String  
754 - ajax_combo_init_parameter  
755 - (  
756 - String f_table, //db table name  
757 - String c_name, //column name in the table  
758 - List(String) s_fields //search fields  
759 - )=  
760 -"$('#acb_"+c_name+"').ajaxComboBox( '?aws_controller=hk_c&aws_action=combo_search',  
761 - {  
762 - lang: 'fr',  
763 - per_page: 15,  
764 - db_table: '"+f_table+"',  
765 - button_img: 'ajax-combobox/btn.png',  
766 - field: '"+force_nth(0, s_fields, "name")+"',  
767 - search_field: '"+join(", ", s_fields)+"',  
768 - hidden_name: '"+c_name+"',  
769 - show_string: '"+join(", ", s_fields)+"',  
770 - and_or: 'OR'  
771 - });"  
772 -.  
773 796
774 -define List(String)  
775 - _get_combo_header  
776 - (  
777 - String table_name,  
778 - List(HK_Form_Table_Line) _lines  
779 - )=  
780 - map_append((HK_Form_Table_Line line)  
781 - |->  
782 - map_append((HK_Form_Table_Cell cell)  
783 - |->  
784 - if cell is  
785 - {  
786 - hk_form_table_cell(_, form_entry) then  
787 - if form_entry is foreign_text_search(s_name, c_name, select, f_table, s_fields, help) then  
788 - [ajax_combo_init_parameter(f_table, c_name, s_fields)]  
789 - else  
790 - [],  
791 - hk_form_table_cell_table(_, t_lines) then  
792 - _get_combo_header(table_name, t_lines)  
793 - },  
794 - line.form_table_cells),  
795 - _lines)  
796 -.  
797 797
798 -define List(HTML_Head_Tag)  
799 - get_editor_header  
800 - (  
801 - List(HK_Form_Table_Line) _lines  
802 - )=  
803 - with result = _get_editor_header(_lines),  
804 - if length(result) > 0 then  
805 - [js(js_file("ckeditor/ckeditor.js")),  
806 - js_inline(jquery_ready(join("",result)))  
807 - ]  
808 - else  
809 - []  
810 - . 798 +//define List(String)
  799 +// _get_combo_header
  800 +// (
  801 +// String table_name,
  802 +// List(HK_Form_Table_Line) _lines
  803 +// )=
  804 +// map_append((HK_Form_Table_Line line)
  805 +// |->
  806 +// map_append((HK_Form_Table_Cell cell)
  807 +// |->
  808 +// if cell is
  809 +// {
  810 +// hk_form_table_cell(_, form_entry) then
  811 +// if form_entry is foreign_text_search(s_name, c_name, select, f_table, s_fields, help) then
  812 +// [ajax_combo_init_parameter(f_table, c_name, s_fields)]
  813 +// else
  814 +// [],
  815 +// hk_form_table_cell_table(_, t_lines) then
  816 +// _get_combo_header(table_name, t_lines)
  817 +// },
  818 +// line.form_table_cells),
  819 +// _lines)
  820 +//.
  821 +
  822 +//define List(HTML_Head_Tag)
  823 +// get_editor_header
  824 +// (
  825 +// List(HK_Form_Table_Line) _lines
  826 +// )=
  827 +// with result = _get_editor_header(_lines),
  828 +// if length(result) > 0 then
  829 +// [js(js_file("ckeditor/ckeditor.js")),
  830 +// js_inline(jquery_ready(join("",result)))
  831 +// ]
  832 +// else
  833 +// []
  834 +// .
811 835
812 -define List(HTML_Head_Tag)  
813 - get_combo_header  
814 - (  
815 - String table_name,  
816 - List(HK_Form_Table_Line) _lines  
817 - )=  
818 - with result = _get_combo_header(table_name, _lines),  
819 - if length(result) > 0 then  
820 - [js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")),  
821 - css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")),  
822 - js_inline(jquery_ready(join("",result)))  
823 - ]  
824 - else  
825 - []  
826 - . 836 +//define List(HTML_Head_Tag)
  837 +// get_combo_header
  838 +// (
  839 +// String table_name,
  840 +// List(HK_Form_Table_Line) _lines
  841 +// )=
  842 +// with result = _get_combo_header(table_name, _lines),
  843 +// if length(result) > 0 then
  844 +// [js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")),
  845 +// css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")),
  846 +// js_inline(jquery_ready(join("",result)))
  847 +// ]
  848 +// else
  849 +// []
  850 +// .
827 851
828 -define List(String)  
829 - _get_combo_header  
830 - (  
831 - String table_name,  
832 - List(HK_Form_Entry) _entries  
833 - )=  
834 - map_append((HK_Form_Entry entry)  
835 - |->  
836 - if entry is foreign_text_search(s_name, c_name, select, f_table, s_fields, help) then  
837 - [ajax_combo_init_parameter(f_table, c_name, s_fields)]  
838 - else  
839 - []  
840 - ,  
841 - _entries)  
842 -. 852 +//define List(String)
  853 +// _get_combo_header
  854 +// (
  855 +// String table_name,
  856 +// List(HK_Form_Entry) _entries
  857 +// )=
  858 +// map_append((HK_Form_Entry entry)
  859 +// |->
  860 +// if entry is foreign_text_search(s_name, c_name, select, f_table, s_fields, help) then
  861 +// []
  862 +// else
  863 +// []
  864 +// ,
  865 +// _entries)
  866 +//.
843 867
844 -define List(HTML_Head_Tag)  
845 - get_combo_header  
846 - (  
847 - String table_name,  
848 - List(HK_Form_Entry) _lines  
849 - )=  
850 - with result = _get_combo_header(table_name, _lines),  
851 - if length(result) > 0 then  
852 - [js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")),  
853 - css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")),  
854 - js_inline(jquery_ready(join("",result)))  
855 - ]  
856 - else  
857 - []  
858 - . 868 +//define List(HTML_Head_Tag)
  869 +// get_combo_header
  870 +// (
  871 +// String table_name,
  872 +// List(HK_Form_Entry) _lines
  873 +// )=
  874 +// with result = _get_combo_header(table_name, _lines),
  875 +// if length(result) > 0 then
  876 +// [js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")),
  877 +// css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")),
  878 +// js_inline(jquery_ready(join("",result)))
  879 +// ]
  880 +// else
  881 +// []
  882 +// .
859 883
860 public define HTML_Partial_Content 884 public define HTML_Partial_Content
861 renderer_edit_list_form 885 renderer_edit_list_form
@@ -898,9 +922,9 @@ public define HTML_Partial_Content @@ -898,9 +922,9 @@ public define HTML_Partial_Content
898 }; 922 };
899 $('#my-awesome-dropzone').dropzone(); ")), 923 $('#my-awesome-dropzone').dropzone(); ")),
900 ]+ 924 ]+
901 - jq_datetimepicker_init(lang) +  
902 - get_editor_header(list_entries)+ //add editor header if need. Like init ck_editor  
903 - get_combo_header(table_name, list_entries), 925 + jq_datetimepicker_init(lang),
  926 + //get_editor_header(list_entries)+ //add editor header if need. Like init ck_editor
  927 + //get_combo_header(table_name, list_entries),
904 sequence([ 928 sequence([
905 cxm_form( table_name, lwa, 929 cxm_form( table_name, lwa,
906 (if length(list_entries) > 19 then 930 (if length(list_entries) > 19 then
@@ -1000,28 +1024,47 @@ public define List(CXM_Form_Field) @@ -1000,28 +1024,47 @@ public define List(CXM_Form_Field)
1000 partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name)))), 1024 partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name)))),
1001 one_line_fields([ 1025 one_line_fields([
1002 partial(partial_content([js_inline(load_script)],empty)), 1026 partial(partial_content([js_inline(load_script)],empty)),
1003 - selector_c([],label(_T(s_name), no_help), html_Id(uid+foreign_table_name+"_"+c_name+"_selector"), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T), 1027 + selector_c([],label(_T(s_name), no_help), html_Id(uid+foreign_table_name+"_"+c_name+"_selector"), wan(c_name), 1, /*select.get(db, table_referer, fk_clause)*/ [], success(init("")), mandatory), help_line(help, _T),
1004 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 1028 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
1005 ]) 1029 ])
1006 ], 1030 ],
1007 - 1031 +
1008 foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then 1032 foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then
1009 //[raw_in_form(literal("<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"))] 1033 //[raw_in_form(literal("<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"))]
1010 - with uid = "_"+generate_random_string(20)+"_", 1034 + with uid = "_"+generate_random_string(20)+"_",
  1035 + with combo_init = ajax_combo_init_parameter(uid, foreign_table_name, c_name, s_fields),
1011 [ 1036 [
1012 - partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name)))), 1037 + partial(partial_content([
  1038 + js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")),
  1039 + css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")),
  1040 + js_inline(jquery_ready(combo_init))],
  1041 + jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name))))),
1013 one_line_fields([ 1042 one_line_fields([
1014 - message("<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"), 1043 + message("<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
1015 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 1044 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
1016 ]), 1045 ]),
1017 help_line(help, _T) 1046 help_line(help, _T)
1018 ] 1047 ]
1019 - 1048 +
1020 choices_text(s_name, c_name, value, select, help) then 1049 choices_text(s_name, c_name, value, select, help) then
1021 [selector_c([],no_label, html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)], 1050 [selector_c([],no_label, html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)],
  1051 +
1022 text_area(s_name, c_name, value, txt_editor, help) then 1052 text_area(s_name, c_name, value, txt_editor, help) then
1023 - with id = if txt_editor is { none then "", rich_editor then c_name+"_editor"},  
1024 - [text_area([],no_label, html_Id(id), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T)], 1053 + with uid = "_"+generate_random_string(20),
  1054 + with id = if txt_editor is { none then "", rich_editor then uid+"_editor"},
  1055 + [
  1056 + if txt_editor is {
  1057 + none then empty,
  1058 + rich_editor then partial(partial_content(
  1059 + [js(js_file("ckeditor/ckeditor.js")),
  1060 + js_inline(jquery_ready(
  1061 + " var cke_instance = CKEDITOR.replace( '"+id+"' );
  1062 + //cxm_cke('"+id+"');
  1063 + cke_instance.on('blur', function() { cke_instance.updateElement(); });
  1064 + "))],empty))
  1065 + },
  1066 + text_area([],no_label, html_Id(id), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T)],
  1067 +
1025 boolean(s_name, c_name, value, help) then 1068 boolean(s_name, c_name, value, help) then
1026 [checkboxr([],no_label, html_Id(""), wan(c_name), wav("true"),value, mandatory), help_line(help, _T)], 1069 [checkboxr([],no_label, html_Id(""), wan(c_name), wav("true"),value, mandatory), help_line(help, _T)],
1027 integer(s_name, c_name, value, help) then 1070 integer(s_name, c_name, value, help) then
@@ -1123,23 +1166,30 @@ public define HTML_Partial_Content @@ -1123,23 +1166,30 @@ public define HTML_Partial_Content
1123 //true if need to create row or false for updating 1166 //true if need to create row or false for updating
1124 with create = if get_String(lwa, "id","none") = "none" then true else false, 1167 with create = if get_String(lwa, "id","none") = "none" then true else false,
1125 with id = get_String(lwa, "id","none"), 1168 with id = get_String(lwa, "id","none"),
1126 - with button_name = if create then _T("CREATE") else _T("UPDATE"), 1169 + with sub_dialog = get_String(lwa, "sub_dialog", "false"),
  1170 + with dialog_id = get_String(lwa, "dialog_id", ""),
  1171 + with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back
  1172 + with button_label = if create then _T("CREATE") else _T("UPDATE"),
  1173 + with button_name = if create then "create" else "update",
1127 with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), 1174 with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"),
1128 1175
1129 partial_content( 1176 partial_content(
1130 [ js(js_file("js/jscolor.min.js")) 1177 [ js(js_file("js/jscolor.min.js"))
1131 ]+ 1178 ]+
1132 - jq_datetimepicker_init(lang) +  
1133 - get_editor_header(table_form.form_lines)+ //add editor header if need. Like init ck_editor  
1134 - get_combo_header(table_name, table_form.form_lines), //add editor header if need. Like init ck_editor 1179 + jq_datetimepicker_init(lang),
  1180 + //get_editor_header(table_form.form_lines)+ //add editor header if need. Like init ck_editor
  1181 + //get_combo_header(table_name, table_form.form_lines), //add editor header if need. Like init ck_editor
1135 sequence([ 1182 sequence([
1136 cxm_form( table_name, [], lwa, 1183 cxm_form( table_name, [], lwa,
1137 get_hidden(table_form.table_attr)+ 1184 get_hidden(table_form.table_attr)+
1138 [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+ 1185 [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+
1139 [ one_line_fields([ 1186 [ one_line_fields([
1140 - submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]),  
1141 - submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]),  
1142 - submit(hkc_cancel, failure, _T("CANCEL")) 1187 +// submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]),
  1188 +// submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]),
  1189 +// submit(hkc_cancel, failure, _T("CANCEL"))
  1190 + partial(jquery_button(jQuery_button(button, dialog_id+button_name, button_name, button_label, jQuery_actioner(same, jqscript(jq_form_submit_and_close(dialog_id, table_name, hkc_update_row, [("table_name", table_name), ("sub_dialog", sub_dialog)], after_close_cb)))))),
  1191 + partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))),
  1192 +
1143 ]) 1193 ])
1144 ], 1194 ],
1145 "form_field table", 1195 "form_field table",
view/web_action.anubis
@@ -16,6 +16,7 @@ public define WEB_Action_Name hkc_grid_view = controller_action(&quot;hk_c&quot; @@ -16,6 +16,7 @@ public define WEB_Action_Name hkc_grid_view = controller_action(&quot;hk_c&quot;
16 public define WEB_Action_Name hkc_grid_action = controller_action("hk_c", "grid_action"). 16 public define WEB_Action_Name hkc_grid_action = controller_action("hk_c", "grid_action").
17 public define WEB_Action_Name hkc_combo_search = controller_action("hk_c", "combo_search"). 17 public define WEB_Action_Name hkc_combo_search = controller_action("hk_c", "combo_search").
18 public define WEB_Action_Name hkc_selector = controller_action("hk_c", "selector"). //get dropdown HMTL content 18 public define WEB_Action_Name hkc_selector = controller_action("hk_c", "selector"). //get dropdown HMTL content
  19 +public define WEB_Action_Name hkc_query = controller_action("hk_c", "query"). //CRUD action
19 20
20 public define WEB_Action_Name hkc_list_view = controller_action("hk_c", "view_table"). 21 public define WEB_Action_Name hkc_list_view = controller_action("hk_c", "view_table").
21 public define WEB_Action_Name hkc_list_view_name = controller_action("hk_c", "hkc_list_view_name"). 22 public define WEB_Action_Name hkc_list_view_name = controller_action("hk_c", "hkc_list_view_name").