Commit 764acb4ef117c94b2e41bea46cf49392378dc2e1

Authored by David RENÉ
1 parent d3d2685b

add support of no add new entry when use the selector. This is useful when the u…

…ser is only allowed to select entry in selector
view/types/hk_form_entry.anubis
@@ -32,7 +32,7 @@ public type HK_Form_Entry: //legacy VT_Edit @@ -32,7 +32,7 @@ public type HK_Form_Entry: //legacy VT_Edit
32 boolean (String s_name, String c_name, Bool value, HK_Help_Text help), 32 boolean (String s_name, String c_name, Bool value, HK_Help_Text help),
33 integer (String s_name, String c_name, Int value, HK_Help_Text help), 33 integer (String s_name, String c_name, Int value, HK_Help_Text help),
34 float (String s_name, String c_name, Float value, HK_Help_Text help), 34 float (String s_name, String c_name, Float value, HK_Help_Text help),
35 - choices_int (String s_name, String c_name, Int selected, HK_Form_Selector selector, HK_Help_Text help), 35 + choices_int (String s_name, String c_name, Int selected, HK_Form_Selector selector, HK_Help_Text help),
36 date (String s_name, String c_name, String value, HK_Help_Text help), 36 date (String s_name, String c_name, String value, HK_Help_Text help),
37 time (String s_name, String c_name, String value, HK_Help_Text help), 37 time (String s_name, String c_name, String value, HK_Help_Text help),
38 datetime (String s_name, String c_name, String value, HK_Help_Text help), 38 datetime (String s_name, String c_name, String value, HK_Help_Text help),
view/view_rows_import.anubis
@@ -22,7 +22,7 @@ read calexium_lib/web/widgets/icons_set.anubis @@ -22,7 +22,7 @@ read calexium_lib/web/widgets/icons_set.anubis
22 22
23 read hayamiki_lib/view/web_action.anubis 23 read hayamiki_lib/view/web_action.anubis
24 24
25 -read web_pages/desktop.anubis 25 + read web_pages/desktop.anubis
26 read app/app_constants.anubis 26 read app/app_constants.anubis
27 read version.anubis 27 read version.anubis
28 28
@@ -184,7 +184,7 @@ public define HTML_Partial_Content @@ -184,7 +184,7 @@ public define HTML_Partial_Content
184 List((String,String)) target_columns_choices, 184 List((String,String)) target_columns_choices,
185 String separator, 185 String separator,
186 String uploaded_file, 186 String uploaded_file,
187 - WEB_Action_Name cancel_action, // 187 + WEB_Action_Name cancel_action, //
188 (String) -> String _T // translator from dictionary 188 (String) -> String _T // translator from dictionary
189 )= 189 )=
190 partial_content([css(css_file("css/cxm/cxm_dnd.css")), 190 partial_content([css(css_file("css/cxm/cxm_dnd.css")),
view/view_table_renderer.anubis
@@ -639,6 +639,7 @@ public define List(CXM_Form_Field) @@ -639,6 +639,7 @@ public define List(CXM_Form_Field)
639 (String) -> String _T, 639 (String) -> String _T,
640 List(HK_Form_Entry) list, 640 List(HK_Form_Entry) list,
641 Bool new_entry, 641 Bool new_entry,
  642 + Bool no_add,
642 List(CXM_Form_Field) so_far 643 List(CXM_Form_Field) so_far
643 )= 644 )=
644 if list is 645 if list is
@@ -689,7 +690,10 @@ public define List(CXM_Form_Field) @@ -689,7 +690,10 @@ public define List(CXM_Form_Field)
689 one_line_fields([ 690 one_line_fields([
690 partial(partial_content([js_inline(load_script)],empty)), 691 partial(partial_content([js_inline(load_script)],empty)),
691 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), 692 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),
692 - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 693 + if no_add then
  694 + empty
  695 + else
  696 + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
693 ]) 697 ])
694 ], 698 ],
695 699
@@ -709,7 +713,10 @@ public define List(CXM_Form_Field) @@ -709,7 +713,10 @@ public define List(CXM_Form_Field)
709 713
710 message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+ 714 message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+
711 "<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"), 715 "<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
712 - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 716 + if no_add then
  717 + empty
  718 + else
  719 + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
713 ]), 720 ]),
714 help_line(help, _T) 721 help_line(help, _T)
715 ] 722 ]
@@ -761,7 +768,7 @@ public define List(CXM_Form_Field) @@ -761,7 +768,7 @@ public define List(CXM_Form_Field)
761 url( s_name, c_name, value, help) then 768 url( s_name, c_name, value, help) then
762 [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)], 769 [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)],
763 }, 770 },
764 - edit_form_lines(db, fk_clause, table_referer, lwa, _T, t, new_entry, reverse(line)+so_far) 771 + edit_form_lines(db, fk_clause, table_referer, lwa, _T, t, new_entry, no_add, reverse(line)+so_far)
765 }. 772 }.
766 773
767 774
@@ -786,10 +793,11 @@ public define HTML_Partial_Content @@ -786,10 +793,11 @@ public define HTML_Partial_Content
786 ) = 793 ) =
787 //with table_name = vt_elist.table_name, 794 //with table_name = vt_elist.table_name,
788 //true if need to create row or false for updating 795 //true if need to create row or false for updating
789 - with create = if get_String(lwa, "id","none") = "none" then true else false,  
790 - with id = get_String(lwa, "id","none"),  
791 - with sub_dialog = get_String(lwa, "sub_dialog", "false"),  
792 - with dialog_id = get_String(lwa, "dialog_id", ""), 796 + with create = if get_String(lwa, "id","none") = "none" then true else false,
  797 + with no_add = get_Bool(lwa, "no_add", false),
  798 + with id = get_String(lwa, "id","none"),
  799 + with sub_dialog = get_String(lwa, "sub_dialog", "false"),
  800 + with dialog_id = get_String(lwa, "dialog_id", ""),
793 with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back 801 with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back
794 with button_label = if create then _T("CREATE") else _T("UPDATE"), 802 with button_label = if create then _T("CREATE") else _T("UPDATE"),
795 with button_name = if create then "create" else "update", 803 with button_name = if create then "create" else "update",
@@ -825,7 +833,7 @@ public define HTML_Partial_Content @@ -825,7 +833,7 @@ public define HTML_Partial_Content
825 [] 833 []
826 ) 834 )
827 + 835 +
828 - edit_form_lines(db, "", table_referer, lwa, _T, list_entries, create, []) 836 + edit_form_lines(db, "", table_referer, lwa, _T, list_entries, create, no_add, [])
829 + 837 +
830 (if id = "none" then 838 (if id = "none" then
831 [] 839 []
@@ -867,6 +875,7 @@ public define List(CXM_Form_Field) @@ -867,6 +875,7 @@ public define List(CXM_Form_Field)
867 (String) -> String _T, 875 (String) -> String _T,
868 HK_Form_Entry cell, 876 HK_Form_Entry cell,
869 Bool new_entry, 877 Bool new_entry,
  878 + Bool no_add,
870 List(CXM_Form_Field) so_far 879 List(CXM_Form_Field) so_far
871 )= 880 )=
872 881
@@ -913,7 +922,10 @@ public define List(CXM_Form_Field) @@ -913,7 +922,10 @@ public define List(CXM_Form_Field)
913 one_line_fields([ 922 one_line_fields([
914 partial(partial_content([js_inline(load_script)],empty)), 923 partial(partial_content([js_inline(load_script)],empty)),
915 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), 924 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),
916 - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 925 + if no_add then
  926 + empty
  927 + else
  928 + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
917 ]) 929 ])
918 ], 930 ],
919 931
@@ -930,7 +942,10 @@ public define List(CXM_Form_Field) @@ -930,7 +942,10 @@ public define List(CXM_Form_Field)
930 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))))), 942 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))))),
931 one_line_fields([ 943 one_line_fields([
932 message("<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"), 944 message("<input class=\"in\" id=\""+uid+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
933 - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 945 + if no_add then
  946 + empty
  947 + else
  948 + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
934 ]), 949 ]),
935 help_line(help, _T) 950 help_line(help, _T)
936 ] 951 ]
@@ -998,12 +1013,13 @@ define List(Cell_Option) @@ -998,12 +1013,13 @@ define List(Cell_Option)
998 define CXM_Form_Field 1013 define CXM_Form_Field
999 construct_edit_form_table 1014 construct_edit_form_table
1000 ( 1015 (
1001 - SQLite3DataBase db,  
1002 - HK_Referer table_referer,  
1003 - (String) -> String _T,  
1004 - List(Web_arg) lwa,  
1005 - List(HK_Form_Table_Line) form_lines,  
1006 - Bool create 1016 + SQLite3DataBase db,
  1017 + HK_Referer table_referer,
  1018 + (String) -> String _T,
  1019 + List(Web_arg) lwa,
  1020 + List(HK_Form_Table_Line) form_lines,
  1021 + Bool create, //this is new entry, db_id = none
  1022 + Bool no_add //not allow to add new entry in dropdown
1007 )= 1023 )=
1008 div([], 1024 div([],
1009 table([class("striped")], 1025 table([class("striped")],
@@ -1016,10 +1032,10 @@ define CXM_Form_Field @@ -1016,10 +1032,10 @@ define CXM_Form_Field
1016 { 1032 {
1017 //construct one cell 1033 //construct one cell
1018 hk_form_table_cell(cell_attributes, entry) then 1034 hk_form_table_cell(cell_attributes, entry) then
1019 - cell(make_cell_option(cell_attributes), to_HTML_In_Form(edit_form_cell(db, "", table_referer, lwa, _T, entry, create, []), lwa, "form_field table", false)), 1035 + cell(make_cell_option(cell_attributes), to_HTML_In_Form(edit_form_cell(db, "", table_referer, lwa, _T, entry, create, no_add, []), lwa, "form_field table", false)),
1020 //construct table in one cell 1036 //construct table in one cell
1021 hk_form_table_cell_table(cell_attributes, lines) then 1037 hk_form_table_cell_table(cell_attributes, lines) then
1022 - cell(make_cell_option(cell_attributes), to_HTML_In_Form([construct_edit_form_table(db, table_referer, _T, lwa, lines, create)], lwa, "form_field table", false)) 1038 + cell(make_cell_option(cell_attributes), to_HTML_In_Form([construct_edit_form_table(db, table_referer, _T, lwa, lines, create, no_add)], lwa, "form_field table", false))
1023 }, 1039 },
1024 line.form_table_cells 1040 line.form_table_cells
1025 ) 1041 )
@@ -1037,6 +1053,28 @@ public define List(CXM_Form_Field) @@ -1037,6 +1053,28 @@ public define List(CXM_Form_Field)
1037 map((HK_Form_Table_Attribute attr) |-> since attr is hidden(n, v), hidden(html_Id(""), wan(n), wav(v)), table_attrs) 1053 map((HK_Form_Table_Attribute attr) |-> since attr is hidden(n, v), hidden(html_Id(""), wan(n), wav(v)), table_attrs)
1038 . 1054 .
1039 1055
  1056 +public define List(CXM_Form_Field)
  1057 + get_hidden
  1058 + (
  1059 + List(Web_arg) lwa
  1060 + )=
  1061 + map_select((Web_arg warg) |->
  1062 + if warg is web_arg(name, value) then
  1063 + if starts_with(name, "hidden_") then
  1064 + with len_string = length(name),
  1065 + if sub_string(name, 7, len_string - 7) is
  1066 + {
  1067 + failure then failure,
  1068 + success(n) then success(hidden(html_Id(""), wan(n), wav(value)))
  1069 + }
  1070 + else
  1071 + failure
  1072 + else
  1073 + failure
  1074 + ,
  1075 + lwa)
  1076 +.
  1077 +
1040 public define HTML_Partial_Content 1078 public define HTML_Partial_Content
1041 renderer_edit_table_form 1079 renderer_edit_table_form
1042 ( 1080 (
@@ -1055,10 +1093,11 @@ public define HTML_Partial_Content @@ -1055,10 +1093,11 @@ public define HTML_Partial_Content
1055 ) = 1093 ) =
1056 //with table_name = vt_elist.table_name, 1094 //with table_name = vt_elist.table_name,
1057 //true if need to create row or false for updating 1095 //true if need to create row or false for updating
1058 - with create = if get_String(lwa, "id","none") = "none" then true else false,  
1059 - with id = get_String(lwa, "id","none"),  
1060 - with sub_dialog = get_String(lwa, "sub_dialog", "false"),  
1061 - with dialog_id = get_String(lwa, "dialog_id", ""), 1096 + with create = if get_String(lwa, "id","none") = "none" then true else false,
  1097 + with no_add = get_Bool(lwa, "no_add", false),
  1098 + with id = get_String(lwa, "id","none"),
  1099 + with sub_dialog = get_String(lwa, "sub_dialog", "false"),
  1100 + with dialog_id = get_String(lwa, "dialog_id", ""),
1062 with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back 1101 with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back
1063 with button_label = if create then _T("CREATE") else _T("UPDATE"), 1102 with button_label = if create then _T("CREATE") else _T("UPDATE"),
1064 with button_name = if create then "create" else "update", 1103 with button_name = if create then "create" else "update",
@@ -1075,8 +1114,9 @@ public define HTML_Partial_Content @@ -1075,8 +1114,9 @@ public define HTML_Partial_Content
1075 //get_combo_header(table_name, table_form.form_lines), //add editor header if need. Like init ck_editor 1114 //get_combo_header(table_name, table_form.form_lines), //add editor header if need. Like init ck_editor
1076 sequence([ 1115 sequence([
1077 cxm_form( form_id, [], lwa, 1116 cxm_form( form_id, [], lwa,
1078 - get_hidden(table_form.table_attr)+  
1079 - [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+ 1117 + get_hidden(table_form.table_attr)+ //collect hidden value from table form
  1118 + get_hidden(lwa)+ //collect hidden value from lwa
  1119 + [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create, no_add)]+
1080 [ one_line_fields([ 1120 [ one_line_fields([
1081 // submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), 1121 // submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]),
1082 // submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), 1122 // submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]),
@@ -1111,15 +1151,12 @@ public define Maybe(HTML_Partial_Content) @@ -1111,15 +1151,12 @@ public define Maybe(HTML_Partial_Content)
1111 ( 1151 (
1112 SQLite3DataBase db, 1152 SQLite3DataBase db,
1113 (String) -> String _T, 1153 (String) -> String _T,
1114 - String lang,  
1115 - //String web_site_directory, 1154 + String lang,
1116 List(Web_arg) lwa, 1155 List(Web_arg) lwa,
1117 - //String dialog_id,  
1118 String table, //table name 1156 String table, //table name
1119 String view_name, //view name to use 1157 String view_name, //view name to use
1120 HK_Form_action action, //new_entry or edit an existing record 1158 HK_Form_action action, //new_entry or edit an existing record
1121 VTM vtm, 1159 VTM vtm,
1122 - //String clause,  
1123 String fk_clause, 1160 String fk_clause,
1124 HK_Referer referer 1161 HK_Referer referer
1125 ) = 1162 ) =
@@ -1143,15 +1180,13 @@ public define Maybe(HTML_Partial_Content) @@ -1143,15 +1180,13 @@ public define Maybe(HTML_Partial_Content)
1143 ( 1180 (
1144 SQLite3DataBase db, 1181 SQLite3DataBase db,
1145 (String) -> String _T, 1182 (String) -> String _T,
1146 - String lang,  
1147 - //String web_site_directory, 1183 + String lang,
1148 List(Web_arg) lwa, 1184 List(Web_arg) lwa,
1149 - //String dialog_id,  
1150 String table, //table name 1185 String table, //table name
1151 String view_name, //view name to use 1186 String view_name, //view name to use
1152 HK_Form_action action, //new_entry or edit an existing record 1187 HK_Form_action action, //new_entry or edit an existing record
1153 VTM vtm 1188 VTM vtm
1154 ) = 1189 ) =
1155 - edit_table_content(db, _T, lang, /*web_site_directory,*/ lwa, /*dialog_id,*/ table, view_name, action, vtm, "", /*"",*/ no_referer) 1190 + edit_table_content(db, _T, lang, lwa, table, view_name, action, vtm, "", no_referer)
1156 . 1191 .
1157 1192