diff --git a/hayamiki_lib b/hayamiki_lib index 7c694bd..4eeb47a 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit 7c694bdb28d105b490596e5a7c186da619654bbb +Subproject commit 4eeb47a275bd6a512a15b2284c27d3408caaead5 diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index 211ba51..69e1de6 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -150,7 +150,8 @@ public define Maybe(String) float_field then success(name), char_field(_,_) then success(name), password_field(_) then success(name), - text_field(_) then success(name) + text_field(_) then success(name), + color_field then success(name), }. public define List(String) @@ -266,7 +267,8 @@ public define Maybe(String) success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") } password_field(min_size) then success("password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")") - text_field(txt_attr) then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")") + text_field(txt_attr) then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")"), + color_field then success("color(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), }. public define String @@ -316,6 +318,7 @@ public define String char_field(_,_) then current_type_name+"."+name, password_field(_) then current_type_name+"."+name, text_field(_) then current_type_name+"."+name + color_field then current_type_name+"."+name }. diff --git a/src/generation/extractor.anubis b/src/generation/extractor.anubis index a25adfc..fe24b22 100644 --- a/src/generation/extractor.anubis +++ b/src/generation/extractor.anubis @@ -30,7 +30,8 @@ public define String float_field then "db_float"+cursor_index, char_field(_,_) then "text"+cursor_index, password_field(_) then "text"+cursor_index, - text_field(_) then "text"+cursor_index + text_field(_) then "text"+cursor_index, + color_field then "text"+cursor_index }. define List(String) diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index b8eb3e9..4b546c5 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -35,7 +35,8 @@ public define String float_field then "Float", char_field(_,_) then "String", password_field(_) then "String", - text_field(_) then "String" + text_field(_) then "String", + color_field then "String", }. public define String @@ -57,7 +58,8 @@ public define String float_field then "float", char_field(_,_) then "string", password_field(_) then "string", - text_field(_) then "string" + text_field(_) then "string", + color_field then "string" }. public define String @@ -80,6 +82,7 @@ public define String char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), password_field(size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), text_field(_) then fill("TEXT", 15) + format_attributes(attributes), + color_field then fill("VARCHAR(8)",15)+ format_attributes(attributes), }. public define String @@ -101,7 +104,8 @@ public define String float_field then "(Float)0.0", char_field(choices,size) then "\"\"", password_field(min_size) then "\"\"", - text_field(_) then "\"\"" + text_field(_) then "\"\"", + color_field then "#DDD", }. @@ -139,5 +143,6 @@ public define String float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", - text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" + text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", + color_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", }. diff --git a/src/generation/files.anubis b/src/generation/files.anubis index ba0fea0..b0e75dd 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -192,7 +192,7 @@ define One [table . t] then since table is hk_table(name, _, _, _), with transmit = "transmit "+name+".anubis", - with view = "vtm_view(\""+name+"\", get_viewable_"+name+")", + with view = "vtm_view(\""+name+"\", get_viewable_"+name+", get_all_"+name+"_view_name)", with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")", with writer = "tm_writer(\""+name+"\", update_"+name+"_from_type, update_"+name+"_from_fields)", with delete = "tm_delete(\""+name+"\", delete_"+name+")", diff --git a/src/generation/html.anubis b/src/generation/html.anubis index b9ec2df..53fff34 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -102,6 +102,7 @@ public define String "text(\"********\")", //to_HTML_cell_text(column, data_name, general_type_name), text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), + color_field then to_HTML_cell_text(column, data_name, general_type_name), } }. diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis index 394910a..89c3190 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -33,6 +33,7 @@ public define String float_field then icn16_question, char_field(choice, size) then icn16_question, password_field(min_size) then icn16_question, - text_field(_) then icn16_question + text_field(_) then icn16_question, + color_field then icn16_question }. diff --git a/src/generation/json.anubis b/src/generation/json.anubis index 0188678..a8fd335 100644 --- a/src/generation/json.anubis +++ b/src/generation/json.anubis @@ -33,7 +33,8 @@ public define String float_field then "float_to_string("+current_type_name+"."+name+",5)", char_field(_,_) then "to_JSON_String("+current_type_name+"."+name+")", password_field(_) then "to_JSON_String("+current_type_name+"."+name+")", - text_field(_) then "to_JSON_String("+current_type_name+"."+name+")" + text_field(_) then "to_JSON_String("+current_type_name+"."+name+")", + color_field then "to_JSON_String("+current_type_name+"."+name+")", } . @@ -62,7 +63,8 @@ public define String float_field then "json_member(\""+name+"\", json_float("+current_type_name+"."+name+",5))", char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", password_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", - text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))" + text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", + color_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))" } . @@ -88,5 +90,6 @@ public define String char_field(_,_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", password_field(_) then "json_member(\""+name+"\", json_string(\"******\"))", text_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" + color_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" } . diff --git a/src/generation/vt_view.anubis b/src/generation/vt_view.anubis index 07111f7..df57812 100644 --- a/src/generation/vt_view.anubis +++ b/src/generation/vt_view.anubis @@ -74,8 +74,9 @@ define String else "text(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" } - password_field(min_size) then "password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" - text_field(txt_attr) then "text_area(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" + password_field(min_size) then "password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", + text_field(txt_attr) then "text_area(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", + color_field then "color(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" }. @@ -265,8 +266,73 @@ public define Maybe(One) failure then println("can't write generate_get_viewable "+table_name); failure, success(_) then success(unique) }. + +public define List(String) +/* Generate + +*/ + _generate_list_view_name + ( + List(HK_List_View) list_view, //list view to generate + List(String) so_far, + Bool has_default //set to true if a default view was encountered. + )= + if list_view is + { + [] then + //if default view was not generated, we force to generate it + if has_default = false then + reverse(["\"default\"" . so_far]) + else + reverse(so_far), + [view . t] then + with new_has_default = if has_default = true then //already true, no need to go further + true + else + if view is + { + list_view_all then true, //list_view_all is default view + list_view(view_name, _, _) then + //if not we search for view named 'default' + if view_name = "default" then true else false + }, + with view_name = if view is + { + list_view_all then "default", + list_view(view_name, _, _) then view_name + }, + _generate_list_view_name(t, ["\""+view_name+"\"" . so_far], new_has_default) + } +. public define Maybe(One) + _generate_get_all_view_name + ( + Stream stream, + HK_Table table, // + List(HK_List_View) list_view + )= + since table is hk_table(table_name, short_name, model, display), + if write_string(stream, + "\n\npublic define List(String)\n"+ + " get_all_"+table_name+"_view_name\n"+ + " (\n"+ + " One dummy\n"+ + " )=\n"+ + " [\n"+ + " "+join(",\n ",_generate_list_view_name(list_view, [], false))+ + "\n ]\n"+ + ".\n\n" + ) is //end of the function + { + failure then println("can't write _generate_get_all_view_name "+table_name); failure, + success(_) then success(unique) + } +. + + + +public define Maybe(One) generate_VT_all_view ( Stream stream, @@ -277,8 +343,15 @@ public define Maybe(One) since display is hk_display(list_view, list_edit), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. - if _generate_VT_view(stream, table, list_view, false) is //list view to generate + if _generate_get_all_view_name(stream, table, list_view) is { - failure then failure, - success(_) then generate_get_viewable(stream, table, list_view) - }. + failure then failure, + success(_) then + + if _generate_VT_view(stream, table, list_view, false) is //list view to generate + { + failure then failure, + success(_) then generate_get_viewable(stream, table, list_view) + } + } +. diff --git a/src/generation/web_args.anubis b/src/generation/web_args.anubis index e3d37c4..1dc523a 100644 --- a/src/generation/web_args.anubis +++ b/src/generation/web_args.anubis @@ -30,7 +30,8 @@ public define String float_field then "get_Float(lwa, __prefix__+\""+name+"\")", char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", password_field(min_size) then "get_Password(lwa, __prefix__+\""+name+"_1\", __prefix__+\""+name+"_2\")", - text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")" + text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")", + color_field then "get_String(lwa, __prefix__+\""+name+"\")", }. define (List(String), Int) @@ -139,8 +140,10 @@ public define String " )" // if get_Password(lwa, __prefix__+"password_1", __prefix__+"password_2") is {failure then [], success(password) then [field("passwxord", bind_String(":v_password", password))] } text_field(_) then + "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }", + color_field then "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" - //"get_String(lwa, __prefix__+\""+name+"\")" + //"get_String(lwa, __prefix__+\""+name+"\")" }. define String -- libgit2 0.21.4