diff --git a/types/model/fields.anubis b/types/model/fields.anubis index a005706..1cc9708 100644 --- a/types/model/fields.anubis +++ b/types/model/fields.anubis @@ -106,6 +106,49 @@ public type HK_Int_Choices: no_choice, //No list choice is available. Hence the user must enter the value int_choices(List(HK_Int_Choice)). //List of possible choices +public type HK_Text_Field_Attr: + none, //Nothing special, normal behaviour + rich_editor. //Use richt text editor for that area + +define String + to_String + ( + HK_Text_Field_Attr attr + )= + if attr is + { + none then "none", + rich_editor then "rich_editor" + }. + +public define String + to_Anubis_source + ( + HK_Text_Field_Attr attr + )= + to_String(attr) +. + +define HK_Text_Field_Attr + to_HK_Text_Field_Attr + ( + String txt_attr_str + )= + if txt_attr_str = "none" then none else + if txt_attr_str = "rich_editor" then rich_editor + else none +. + +define HK_Text_Field_Attr + get_text_attribute + ( + Message msg + )= + if find_string(msg, "text_attribute") is + { + failure then none, + success(text_attrib) then to_HK_Text_Field_Attr(text_attrib) + }. public type HK_Datetime_Field_Attr: none, //Nothing special, normal behaviour @@ -155,7 +198,7 @@ public type HK_Model_Field: integer_field (HK_Int_Choices choices), // integer of arbitrary size char_field (HK_Text_Choices choices, Int size), // text of maximal size 'size' (number of characters) password_field(Int min_size), // the password field doesn't show the password string or store it in hashed version into database - text_field. // text of variable size + text_field (HK_Text_Field_Attr). // text of variable size //default initialization public define HK_Model_Field @@ -177,6 +220,12 @@ public define HK_Model_Field )= foreign_key(this, table_name). +public define HK_Model_Field + text_field + = + text_field(none) +. + /* * _HK_FIELD message format: ============================= @@ -248,8 +297,9 @@ public define Message forget(add_string(hk_model_field_message, "type", "password_field")); forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), - text_field then // text of variable size - forget(add_string(hk_model_field_message, "type", "text_field")) + text_field(text_attr) then // text of variable size + forget(add_string(hk_model_field_message, "type", "text_field")); + forget(add_string(hk_model_field_message, "text_attribute", to_String(text_attr))), }; hk_model_field_message @@ -305,8 +355,10 @@ public define JsonValue json_member("size", json_int(size)) ], - text_field then // text of variable size - [ json_member("type", json_string("text_field"))] + text_field(attr) then // text of variable size + [ json_member("type", json_string("text_field")), + json_member("text_attribute", json_string(to_String(attr))) + ] }, json_object("_HK_FIELD", members). @@ -335,7 +387,7 @@ define Maybe(HK_Model_Field) else if type = "password_field" then if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then success(password_field(to_Int(w32_size)))} - else if type = "text_field" then success(text_field) + else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) else failure . diff --git a/view/view_table_types.anubis b/view/view_table_types.anubis index 77115ef..96dbcf2 100644 --- a/view/view_table_types.anubis +++ b/view/view_table_types.anubis @@ -12,6 +12,7 @@ read hayamiki_lib/types/hayamiki.anubis public type VT_edit_selector: vt_edit_selector((SQLite3DataBase db) -> List((List(CoreAttrs), WebArgValue, String)) get). + public type VT_edit_entry: hidden (String name, String value), primary_key (String idx), @@ -21,7 +22,7 @@ public type VT_edit_entry: foreign_text(String s_name, String c_name, DB_id selected, VT_edit_selector selector, HK_Help_Text help), choices_text(String s_name, String c_name, String selected, VT_edit_selector selector, HK_Help_Text help), 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 - boolean (String s_name, String c_name, Bool value, HK_Help_Text help), + boolean (String s_name, String c_name, Bool value, HK_Text_Field_Attr area_att, HK_Help_Text help), integer (String s_name, String c_name, Int value, HK_Help_Text help), choices_int (String s_name, String c_name, Int selected, VT_edit_selector selector, HK_Help_Text help), date (String s_name, String c_name, String value, HK_Help_Text help), -- libgit2 0.21.4