Commit 99a54291b71c079ff268a039c9c43cc17e093f36

Authored by totoro
1 parent 7aee2bab

start working on text_area with CKeditor.

view/view_table_renderer.anubis
@@ -88,8 +88,9 @@ public define List(CXM_Form_Field) @@ -88,8 +88,9 @@ public define List(CXM_Form_Field)
88 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(to_String(value))), mandatory), help_line(help, _T)], 88 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(to_String(value))), mandatory), help_line(help, _T)],
89 choices_text(s_name, c_name, value, select, help) then 89 choices_text(s_name, c_name, value, select, help) then
90 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(value)), mandatory), help_line(help, _T)], 90 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db), success(init(value)), mandatory), help_line(help, _T)],
91 - text_area(s_name, c_name, value, help) then  
92 - [text_area([],label(_T(s_name), no_help), html_Id(""), wan(c_name), init(not_null_String(value)), narrow, (Int)5, mandatory), help_line(help, _T)], 91 + text_area(s_name, c_name, value, txt_editor, help) then
  92 + with id = if txt_editor is { none then "", rich_editor then c_name+"_editor"},
  93 + [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)],
93 boolean(s_name, c_name, value, help) then 94 boolean(s_name, c_name, value, help) then
94 [checkboxr([],label(_T(s_name), no_help), html_Id(""), wan(c_name), wav(c_name),value, mandatory), help_line(help, _T)], 95 [checkboxr([],label(_T(s_name), no_help), html_Id(""), wan(c_name), wav(c_name),value, mandatory), help_line(help, _T)],
95 integer(s_name, c_name, value, help) then 96 integer(s_name, c_name, value, help) then
@@ -106,6 +107,32 @@ public define List(CXM_Form_Field) @@ -106,6 +107,32 @@ public define List(CXM_Form_Field)
106 edit_form_lines(db, _T, t, reverse(line)+so_far) 107 edit_form_lines(db, _T, t, reverse(line)+so_far)
107 }. 108 }.
108 109
  110 +define HTML_Head_Tag
  111 + get_rich_editor_inline
  112 + (
  113 + List(VT_edit_entry) list
  114 + )=
  115 + js_inline(jquery_ready(
  116 + join("",map_select((VT_edit_entry entry) |->
  117 + if entry is text_area(s_name, c_name, value, txt_editor, help) then
  118 + if txt_editor is { none then failure,
  119 + rich_editor then success("CKEDITOR.on( 'loaded', function(){\n CKEDITOR.replace( '"+c_name+"_editor' );});")
  120 + }
  121 + else
  122 + failure, list))
  123 + ))
  124 +.
  125 +
  126 +define List(HTML_Head_Tag)
  127 + get_editor_header
  128 + (
  129 + List(VT_edit_entry) list
  130 + )=
  131 + [js(js_file("ckeditor/ckeditor.js")),
  132 + get_rich_editor_inline(list),
  133 + ]
  134 + .
  135 +
109 public define HTML_Partial_Content 136 public define HTML_Partial_Content
110 edit_table_page 137 edit_table_page
111 ( 138 (
@@ -117,7 +144,11 @@ public define HTML_Partial_Content @@ -117,7 +144,11 @@ public define HTML_Partial_Content
117 ) = 144 ) =
118 with table_name = vt_elist.table_name, 145 with table_name = vt_elist.table_name,
119 with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"), 146 with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"),
120 - partial_content(jq_datetimepicker_init(lang), 147 +
  148 +
  149 + partial_content(
  150 + jq_datetimepicker_init(lang) +
  151 + get_editor_header(vt_elist.list), //add editor header if need. Like init ck_editor
121 cxm_form( table_name, lwa, 152 cxm_form( table_name, lwa,
122 edit_form_lines(db, _T, vt_elist.list, [])+ 153 edit_form_lines(db, _T, vt_elist.list, [])+
123 [ one_line_fields([ 154 [ one_line_fields([
view/view_table_types.anubis
@@ -21,9 +21,9 @@ public type VT_edit_entry: @@ -21,9 +21,9 @@ public type VT_edit_entry:
21 password (String s_name, String c_name, HK_Help_Text help), //s_name = show_name for translation, c_name = table column name 21 password (String s_name, String c_name, HK_Help_Text help), //s_name = show_name for translation, c_name = table column name
22 foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector, HK_Help_Text help), 22 foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector, HK_Help_Text help),
23 choices_text(String s_name, String c_name, String selected, VT_edit_selector selector, HK_Help_Text help), 23 choices_text(String s_name, String c_name, String selected, VT_edit_selector selector, HK_Help_Text help),
24 - text_area (String s_name, String c_name, String value, HK_Help_Text help), //s_name = show_name for translate, c_name = table column name  
25 - boolean (String s_name, String c_name, Bool value, HK_Text_Field_Attr area_att, HK_Help_Text help),  
26 - integer (String s_name, String c_name, Int value, HK_Help_Text help), 24 + text_area (String s_name, String c_name, String value, HK_Text_Field_Attr area_att, HK_Help_Text help), //s_name = show_name for translate, c_name = table column name
  25 + boolean (String s_name, String c_name, Bool value, HK_Help_Text help),
  26 + integer (String s_name, String c_name, Int value, HK_Help_Text help),
27 choices_int (String s_name, String c_name, Int selected, VT_edit_selector selector, HK_Help_Text help), 27 choices_int (String s_name, String c_name, Int selected, VT_edit_selector selector, HK_Help_Text help),
28 date (String s_name, String c_name, String value, HK_Help_Text help), 28 date (String s_name, String c_name, String value, HK_Help_Text help),
29 time (String s_name, String c_name, String value, HK_Help_Text help), 29 time (String s_name, String c_name, String value, HK_Help_Text help),
@@ -31,7 +31,7 @@ public type VT_edit_entry: @@ -31,7 +31,7 @@ public type VT_edit_entry:
31 31
32 public define VT_edit_entry text (String s_name, String c_name, String value) = text(s_name, c_name, value, no_help_text). 32 public define VT_edit_entry text (String s_name, String c_name, String value) = text(s_name, c_name, value, no_help_text).
33 public define VT_edit_entry foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector) = foreign_text(s_name, c_name, selected, selector, no_help_text). 33 public define VT_edit_entry foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector) = foreign_text(s_name, c_name, selected, selector, no_help_text).
34 -public define VT_edit_entry text_area (String s_name, String c_name, String value) = text_area(s_name, c_name, value, no_help_text). 34 +public define VT_edit_entry text_area (String s_name, String c_name, String value) = text_area(s_name, c_name, value, none, no_help_text).
35 public define VT_edit_entry boolean(String s_name, String c_name, Bool value) = boolean(s_name, c_name, value, no_help_text). 35 public define VT_edit_entry boolean(String s_name, String c_name, Bool value) = boolean(s_name, c_name, value, no_help_text).
36 public define VT_edit_entry integer(String s_name, String c_name, Int value) = integer(s_name, c_name, value, no_help_text). 36 public define VT_edit_entry integer(String s_name, String c_name, Int value) = integer(s_name, c_name, value, no_help_text).
37 public define VT_edit_entry information(String s_name, String c_name, String v_name, HK_Help_Text help) = information(s_name, c_name, v_name, 0, help). 37 public define VT_edit_entry information(String s_name, String c_name, String v_name, HK_Help_Text help) = information(s_name, c_name, v_name, 0, help).