Commit ef877b079541989d8b116a8a2f067996c538a5d4
1 parent
95c6d506
format table form
Showing
1 changed file
with
81 additions
and
21 deletions
Show diff stats
view/view_table_renderer.anubis
| ... | ... | @@ -17,6 +17,7 @@ read hayamiki_lib/types/hayamiki.anubis |
| 17 | 17 | read system/string.anubis |
| 18 | 18 | read locale/L3.anubis |
| 19 | 19 | read tools/basis.anubis |
| 20 | +read tools/list.anubis | |
| 20 | 21 | read data_base/sqlite.anubis |
| 21 | 22 | read system_colors/rgb.anubis |
| 22 | 23 | read system/convert.anubis |
| ... | ... | @@ -446,31 +447,74 @@ public define List(CXM_Form_Field) |
| 446 | 447 | edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far) |
| 447 | 448 | }. |
| 448 | 449 | |
| 449 | -define HTML_Head_Tag | |
| 450 | +define List(String) | |
| 450 | 451 | get_rich_editor_inline |
| 451 | 452 | ( |
| 452 | 453 | List(HK_Form_Entry) list |
| 453 | 454 | )= |
| 454 | - js_inline(jquery_ready( | |
| 455 | - join("",map_select((HK_Form_Entry entry) |-> | |
| 455 | + map_select((HK_Form_Entry entry) |-> | |
| 456 | 456 | if entry is text_area(s_name, c_name, value, txt_editor, help) then |
| 457 | 457 | if txt_editor is { none then failure, |
| 458 | 458 | rich_editor then success(" CKEDITOR.replace( '"+c_name+"_editor' );") |
| 459 | 459 | } |
| 460 | 460 | else |
| 461 | - failure, list)) | |
| 462 | - )) | |
| 461 | + failure, list) | |
| 463 | 462 | . |
| 464 | 463 | |
| 465 | 464 | define List(HTML_Head_Tag) |
| 466 | 465 | get_editor_header |
| 467 | 466 | ( |
| 468 | - List(HK_Form_Entry) list | |
| 467 | + List(HK_Form_Entry) _list | |
| 468 | + )= | |
| 469 | + with result = get_rich_editor_inline(_list), | |
| 470 | + if length(result) > 0 then | |
| 471 | + [js(js_file("ckeditor/ckeditor.js")), | |
| 472 | + js_inline(jquery_ready(join("",result))) | |
| 473 | + ] | |
| 474 | + else | |
| 475 | + [] | |
| 476 | + . | |
| 477 | + | |
| 478 | +define List(String) | |
| 479 | + _get_editor_header | |
| 480 | + ( | |
| 481 | + List(HK_Form_Table_Line) _lines | |
| 469 | 482 | )= |
| 470 | - [js(js_file("ckeditor/ckeditor.js")), | |
| 471 | - get_rich_editor_inline(list), | |
| 472 | - ] | |
| 483 | + map_append((HK_Form_Table_Line line) | |
| 484 | + |-> | |
| 485 | + map_append((HK_Form_Table_Cell cell) | |
| 486 | + |-> | |
| 487 | + if cell is | |
| 488 | + { | |
| 489 | + hk_form_table_cell(_, form_entry) then | |
| 490 | + if form_entry is text_area(s_name, c_name, value, txt_editor, help) then | |
| 491 | + if txt_editor is { | |
| 492 | + none then [], | |
| 493 | + rich_editor then [" CKEDITOR.replace( '"+c_name+"_editor' );"] | |
| 494 | + } | |
| 495 | + else | |
| 496 | + [], | |
| 497 | + hk_form_table_cell_table(_, t_lines) then | |
| 498 | + _get_editor_header(t_lines) | |
| 499 | + }, | |
| 500 | + line.form_table_cells), | |
| 501 | + _lines) | |
| 502 | +. | |
| 503 | + | |
| 504 | +define List(HTML_Head_Tag) | |
| 505 | + get_editor_header | |
| 506 | + ( | |
| 507 | + List(HK_Form_Table_Line) _lines | |
| 508 | + )= | |
| 509 | + with result = _get_editor_header(_lines), | |
| 510 | + if length(result) > 0 then | |
| 511 | + [js(js_file("ckeditor/ckeditor.js")), | |
| 512 | + js_inline(jquery_ready(join("",result))) | |
| 513 | + ] | |
| 514 | + else | |
| 515 | + [] | |
| 473 | 516 | . |
| 517 | + | |
| 474 | 518 | |
| 475 | 519 | public define HTML_Partial_Content |
| 476 | 520 | renderer_edit_list_form |
| ... | ... | @@ -596,7 +640,23 @@ public define List(CXM_Form_Field) |
| 596 | 640 | color( s_name, c_name, value, help) then |
| 597 | 641 | [input([class("jscolor")], no_label, wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], |
| 598 | 642 | }. |
| 599 | - | |
| 643 | + | |
| 644 | +define List(Cell_Option) | |
| 645 | + make_cell_option | |
| 646 | + ( | |
| 647 | + List(HK_Form_Table_Cell_Attribute) attributes | |
| 648 | + )= | |
| 649 | + map((HK_Form_Table_Cell_Attribute attr) | |
| 650 | + |-> | |
| 651 | + if attr is | |
| 652 | + { | |
| 653 | + colspan(number) then columns(number), | |
| 654 | + rowspan(number) then rows(number) | |
| 655 | + }, | |
| 656 | + attributes | |
| 657 | + ) | |
| 658 | +. | |
| 659 | + | |
| 600 | 660 | define CXM_Form_Field |
| 601 | 661 | construct_edit_form_table |
| 602 | 662 | ( |
| ... | ... | @@ -608,22 +668,20 @@ define CXM_Form_Field |
| 608 | 668 | Bool create |
| 609 | 669 | )= |
| 610 | 670 | div([], |
| 611 | - table([], | |
| 671 | + table([class("striped")], | |
| 612 | 672 | map((HK_Form_Table_Line line) |
| 613 | 673 | |-> //construct line |
| 614 | 674 | row( |
| 615 | 675 | map((HK_Form_Table_Cell cell_content) |
| 616 | 676 | |-> |
| 617 | - | |
| 618 | - | |
| 619 | 677 | if cell_content is |
| 620 | 678 | { |
| 621 | 679 | //construct one cell |
| 622 | - hk_form_table_cell(entry) then | |
| 623 | - cell(fieldset(lwa, edit_form_cell(db, "", table_referer, _T, entry, create, []))), | |
| 680 | + hk_form_table_cell(cell_attributes, entry) then | |
| 681 | + cell(make_cell_option(cell_attributes), to_HTML_In_Form(edit_form_cell(db, "", table_referer, _T, entry, create, []), lwa, "form_field table", false)), | |
| 624 | 682 | //construct table in one cell |
| 625 | - hk_form_table_cell_table(lines) then | |
| 626 | - cell(fieldset(lwa, [construct_edit_form_table(db, table_referer, _T, lwa, lines, create)])) | |
| 683 | + hk_form_table_cell_table(cell_attributes, lines) then | |
| 684 | + 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)) | |
| 627 | 685 | }, |
| 628 | 686 | line.form_table_cells |
| 629 | 687 | ) |
| ... | ... | @@ -660,17 +718,19 @@ public define HTML_Partial_Content |
| 660 | 718 | partial_content( |
| 661 | 719 | [ js(js_file("js/jscolor.min.js")) |
| 662 | 720 | ]+ |
| 663 | - jq_datetimepicker_init(lang), | |
| 664 | - //get_editor_header(list_entries), //add editor header if need. Like init ck_editor | |
| 721 | + jq_datetimepicker_init(lang) + | |
| 722 | + get_editor_header(table_form.form_lines), //add editor header if need. Like init ck_editor | |
| 665 | 723 | sequence([ |
| 666 | - cxm_form( table_name, lwa, | |
| 724 | + cxm_form( table_name, [], lwa, | |
| 667 | 725 | [construct_edit_form_table(db, table_referer, _T, lwa, table_form.form_lines, create)]+ |
| 668 | 726 | [ one_line_fields([ |
| 669 | 727 | submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name)]), |
| 670 | 728 | submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), |
| 671 | 729 | submit(hkc_cancel, failure, _T("CANCEL")) |
| 672 | 730 | ]) |
| 673 | - ] | |
| 731 | + ], | |
| 732 | + "form_field table", | |
| 733 | + false | |
| 674 | 734 | )] |
| 675 | 735 | // if id = "none" then |
| 676 | 736 | // [] | ... | ... |