From ef877b079541989d8b116a8a2f067996c538a5d4 Mon Sep 17 00:00:00 2001 From: totoro Date: Fri, 28 Apr 2017 23:56:26 +0900 Subject: [PATCH] format table form --- view/view_table_renderer.anubis | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 81 insertions(+), 21 deletions(-) diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index 554474f..57406fd 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -17,6 +17,7 @@ read hayamiki_lib/types/hayamiki.anubis read system/string.anubis read locale/L3.anubis read tools/basis.anubis +read tools/list.anubis read data_base/sqlite.anubis read system_colors/rgb.anubis read system/convert.anubis @@ -446,31 +447,74 @@ public define List(CXM_Form_Field) edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far) }. -define HTML_Head_Tag +define List(String) get_rich_editor_inline ( List(HK_Form_Entry) list )= - js_inline(jquery_ready( - join("",map_select((HK_Form_Entry entry) |-> + map_select((HK_Form_Entry entry) |-> if entry is text_area(s_name, c_name, value, txt_editor, help) then if txt_editor is { none then failure, rich_editor then success(" CKEDITOR.replace( '"+c_name+"_editor' );") } else - failure, list)) - )) + failure, list) . define List(HTML_Head_Tag) get_editor_header ( - List(HK_Form_Entry) list + List(HK_Form_Entry) _list + )= + with result = get_rich_editor_inline(_list), + if length(result) > 0 then + [js(js_file("ckeditor/ckeditor.js")), + js_inline(jquery_ready(join("",result))) + ] + else + [] + . + +define List(String) + _get_editor_header + ( + List(HK_Form_Table_Line) _lines )= - [js(js_file("ckeditor/ckeditor.js")), - get_rich_editor_inline(list), - ] + map_append((HK_Form_Table_Line line) + |-> + map_append((HK_Form_Table_Cell cell) + |-> + if cell is + { + hk_form_table_cell(_, form_entry) then + if form_entry is text_area(s_name, c_name, value, txt_editor, help) then + if txt_editor is { + none then [], + rich_editor then [" CKEDITOR.replace( '"+c_name+"_editor' );"] + } + else + [], + hk_form_table_cell_table(_, t_lines) then + _get_editor_header(t_lines) + }, + line.form_table_cells), + _lines) +. + +define List(HTML_Head_Tag) + get_editor_header + ( + List(HK_Form_Table_Line) _lines + )= + with result = _get_editor_header(_lines), + if length(result) > 0 then + [js(js_file("ckeditor/ckeditor.js")), + js_inline(jquery_ready(join("",result))) + ] + else + [] . + public define HTML_Partial_Content renderer_edit_list_form @@ -596,7 +640,23 @@ public define List(CXM_Form_Field) 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)], }. - + +define List(Cell_Option) + make_cell_option + ( + List(HK_Form_Table_Cell_Attribute) attributes + )= + map((HK_Form_Table_Cell_Attribute attr) + |-> + if attr is + { + colspan(number) then columns(number), + rowspan(number) then rows(number) + }, + attributes + ) +. + define CXM_Form_Field construct_edit_form_table ( @@ -608,22 +668,20 @@ define CXM_Form_Field Bool create )= div([], - table([], + table([class("striped")], map((HK_Form_Table_Line line) |-> //construct line row( map((HK_Form_Table_Cell cell_content) |-> - - if cell_content is { //construct one cell - hk_form_table_cell(entry) then - cell(fieldset(lwa, edit_form_cell(db, "", table_referer, _T, entry, create, []))), + hk_form_table_cell(cell_attributes, entry) then + cell(make_cell_option(cell_attributes), to_HTML_In_Form(edit_form_cell(db, "", table_referer, _T, entry, create, []), lwa, "form_field table", false)), //construct table in one cell - hk_form_table_cell_table(lines) then - cell(fieldset(lwa, [construct_edit_form_table(db, table_referer, _T, lwa, lines, create)])) + 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)) }, line.form_table_cells ) @@ -660,17 +718,19 @@ public define HTML_Partial_Content partial_content( [ js(js_file("js/jscolor.min.js")) ]+ - jq_datetimepicker_init(lang), - //get_editor_header(list_entries), //add editor header if need. Like init ck_editor + jq_datetimepicker_init(lang) + + get_editor_header(table_form.form_lines), //add editor header if need. Like init ck_editor sequence([ - cxm_form( table_name, lwa, + cxm_form( table_name, [], lwa, [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+ [ 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)]), submit(hkc_cancel, failure, _T("CANCEL")) ]) - ] + ], + "form_field table", + false )] // if id = "none" then // [] -- libgit2 0.21.4