diff --git a/view/types/hk_form_entry.anubis b/view/types/hk_form_entry.anubis
index 402f358..ed98f85 100644
--- a/view/types/hk_form_entry.anubis
+++ b/view/types/hk_form_entry.anubis
@@ -32,7 +32,7 @@ public type HK_Form_Entry: //legacy VT_Edit
boolean (String s_name, String c_name, Bool value, HK_Help_Text help),
integer (String s_name, String c_name, Int value, HK_Help_Text help),
float (String s_name, String c_name, Float value, HK_Help_Text help),
- choices_int (String s_name, String c_name, Int selected, HK_Form_Selector selector, HK_Help_Text help),
+ choices_int (String s_name, String c_name, Int selected, HK_Form_Selector selector, HK_Help_Text help),
date (String s_name, String c_name, String value, HK_Help_Text help),
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),
diff --git a/view/view_rows_import.anubis b/view/view_rows_import.anubis
index 9ecf5d9..659e7f3 100644
--- a/view/view_rows_import.anubis
+++ b/view/view_rows_import.anubis
@@ -22,7 +22,7 @@ read calexium_lib/web/widgets/icons_set.anubis
read hayamiki_lib/view/web_action.anubis
-read web_pages/desktop.anubis
+ read web_pages/desktop.anubis
read app/app_constants.anubis
read version.anubis
@@ -184,7 +184,7 @@ public define HTML_Partial_Content
List((String,String)) target_columns_choices,
String separator,
String uploaded_file,
- WEB_Action_Name cancel_action, //
+ WEB_Action_Name cancel_action, //
(String) -> String _T // translator from dictionary
)=
partial_content([css(css_file("css/cxm/cxm_dnd.css")),
diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis
index a5495ef..edd6758 100644
--- a/view/view_table_renderer.anubis
+++ b/view/view_table_renderer.anubis
@@ -639,6 +639,7 @@ public define List(CXM_Form_Field)
(String) -> String _T,
List(HK_Form_Entry) list,
Bool new_entry,
+ Bool no_add,
List(CXM_Form_Field) so_far
)=
if list is
@@ -689,7 +690,10 @@ public define List(CXM_Form_Field)
one_line_fields([
partial(partial_content([js_inline(load_script)],empty)),
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),
- partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
+ if no_add then
+ empty
+ else
+ partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
])
],
@@ -709,7 +713,10 @@ public define List(CXM_Form_Field)
message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+
""),
- partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
+ if no_add then
+ empty
+ else
+ partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
]),
help_line(help, _T)
]
@@ -761,7 +768,7 @@ public define List(CXM_Form_Field)
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)
+ edit_form_lines(db, fk_clause, table_referer, lwa, _T, t, new_entry, no_add, reverse(line)+so_far)
}.
@@ -786,10 +793,11 @@ public define HTML_Partial_Content
) =
//with table_name = vt_elist.table_name,
//true if need to create row or false for updating
- with create = if get_String(lwa, "id","none") = "none" then true else false,
- with id = get_String(lwa, "id","none"),
- with sub_dialog = get_String(lwa, "sub_dialog", "false"),
- with dialog_id = get_String(lwa, "dialog_id", ""),
+ with create = if get_String(lwa, "id","none") = "none" then true else false,
+ with no_add = get_Bool(lwa, "no_add", false),
+ with id = get_String(lwa, "id","none"),
+ with sub_dialog = get_String(lwa, "sub_dialog", "false"),
+ with dialog_id = get_String(lwa, "dialog_id", ""),
with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back
with button_label = if create then _T("CREATE") else _T("UPDATE"),
with button_name = if create then "create" else "update",
@@ -825,7 +833,7 @@ public define HTML_Partial_Content
[]
)
+
- edit_form_lines(db, "", table_referer, lwa, _T, list_entries, create, [])
+ edit_form_lines(db, "", table_referer, lwa, _T, list_entries, create, no_add, [])
+
(if id = "none" then
[]
@@ -867,6 +875,7 @@ public define List(CXM_Form_Field)
(String) -> String _T,
HK_Form_Entry cell,
Bool new_entry,
+ Bool no_add,
List(CXM_Form_Field) so_far
)=
@@ -913,7 +922,10 @@ public define List(CXM_Form_Field)
one_line_fields([
partial(partial_content([js_inline(load_script)],empty)),
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),
- partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
+ if no_add then
+ empty
+ else
+ partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
])
],
@@ -930,7 +942,10 @@ public define List(CXM_Form_Field)
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))))),
one_line_fields([
message(""),
- partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
+ if no_add then
+ empty
+ else
+ partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
]),
help_line(help, _T)
]
@@ -998,12 +1013,13 @@ define List(Cell_Option)
define CXM_Form_Field
construct_edit_form_table
(
- SQLite3DataBase db,
- HK_Referer table_referer,
- (String) -> String _T,
- List(Web_arg) lwa,
- List(HK_Form_Table_Line) form_lines,
- Bool create
+ SQLite3DataBase db,
+ HK_Referer table_referer,
+ (String) -> String _T,
+ List(Web_arg) lwa,
+ List(HK_Form_Table_Line) form_lines,
+ Bool create, //this is new entry, db_id = none
+ Bool no_add //not allow to add new entry in dropdown
)=
div([],
table([class("striped")],
@@ -1016,10 +1032,10 @@ define CXM_Form_Field
{
//construct one cell
hk_form_table_cell(cell_attributes, entry) then
- 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)),
+ 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)),
//construct table in one cell
hk_form_table_cell_table(cell_attributes, lines) then
- 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))
+ 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))
},
line.form_table_cells
)
@@ -1037,6 +1053,28 @@ public define List(CXM_Form_Field)
map((HK_Form_Table_Attribute attr) |-> since attr is hidden(n, v), hidden(html_Id(""), wan(n), wav(v)), table_attrs)
.
+public define List(CXM_Form_Field)
+ get_hidden
+ (
+ List(Web_arg) lwa
+ )=
+ map_select((Web_arg warg) |->
+ if warg is web_arg(name, value) then
+ if starts_with(name, "hidden_") then
+ with len_string = length(name),
+ if sub_string(name, 7, len_string - 7) is
+ {
+ failure then failure,
+ success(n) then success(hidden(html_Id(""), wan(n), wav(value)))
+ }
+ else
+ failure
+ else
+ failure
+ ,
+ lwa)
+.
+
public define HTML_Partial_Content
renderer_edit_table_form
(
@@ -1055,10 +1093,11 @@ public define HTML_Partial_Content
) =
//with table_name = vt_elist.table_name,
//true if need to create row or false for updating
- with create = if get_String(lwa, "id","none") = "none" then true else false,
- with id = get_String(lwa, "id","none"),
- with sub_dialog = get_String(lwa, "sub_dialog", "false"),
- with dialog_id = get_String(lwa, "dialog_id", ""),
+ with create = if get_String(lwa, "id","none") = "none" then true else false,
+ with no_add = get_Bool(lwa, "no_add", false),
+ with id = get_String(lwa, "id","none"),
+ with sub_dialog = get_String(lwa, "sub_dialog", "false"),
+ with dialog_id = get_String(lwa, "dialog_id", ""),
with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back
with button_label = if create then _T("CREATE") else _T("UPDATE"),
with button_name = if create then "create" else "update",
@@ -1075,8 +1114,9 @@ public define HTML_Partial_Content
//get_combo_header(table_name, table_form.form_lines), //add editor header if need. Like init ck_editor
sequence([
cxm_form( form_id, [], lwa,
- get_hidden(table_form.table_attr)+
- [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+
+ get_hidden(table_form.table_attr)+ //collect hidden value from table form
+ get_hidden(lwa)+ //collect hidden value from lwa
+ [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create, no_add)]+
[ one_line_fields([
// submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]),
// 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)
(
SQLite3DataBase db,
(String) -> String _T,
- String lang,
- //String web_site_directory,
+ String lang,
List(Web_arg) lwa,
- //String dialog_id,
String table, //table name
String view_name, //view name to use
HK_Form_action action, //new_entry or edit an existing record
VTM vtm,
- //String clause,
String fk_clause,
HK_Referer referer
) =
@@ -1143,15 +1180,13 @@ public define Maybe(HTML_Partial_Content)
(
SQLite3DataBase db,
(String) -> String _T,
- String lang,
- //String web_site_directory,
+ String lang,
List(Web_arg) lwa,
- //String dialog_id,
String table, //table name
String view_name, //view name to use
HK_Form_action action, //new_entry or edit an existing record
VTM vtm
) =
- edit_table_content(db, _T, lang, /*web_site_directory,*/ lwa, /*dialog_id,*/ table, view_name, action, vtm, "", /*"",*/ no_referer)
+ edit_table_content(db, _T, lang, lwa, table, view_name, action, vtm, "", no_referer)
.
--
libgit2 0.21.4