Commit 24d83682542bb02d83012911d04252501628137d
1 parent
190a0eb4
add generation of vt_edit with foreign key view
Showing
10 changed files
with
267 additions
and
41 deletions
Show diff stats
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 14/03/2017 | ||
| 5 | + * Time: 22:50 | ||
| 6 | + * © Calexium | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +read tools/basis.anubis | ||
| 11 | +read densaku_lib/ds_generator.anubis | ||
| 12 | +read hayamiki_lib/ds_files/ds_types.anubis | ||
| 13 | +//read hayamiki_lib/ds_files/ds_messages.anubis | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +global define One | ||
| 17 | + hayamiki_lib_ds | ||
| 18 | + ( | ||
| 19 | + List(String) args | ||
| 20 | + ) = | ||
| 21 | + if load_ds_generator is | ||
| 22 | + { | ||
| 23 | + failure then println("Densaku generator can't be load"), | ||
| 24 | + success(ds_gen) then forget(ds_gen.generate_type_files(hayamiki_lib_types_description, [], "ds_files/")) | ||
| 25 | + }. | ||
| 26 | + | ||
| 27 | +execute anbexec hayamiki_lib_ds // generate the file |
| 1 | +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 2 | + <PropertyGroup> | ||
| 3 | + <ProjectGuid>{06BE5572-9B4A-4F41-A01E-84C730A8F4E4}</ProjectGuid> | ||
| 4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| 5 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
| 6 | + <OutputType>Exe</OutputType> | ||
| 7 | + <RootNamespace>hayamiki_ds_types</RootNamespace> | ||
| 8 | + <AssemblyName>hayamiki_ds_types</AssemblyName> | ||
| 9 | + <StartupObject>hayamiki_ds_types.anubis</StartupObject> | ||
| 10 | + <IncludePaths>./</IncludePaths> | ||
| 11 | + </PropertyGroup> | ||
| 12 | + <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
| 13 | + <OutputPath>bin\Debug\</OutputPath> | ||
| 14 | + <DebugSymbols>True</DebugSymbols> | ||
| 15 | + <DebugType>Full</DebugType> | ||
| 16 | + <Optimize>False</Optimize> | ||
| 17 | + </PropertyGroup> | ||
| 18 | + <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
| 19 | + <OutputPath>bin\Release\</OutputPath> | ||
| 20 | + <DebugSymbols>False</DebugSymbols> | ||
| 21 | + <DebugType>None</DebugType> | ||
| 22 | + <Optimize>True</Optimize> | ||
| 23 | + </PropertyGroup> | ||
| 24 | + <Import Project="$(AnubisBinPath)\Anubis.Build.targets" /> | ||
| 25 | + <ItemGroup> | ||
| 26 | + <Compile Include="hayamiki_ds_types.anubis" /> | ||
| 27 | + <Compile Include="hayamiki_lib\controller\hk_controller.anubis" /> | ||
| 28 | + <Compile Include="hayamiki_lib\controller\hk_delete.anubis" /> | ||
| 29 | + <Compile Include="hayamiki_lib\ds_files\ds_types.anubis" /> | ||
| 30 | + <Compile Include="hayamiki_lib\hk_generator.anubis" /> | ||
| 31 | + <Compile Include="hayamiki_lib\model\app.anubis" /> | ||
| 32 | + <Compile Include="hayamiki_lib\model\columns.anubis" /> | ||
| 33 | + <Compile Include="hayamiki_lib\model\database.anubis" /> | ||
| 34 | + <Compile Include="hayamiki_lib\model\display.anubis" /> | ||
| 35 | + <Compile Include="hayamiki_lib\model\fields.anubis" /> | ||
| 36 | + <Compile Include="hayamiki_lib\model\help.anubis" /> | ||
| 37 | + <Compile Include="hayamiki_lib\model\icons.anubis" /> | ||
| 38 | + <Compile Include="hayamiki_lib\model\model.anubis" /> | ||
| 39 | + <Compile Include="hayamiki_lib\model\tables.anubis" /> | ||
| 40 | + <Compile Include="hayamiki_lib\model\types\hk_app.anubis" /> | ||
| 41 | + <Compile Include="hayamiki_lib\model\types\hk_app_name.anubis" /> | ||
| 42 | + <Compile Include="hayamiki_lib\model\types\hk_database.anubis" /> | ||
| 43 | + <Compile Include="hayamiki_lib\model\types\hk_datetime_field_attr.anubis" /> | ||
| 44 | + <Compile Include="hayamiki_lib\model\types\hk_display.anubis" /> | ||
| 45 | + <Compile Include="hayamiki_lib\model\types\hk_edit_view.anubis" /> | ||
| 46 | + <Compile Include="hayamiki_lib\model\types\hk_help_text.anubis" /> | ||
| 47 | + <Compile Include="hayamiki_lib\model\types\hk_icon.anubis" /> | ||
| 48 | + <Compile Include="hayamiki_lib\model\types\hk_int_choice.anubis" /> | ||
| 49 | + <Compile Include="hayamiki_lib\model\types\hk_int_choices.anubis" /> | ||
| 50 | + <Compile Include="hayamiki_lib\model\types\hk_list_view.anubis" /> | ||
| 51 | + <Compile Include="hayamiki_lib\model\types\hk_model.anubis" /> | ||
| 52 | + <Compile Include="hayamiki_lib\model\types\hk_model_attr.anubis" /> | ||
| 53 | + <Compile Include="hayamiki_lib\model\types\hk_model_column.anubis" /> | ||
| 54 | + <Compile Include="hayamiki_lib\model\types\hk_model_field.anubis" /> | ||
| 55 | + <Compile Include="hayamiki_lib\model\types\hk_table.anubis" /> | ||
| 56 | + <Compile Include="hayamiki_lib\model\types\hk_text_choice.anubis" /> | ||
| 57 | + <Compile Include="hayamiki_lib\model\types\hk_text_choices.anubis" /> | ||
| 58 | + <Compile Include="hayamiki_lib\model\types\hk_text_field_attr.anubis" /> | ||
| 59 | + <Compile Include="hayamiki_lib\types\hayamiki.anubis" /> | ||
| 60 | + <Compile Include="hayamiki_lib\view\view_apps_renderer.anubis" /> | ||
| 61 | + <Compile Include="hayamiki_lib\view\view_table_manager.anubis" /> | ||
| 62 | + <Compile Include="hayamiki_lib\view\view_table_manager_types.anubis" /> | ||
| 63 | + <Compile Include="hayamiki_lib\view\view_table_renderer.anubis" /> | ||
| 64 | + <Compile Include="hayamiki_lib\view\view_table_types.anubis" /> | ||
| 65 | + <Compile Include="hayamiki_lib\view\web_action.anubis" /> | ||
| 66 | + </ItemGroup> | ||
| 67 | + <ItemGroup> | ||
| 68 | + <Folder Include="hayamiki_lib" /> | ||
| 69 | + <Folder Include="hayamiki_lib\controller" /> | ||
| 70 | + <Folder Include="hayamiki_lib\ds_files" /> | ||
| 71 | + <Folder Include="hayamiki_lib\model" /> | ||
| 72 | + <Folder Include="hayamiki_lib\model\types" /> | ||
| 73 | + <Folder Include="hayamiki_lib\types" /> | ||
| 74 | + <Folder Include="hayamiki_lib\view" /> | ||
| 75 | + </ItemGroup> | ||
| 76 | +</Project> | ||
| 0 | \ No newline at end of file | 77 | \ No newline at end of file |
hayamiki_generator.aproj
| @@ -123,6 +123,7 @@ | @@ -123,6 +123,7 @@ | ||
| 123 | <Compile Include="calexium_lib\web\widgets\icons_set.anubis" /> | 123 | <Compile Include="calexium_lib\web\widgets\icons_set.anubis" /> |
| 124 | <Compile Include="hayamiki_lib\controller\hk_controller.anubis" /> | 124 | <Compile Include="hayamiki_lib\controller\hk_controller.anubis" /> |
| 125 | <Compile Include="hayamiki_lib\controller\hk_delete.anubis" /> | 125 | <Compile Include="hayamiki_lib\controller\hk_delete.anubis" /> |
| 126 | + <Compile Include="hayamiki_lib\ds_files\ds_types.anubis" /> | ||
| 126 | <Compile Include="hayamiki_lib\hk_generator.anubis" /> | 127 | <Compile Include="hayamiki_lib\hk_generator.anubis" /> |
| 127 | <Compile Include="hayamiki_lib\model\app.anubis" /> | 128 | <Compile Include="hayamiki_lib\model\app.anubis" /> |
| 128 | <Compile Include="hayamiki_lib\model\columns.anubis" /> | 129 | <Compile Include="hayamiki_lib\model\columns.anubis" /> |
| @@ -139,6 +140,7 @@ | @@ -139,6 +140,7 @@ | ||
| 139 | <Compile Include="hayamiki_lib\model\types\hk_datetime_field_attr.anubis" /> | 140 | <Compile Include="hayamiki_lib\model\types\hk_datetime_field_attr.anubis" /> |
| 140 | <Compile Include="hayamiki_lib\model\types\hk_display.anubis" /> | 141 | <Compile Include="hayamiki_lib\model\types\hk_display.anubis" /> |
| 141 | <Compile Include="hayamiki_lib\model\types\hk_edit_view.anubis" /> | 142 | <Compile Include="hayamiki_lib\model\types\hk_edit_view.anubis" /> |
| 143 | + <Compile Include="hayamiki_lib\model\types\hk_fk_view.anubis" /> | ||
| 142 | <Compile Include="hayamiki_lib\model\types\hk_help_text.anubis" /> | 144 | <Compile Include="hayamiki_lib\model\types\hk_help_text.anubis" /> |
| 143 | <Compile Include="hayamiki_lib\model\types\hk_icon.anubis" /> | 145 | <Compile Include="hayamiki_lib\model\types\hk_icon.anubis" /> |
| 144 | <Compile Include="hayamiki_lib\model\types\hk_int_choice.anubis" /> | 146 | <Compile Include="hayamiki_lib\model\types\hk_int_choice.anubis" /> |
| @@ -162,6 +164,7 @@ | @@ -162,6 +164,7 @@ | ||
| 162 | <Compile Include="hayamiki_lib\types\model\icons.anubis" /> | 164 | <Compile Include="hayamiki_lib\types\model\icons.anubis" /> |
| 163 | <Compile Include="hayamiki_lib\types\model\model.anubis" /> | 165 | <Compile Include="hayamiki_lib\types\model\model.anubis" /> |
| 164 | <Compile Include="hayamiki_lib\types\model\tables.anubis" /> | 166 | <Compile Include="hayamiki_lib\types\model\tables.anubis" /> |
| 167 | + <Compile Include="hayamiki_lib\view\view_apps_renderer.anubis" /> | ||
| 165 | <Compile Include="hayamiki_lib\view\view_table_manager.anubis" /> | 168 | <Compile Include="hayamiki_lib\view\view_table_manager.anubis" /> |
| 166 | <Compile Include="hayamiki_lib\view\view_table_manager_types.anubis" /> | 169 | <Compile Include="hayamiki_lib\view\view_table_manager_types.anubis" /> |
| 167 | <Compile Include="hayamiki_lib\view\view_table_renderer.anubis" /> | 170 | <Compile Include="hayamiki_lib\view\view_table_renderer.anubis" /> |
| @@ -713,9 +716,9 @@ | @@ -713,9 +716,9 @@ | ||
| 713 | <Folder Include="calexium_lib\web\widgets" /> | 716 | <Folder Include="calexium_lib\web\widgets" /> |
| 714 | <Folder Include="hayamiki_lib" /> | 717 | <Folder Include="hayamiki_lib" /> |
| 715 | <Folder Include="hayamiki_lib\controller" /> | 718 | <Folder Include="hayamiki_lib\controller" /> |
| 719 | + <Folder Include="hayamiki_lib\ds_files" /> | ||
| 716 | <Folder Include="hayamiki_lib\model" /> | 720 | <Folder Include="hayamiki_lib\model" /> |
| 717 | <Folder Include="hayamiki_lib\model\types" /> | 721 | <Folder Include="hayamiki_lib\model\types" /> |
| 718 | - <Folder Include="hayamiki_lib\model\types\generated" /> | ||
| 719 | <Folder Include="hayamiki_lib\types" /> | 722 | <Folder Include="hayamiki_lib\types" /> |
| 720 | <Folder Include="hayamiki_lib\types\model" /> | 723 | <Folder Include="hayamiki_lib\types\model" /> |
| 721 | <Folder Include="hayamiki_lib\types\view" /> | 724 | <Folder Include="hayamiki_lib\types\view" /> |
hayamiki_lib @ ea1efe8b2ab
src/check.anubis
| @@ -10,6 +10,7 @@ read hayamiki_lib/types/hayamiki.anubis | @@ -10,6 +10,7 @@ read hayamiki_lib/types/hayamiki.anubis | ||
| 10 | read system/string.anubis | 10 | read system/string.anubis |
| 11 | read tools/list.anubis | 11 | read tools/list.anubis |
| 12 | read tools/basis.anubis | 12 | read tools/basis.anubis |
| 13 | +transmit hayamiki_lib/model/types/hk_edit_view.anubis | ||
| 13 | 14 | ||
| 14 | public define Maybe(List(String)) | 15 | public define Maybe(List(String)) |
| 15 | get_all_apps_name | 16 | get_all_apps_name |
| @@ -35,9 +36,9 @@ public define Maybe(List(String)) | @@ -35,9 +36,9 @@ public define Maybe(List(String)) | ||
| 35 | define Maybe(HK_Model_Column) | 36 | define Maybe(HK_Model_Column) |
| 36 | resolve_foreign | 37 | resolve_foreign |
| 37 | ( | 38 | ( |
| 38 | - List(String) apps_name, | ||
| 39 | - String current_app_name, | ||
| 40 | - String table_name, | 39 | + List(String) apps_name, //list of all knows application |
| 40 | + String current_app_name, | ||
| 41 | + String table_name, //current table name | ||
| 41 | HK_Model_Column col | 42 | HK_Model_Column col |
| 42 | )= | 43 | )= |
| 43 | since col is hk_column(name, type, attrib, help), | 44 | since col is hk_column(name, type, attrib, help), |
| @@ -81,6 +82,72 @@ define Maybe(List(HK_Model_Column)) | @@ -81,6 +82,72 @@ define Maybe(List(HK_Model_Column)) | ||
| 81 | success(col) then resolve_foreign(apps_name, app_name, table_name, t, [col. so_far]) | 82 | success(col) then resolve_foreign(apps_name, app_name, table_name, t, [col. so_far]) |
| 82 | } | 83 | } |
| 83 | }. | 84 | }. |
| 85 | + | ||
| 86 | +define Maybe(HK_FK_View) | ||
| 87 | + resolve_HK_FK_View_foreign | ||
| 88 | + ( | ||
| 89 | + List(String) apps_name, //list of all knows application | ||
| 90 | + String current_app_name, | ||
| 91 | + HK_FK_View _fk_view | ||
| 92 | + )= | ||
| 93 | + since _fk_view is fk_view(fk_app, fk_table, fk_column), | ||
| 94 | + with mb_fk_app = if (fk_app) is | ||
| 95 | + { | ||
| 96 | + this then println("this found replaced by "+current_app_name+" in app '"+current_app_name+"' table '"+fk_table+"' column '"+fk_column+"'"); | ||
| 97 | + success(current_app_name), | ||
| 98 | + app_name(_name) then | ||
| 99 | + if _name:apps_name then | ||
| 100 | + success(_name) | ||
| 101 | + else | ||
| 102 | + println("foreign key app '"+_name+"' doesn't exists in app '"+current_app_name+"' table '"+fk_table+"' column '"+fk_column+"'");failure, | ||
| 103 | + none then | ||
| 104 | + success("") | ||
| 105 | + }, | ||
| 106 | + if mb_fk_app is | ||
| 107 | + { | ||
| 108 | + failure then failure, | ||
| 109 | + success(n_fk_app) then success(fk_view(fk_app, (if length(n_fk_app)>0 then n_fk_app+"_"else "")+fk_table, fk_column)) | ||
| 110 | + } | ||
| 111 | +. | ||
| 112 | + | ||
| 113 | +define Maybe(HK_Edit_View) | ||
| 114 | + resolve_HK_Edit_View_foreign | ||
| 115 | + ( | ||
| 116 | + List(String) apps_name, //list of all knows app name | ||
| 117 | + String app_name, //current app name | ||
| 118 | + HK_Edit_View _edit_view | ||
| 119 | + )= | ||
| 120 | + if _edit_view is | ||
| 121 | + { | ||
| 122 | + edit_view_all then success(edit_view_all), | ||
| 123 | + edit_view(v, c, fk_views) then | ||
| 124 | + with mb_fk_views = map_escape((HK_FK_View _fk_view) |-> resolve_HK_FK_View_foreign(apps_name, app_name, _fk_view), fk_views), | ||
| 125 | + if mb_fk_views is | ||
| 126 | + { | ||
| 127 | + failure then failure, | ||
| 128 | + success(n_fk_views) then success(edit_view(v, c, n_fk_views)) | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | +. | ||
| 132 | + | ||
| 133 | +define Maybe(List(HK_Edit_View)) | ||
| 134 | + resolve_foreign | ||
| 135 | + ( | ||
| 136 | + List(String) apps_name, //list of all knows app name | ||
| 137 | + String app_name, //current app name | ||
| 138 | + List(HK_Edit_View) list_edits, //edit view to check | ||
| 139 | + List(HK_Edit_View) so_far //already checked edit view | ||
| 140 | + )= | ||
| 141 | + if list_edits is | ||
| 142 | + { | ||
| 143 | + [] then success(reverse(so_far)), | ||
| 144 | + [h . t] then | ||
| 145 | + if resolve_HK_Edit_View_foreign(apps_name, app_name, h) is | ||
| 146 | + { | ||
| 147 | + failure then failure, | ||
| 148 | + success(edit_view) then resolve_foreign(apps_name, app_name, t, [edit_view. so_far]) | ||
| 149 | + } | ||
| 150 | + }. | ||
| 84 | 151 | ||
| 85 | define Maybe(List(HK_Table)) | 152 | define Maybe(List(HK_Table)) |
| 86 | resolve_foreign | 153 | resolve_foreign |
| @@ -100,7 +167,15 @@ define Maybe(List(HK_Table)) | @@ -100,7 +167,15 @@ define Maybe(List(HK_Table)) | ||
| 100 | if resolve_foreign(apps_name, app_name, table_name, columns, []) is | 167 | if resolve_foreign(apps_name, app_name, table_name, columns, []) is |
| 101 | { | 168 | { |
| 102 | failure then failure, | 169 | failure then failure, |
| 103 | - success(checked_model) then resolve_foreign(apps_name, app_name, t, [hk_table(table_name, name, hk_model(checked_model, display_string), display) . so_far]) | 170 | + success(checked_model) then |
| 171 | + since display is hk_display( list_views, list_edits), | ||
| 172 | + if resolve_foreign(apps_name, app_name, list_edits, []) is | ||
| 173 | + { | ||
| 174 | + failure then failure, | ||
| 175 | + success(checked_list_edits) then | ||
| 176 | + resolve_foreign(apps_name, app_name, t, [hk_table(table_name, name, hk_model(checked_model, display_string), hk_display(list_views, checked_list_edits)) . so_far]) | ||
| 177 | + } | ||
| 178 | + | ||
| 104 | } | 179 | } |
| 105 | }. | 180 | }. |
| 106 | 181 |
src/generation/columns.anubis
| @@ -13,6 +13,36 @@ read hayamiki_lib/model/fields.anubis | @@ -13,6 +13,36 @@ read hayamiki_lib/model/fields.anubis | ||
| 13 | 13 | ||
| 14 | read fields.anubis | 14 | read fields.anubis |
| 15 | 15 | ||
| 16 | +public define Maybe(HK_Model_Column) | ||
| 17 | +/* return the HK_Model_Column corresponding of the given column name | ||
| 18 | + */ | ||
| 19 | + get_column_type_from_name | ||
| 20 | + ( | ||
| 21 | + List(HK_Model_Column) columns, //columns in wich we search | ||
| 22 | + String name_to_find //Column name to find in previous list | ||
| 23 | + )= | ||
| 24 | + if columns is | ||
| 25 | + { | ||
| 26 | + [] then failure, | ||
| 27 | + [h . t] then | ||
| 28 | + since h is hk_column(name, _, _, _), | ||
| 29 | + if name_to_find = name then | ||
| 30 | + success(h) | ||
| 31 | + else | ||
| 32 | + get_column_type_from_name(t, name_to_find) | ||
| 33 | + }. | ||
| 34 | + | ||
| 35 | +public define Maybe(List(HK_Model_Column)) | ||
| 36 | +/* return all columns matching with the list of given list of columns to get | ||
| 37 | + */ | ||
| 38 | + get_HK_Model_Column_list_from_name_list | ||
| 39 | + ( | ||
| 40 | + List(HK_Model_Column) columns, //columns in wich we search | ||
| 41 | + List(String) names_to_find //Column name to find in previous list | ||
| 42 | + )= | ||
| 43 | + map_escape((String column_name) |-> get_column_type_from_name(columns, column_name), names_to_find) | ||
| 44 | +. | ||
| 45 | + | ||
| 16 | define List(String) | 46 | define List(String) |
| 17 | /* return the list of all columns name | 47 | /* return the list of all columns name |
| 18 | */ | 48 | */ |
| @@ -234,7 +264,9 @@ public define Maybe(String) | @@ -234,7 +264,9 @@ public define Maybe(String) | ||
| 234 | auto_now then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")"), | 264 | auto_now then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")"), |
| 235 | auto_now_add then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")") | 265 | auto_now_add then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")") |
| 236 | }, | 266 | }, |
| 237 | - foreign_key(app,foreign_table) then success("foreign_text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", vt_edit_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")"), | 267 | + foreign_key(app,foreign_table) then success("foreign_text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", vt_edit_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")"), |
| 268 | + | ||
| 269 | + | ||
| 238 | integer_field(choices) then | 270 | integer_field(choices) then |
| 239 | //success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), | 271 | //success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), |
| 240 | if choices is | 272 | if choices is |
| @@ -292,22 +324,7 @@ public define String | @@ -292,22 +324,7 @@ public define String | ||
| 292 | )= | 324 | )= |
| 293 | indent+join(",\n"+indent, map((String text) |-> "text(\""+to_upper(text)+"\")", list_view)). | 325 | indent+join(",\n"+indent, map((String text) |-> "text(\""+to_upper(text)+"\")", list_view)). |
| 294 | 326 | ||
| 295 | -public define Maybe(HK_Model_Column) | ||
| 296 | - get_column_type_from_name | ||
| 297 | - ( | ||
| 298 | - List(HK_Model_Column) columns, //columns in wich we search | ||
| 299 | - String name_to_find //Column name to find in previous list | ||
| 300 | - )= | ||
| 301 | - if columns is | ||
| 302 | - { | ||
| 303 | - [] then failure, | ||
| 304 | - [h . t] then | ||
| 305 | - since h is hk_column(name, _, _, _), | ||
| 306 | - if name_to_find = name then | ||
| 307 | - success(h) | ||
| 308 | - else | ||
| 309 | - get_column_type_from_name(t, name_to_find) | ||
| 310 | - }. | 327 | + |
| 311 | 328 | ||
| 312 | public define String | 329 | public define String |
| 313 | /** to_String return the content of the given model column 'col' in String format. | 330 | /** to_String return the content of the given model column 'col' in String format. |
src/generation/fields.anubis
| @@ -46,10 +46,8 @@ public define String | @@ -46,10 +46,8 @@ public define String | ||
| 46 | HK_Model_Field t | 46 | HK_Model_Field t |
| 47 | ) = | 47 | ) = |
| 48 | if t is | 48 | if t is |
| 49 | - { | ||
| 50 | - //anubis(_T) then "ByteArray", | 49 | + { |
| 51 | p_key then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", | 50 | p_key then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", |
| 52 | - //binary then "ByteArray", | ||
| 53 | boolean_field then "bool", | 51 | boolean_field then "bool", |
| 54 | date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")", | 52 | date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")", |
| 55 | time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")", | 53 | time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")", |
src/generation/types.anubis
| @@ -497,7 +497,7 @@ public define Maybe(One) | @@ -497,7 +497,7 @@ public define Maybe(One) | ||
| 497 | " )=\n"+ | 497 | " )=\n"+ |
| 498 | " if list is\n"+ | 498 | " if list is\n"+ |
| 499 | " {\n"+ | 499 | " {\n"+ |
| 500 | - " [] then\n"+ | 500 | + " [] then //last entry, add the header and the reverse the list \n"+ |
| 501 | " with header = vt_view_row_header([\n"+ | 501 | " with header = vt_view_row_header([\n"+ |
| 502 | // view row header | 502 | // view row header |
| 503 | make_list_view_header(current_list_view, " ")+"\n"+ | 503 | make_list_view_header(current_list_view, " ")+"\n"+ |
src/generation/vt_edit.anubis
| @@ -13,8 +13,23 @@ read system/string.anubis | @@ -13,8 +13,23 @@ read system/string.anubis | ||
| 13 | read fields.anubis | 13 | read fields.anubis |
| 14 | read columns.anubis | 14 | read columns.anubis |
| 15 | read html.anubis | 15 | read html.anubis |
| 16 | - . | ||
| 17 | - | 16 | + |
| 17 | +define String | ||
| 18 | + edit_tab_entries | ||
| 19 | + ( | ||
| 20 | + List(HK_FK_View) fk_views, | ||
| 21 | + String indent | ||
| 22 | + )= | ||
| 23 | + join(",\n", | ||
| 24 | + map((HK_FK_View fk_view) | ||
| 25 | + |-> | ||
| 26 | + since fk_view is fk_view(app_name, table_name, fk_col), | ||
| 27 | + indent+"hk_v_edit_tab(String fk_table_name, "+fk_col+", \"default\")" | ||
| 28 | + , | ||
| 29 | + fk_views) | ||
| 30 | + ) | ||
| 31 | +. | ||
| 32 | + | ||
| 18 | public define Maybe(One) | 33 | public define Maybe(One) |
| 19 | /* Generate | 34 | /* Generate |
| 20 | 35 | ||
| @@ -32,14 +47,25 @@ public define Maybe(One) | @@ -32,14 +47,25 @@ public define Maybe(One) | ||
| 32 | with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. | 47 | with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. |
| 33 | with view_name = if edit_view is | 48 | with view_name = if edit_view is |
| 34 | { | 49 | { |
| 35 | - edit_view_all then "default", | ||
| 36 | - edit_view(view_name, _) then view_name | 50 | + edit_view_all then "default", |
| 51 | + edit_view(view_name, _, _) then view_name | ||
| 37 | }, | 52 | }, |
| 38 | with current_edit_view = if edit_view is | 53 | with current_edit_view = if edit_view is |
| 39 | { | 54 | { |
| 40 | - edit_view_all then to_List_String(columns, false), | ||
| 41 | - edit_view(_, cols) then cols | 55 | + edit_view_all then columns, |
| 56 | + edit_view(view_name, cols, _) then | ||
| 57 | + if get_HK_Model_Column_list_from_name_list(columns, cols) is | ||
| 58 | + { | ||
| 59 | + failure then println("generate_VT_edit: can't get all specified columns for table \""+table_name+"\" view name \""+view_name+"\" cols["+join(", ",cols)+"]");[], | ||
| 60 | + success(got_columns) then got_columns, | ||
| 61 | + } | ||
| 62 | + }, | ||
| 63 | + with current_fk_views = if edit_view is | ||
| 64 | + { | ||
| 65 | + edit_view_all then [], | ||
| 66 | + edit_view(_, _, lfk) then lfk | ||
| 42 | }, | 67 | }, |
| 68 | + | ||
| 43 | //generate the type of the table that contain all components | 69 | //generate the type of the table that contain all components |
| 44 | if write_string(stream, | 70 | if write_string(stream, |
| 45 | "\n\n"+ | 71 | "\n\n"+ |
| @@ -52,9 +78,13 @@ public define Maybe(One) | @@ -52,9 +78,13 @@ public define Maybe(One) | ||
| 52 | " )=\n"+ | 78 | " )=\n"+ |
| 53 | " with edit_entries = (List(VT_edit_entry))\n"+ | 79 | " with edit_entries = (List(VT_edit_entry))\n"+ |
| 54 | " [\n"+ | 80 | " [\n"+ |
| 55 | - edit_entries(columns, table_name, " ", [])+"\n"+ | 81 | + edit_entries(current_edit_view, table_name, " ", [])+"\n"+ |
| 56 | " ],\n"+ | 82 | " ],\n"+ |
| 57 | - " vt_edit(\""+table_name+"\", \""+view_name+"\", edit_entries).\n\n" | 83 | + " with fk_view_entries = (List(HK_V_Edit_Tab))\n"+ |
| 84 | + " [\n"+ | ||
| 85 | + edit_tab_entries(current_fk_views, " ")+"\n"+ | ||
| 86 | + " ],\n"+ | ||
| 87 | + " vt_edit(\""+table_name+"\", \""+view_name+"\", edit_entries, fk_view_entries).\n\n" | ||
| 58 | ) is //end of the function | 88 | ) is //end of the function |
| 59 | { | 89 | { |
| 60 | failure then println("can't write generate_VT_view "+type_name); failure, | 90 | failure then println("can't write generate_VT_view "+type_name); failure, |
| @@ -90,8 +120,8 @@ public define Maybe(One) | @@ -90,8 +120,8 @@ public define Maybe(One) | ||
| 90 | else | 120 | else |
| 91 | if view is | 121 | if view is |
| 92 | { | 122 | { |
| 93 | - edit_view_all then true, //list_view_all is default view | ||
| 94 | - edit_view(view_name, _) then | 123 | + edit_view_all then true, //list_view_all is default view |
| 124 | + edit_view(view_name, _, _) then | ||
| 95 | //if not we search for view named 'default' | 125 | //if not we search for view named 'default' |
| 96 | if view_name = "default" then true else false | 126 | if view_name = "default" then true else false |
| 97 | }, | 127 | }, |
| @@ -118,8 +148,8 @@ public define String | @@ -118,8 +148,8 @@ public define String | ||
| 118 | [view . t] then | 148 | [view . t] then |
| 119 | with view_name = if view is | 149 | with view_name = if view is |
| 120 | { | 150 | { |
| 121 | - edit_view_all then "default", | ||
| 122 | - edit_view(view_name, _) then view_name | 151 | + edit_view_all then "default", |
| 152 | + edit_view(view_name, _, _) then view_name | ||
| 123 | }, | 153 | }, |
| 124 | _generate_get_editable_if_else( table_name, t, | 154 | _generate_get_editable_if_else( table_name, t, |
| 125 | so_far + | 155 | so_far + |
src/model.3.0.0.anubis
| @@ -528,7 +528,7 @@ public define HK_Table production_supplier_table = | @@ -528,7 +528,7 @@ public define HK_Table production_supplier_table = | ||
| 528 | list_view("default", ["company", "phone", "mobile", "email"]) | 528 | list_view("default", ["company", "phone", "mobile", "email"]) |
| 529 | ], | 529 | ], |
| 530 | //list_edit | 530 | //list_edit |
| 531 | - [ edit_view("default", ["company", "supplier_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", | 531 | + [ edit_view("default", ["company", "contact_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", |
| 532 | "siret", "tva_number", "date_created", "last_modified", "comments"])] | 532 | "siret", "tva_number", "date_created", "last_modified", "comments"])] |
| 533 | ) | 533 | ) |
| 534 | ). | 534 | ). |
| @@ -606,7 +606,7 @@ public define HK_Table staff_table = | @@ -606,7 +606,7 @@ public define HK_Table staff_table = | ||
| 606 | 606 | ||
| 607 | ], | 607 | ], |
| 608 | //list_edit | 608 | //list_edit |
| 609 | - [ edit_view("default", ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "date_modified", "comments"])] | 609 | + [ edit_view("default", ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "last_modified", "comments"])] |
| 610 | ) | 610 | ) |
| 611 | ). | 611 | ). |
| 612 | 612 |