diff --git a/hayamiki_ds_types.anubis b/hayamiki_ds_types.anubis
new file mode 100644
index 0000000..7374fbb
--- /dev/null
+++ b/hayamiki_ds_types.anubis
@@ -0,0 +1,27 @@
+/*
+ * Created by PyramIDE.
+ * User: フランスのトトロ aka (David RENÉ)
+ * Date: 14/03/2017
+ * Time: 22:50
+ * © Calexium
+ */
+
+
+read tools/basis.anubis
+read densaku_lib/ds_generator.anubis
+read hayamiki_lib/ds_files/ds_types.anubis
+//read hayamiki_lib/ds_files/ds_messages.anubis
+
+
+global define One
+ hayamiki_lib_ds
+ (
+ List(String) args
+ ) =
+ if load_ds_generator is
+ {
+ failure then println("Densaku generator can't be load"),
+ success(ds_gen) then forget(ds_gen.generate_type_files(hayamiki_lib_types_description, [], "ds_files/"))
+ }.
+
+execute anbexec hayamiki_lib_ds // generate the file
diff --git a/hayamiki_ds_types.aproj b/hayamiki_ds_types.aproj
new file mode 100644
index 0000000..0508f38
--- /dev/null
+++ b/hayamiki_ds_types.aproj
@@ -0,0 +1,76 @@
+
+
+ {06BE5572-9B4A-4F41-A01E-84C730A8F4E4}
+ Debug
+ AnyCPU
+ Exe
+ hayamiki_ds_types
+ hayamiki_ds_types
+ hayamiki_ds_types.anubis
+ ./
+
+
+ bin\Debug\
+ True
+ Full
+ False
+
+
+ bin\Release\
+ False
+ None
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hayamiki_generator.aproj b/hayamiki_generator.aproj
index 9364bc3..7ca345d 100644
--- a/hayamiki_generator.aproj
+++ b/hayamiki_generator.aproj
@@ -123,6 +123,7 @@
+
@@ -139,6 +140,7 @@
+
@@ -162,6 +164,7 @@
+
@@ -713,9 +716,9 @@
+
-
diff --git a/hayamiki_lib b/hayamiki_lib
index 6ad846b..ea1efe8 160000
--- a/hayamiki_lib
+++ b/hayamiki_lib
@@ -1 +1 @@
-Subproject commit 6ad846b4dc7ff3ab41cd33262dfe68e3de9c6952
+Subproject commit ea1efe8b2abb5813464c7399d767aee6c0545475
diff --git a/src/check.anubis b/src/check.anubis
index e81ddd3..ec9180f 100644
--- a/src/check.anubis
+++ b/src/check.anubis
@@ -10,6 +10,7 @@ read hayamiki_lib/types/hayamiki.anubis
read system/string.anubis
read tools/list.anubis
read tools/basis.anubis
+transmit hayamiki_lib/model/types/hk_edit_view.anubis
public define Maybe(List(String))
get_all_apps_name
@@ -35,9 +36,9 @@ public define Maybe(List(String))
define Maybe(HK_Model_Column)
resolve_foreign
(
- List(String) apps_name,
- String current_app_name,
- String table_name,
+ List(String) apps_name, //list of all knows application
+ String current_app_name,
+ String table_name, //current table name
HK_Model_Column col
)=
since col is hk_column(name, type, attrib, help),
@@ -81,6 +82,72 @@ define Maybe(List(HK_Model_Column))
success(col) then resolve_foreign(apps_name, app_name, table_name, t, [col. so_far])
}
}.
+
+define Maybe(HK_FK_View)
+ resolve_HK_FK_View_foreign
+ (
+ List(String) apps_name, //list of all knows application
+ String current_app_name,
+ HK_FK_View _fk_view
+ )=
+ since _fk_view is fk_view(fk_app, fk_table, fk_column),
+ with mb_fk_app = if (fk_app) is
+ {
+ this then println("this found replaced by "+current_app_name+" in app '"+current_app_name+"' table '"+fk_table+"' column '"+fk_column+"'");
+ success(current_app_name),
+ app_name(_name) then
+ if _name:apps_name then
+ success(_name)
+ else
+ println("foreign key app '"+_name+"' doesn't exists in app '"+current_app_name+"' table '"+fk_table+"' column '"+fk_column+"'");failure,
+ none then
+ success("")
+ },
+ if mb_fk_app is
+ {
+ failure then failure,
+ 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))
+ }
+.
+
+define Maybe(HK_Edit_View)
+ resolve_HK_Edit_View_foreign
+ (
+ List(String) apps_name, //list of all knows app name
+ String app_name, //current app name
+ HK_Edit_View _edit_view
+ )=
+ if _edit_view is
+ {
+ edit_view_all then success(edit_view_all),
+ edit_view(v, c, fk_views) then
+ with mb_fk_views = map_escape((HK_FK_View _fk_view) |-> resolve_HK_FK_View_foreign(apps_name, app_name, _fk_view), fk_views),
+ if mb_fk_views is
+ {
+ failure then failure,
+ success(n_fk_views) then success(edit_view(v, c, n_fk_views))
+ }
+ }
+.
+
+define Maybe(List(HK_Edit_View))
+ resolve_foreign
+ (
+ List(String) apps_name, //list of all knows app name
+ String app_name, //current app name
+ List(HK_Edit_View) list_edits, //edit view to check
+ List(HK_Edit_View) so_far //already checked edit view
+ )=
+ if list_edits is
+ {
+ [] then success(reverse(so_far)),
+ [h . t] then
+ if resolve_HK_Edit_View_foreign(apps_name, app_name, h) is
+ {
+ failure then failure,
+ success(edit_view) then resolve_foreign(apps_name, app_name, t, [edit_view. so_far])
+ }
+ }.
define Maybe(List(HK_Table))
resolve_foreign
@@ -100,7 +167,15 @@ define Maybe(List(HK_Table))
if resolve_foreign(apps_name, app_name, table_name, columns, []) is
{
failure then failure,
- 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])
+ success(checked_model) then
+ since display is hk_display( list_views, list_edits),
+ if resolve_foreign(apps_name, app_name, list_edits, []) is
+ {
+ failure then failure,
+ success(checked_list_edits) then
+ 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])
+ }
+
}
}.
diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis
index b14a93d..556c94a 100644
--- a/src/generation/columns.anubis
+++ b/src/generation/columns.anubis
@@ -13,6 +13,36 @@ read hayamiki_lib/model/fields.anubis
read fields.anubis
+public define Maybe(HK_Model_Column)
+/* return the HK_Model_Column corresponding of the given column name
+ */
+ get_column_type_from_name
+ (
+ List(HK_Model_Column) columns, //columns in wich we search
+ String name_to_find //Column name to find in previous list
+ )=
+ if columns is
+ {
+ [] then failure,
+ [h . t] then
+ since h is hk_column(name, _, _, _),
+ if name_to_find = name then
+ success(h)
+ else
+ get_column_type_from_name(t, name_to_find)
+ }.
+
+public define Maybe(List(HK_Model_Column))
+/* return all columns matching with the list of given list of columns to get
+ */
+ get_HK_Model_Column_list_from_name_list
+ (
+ List(HK_Model_Column) columns, //columns in wich we search
+ List(String) names_to_find //Column name to find in previous list
+ )=
+ map_escape((String column_name) |-> get_column_type_from_name(columns, column_name), names_to_find)
+.
+
define List(String)
/* return the list of all columns name
*/
@@ -234,7 +264,9 @@ public define Maybe(String)
auto_now then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")"),
auto_now_add then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")")
},
- 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)+")"),
+ 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)+")"),
+
+
integer_field(choices) then
//success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"),
if choices is
@@ -292,22 +324,7 @@ public define String
)=
indent+join(",\n"+indent, map((String text) |-> "text(\""+to_upper(text)+"\")", list_view)).
-public define Maybe(HK_Model_Column)
- get_column_type_from_name
- (
- List(HK_Model_Column) columns, //columns in wich we search
- String name_to_find //Column name to find in previous list
- )=
- if columns is
- {
- [] then failure,
- [h . t] then
- since h is hk_column(name, _, _, _),
- if name_to_find = name then
- success(h)
- else
- get_column_type_from_name(t, name_to_find)
- }.
+
public define String
/** to_String return the content of the given model column 'col' in String format.
diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis
index 82dea4c..10c1042 100644
--- a/src/generation/fields.anubis
+++ b/src/generation/fields.anubis
@@ -46,10 +46,8 @@ public define String
HK_Model_Field t
) =
if t is
- {
- //anubis(_T) then "ByteArray",
+ {
p_key then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")",
- //binary then "ByteArray",
boolean_field then "bool",
date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")",
time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")",
diff --git a/src/generation/types.anubis b/src/generation/types.anubis
index 3cc7d37..b9a959c 100644
--- a/src/generation/types.anubis
+++ b/src/generation/types.anubis
@@ -497,7 +497,7 @@ public define Maybe(One)
" )=\n"+
" if list is\n"+
" {\n"+
- " [] then\n"+
+ " [] then //last entry, add the header and the reverse the list \n"+
" with header = vt_view_row_header([\n"+
// view row header
make_list_view_header(current_list_view, " ")+"\n"+
diff --git a/src/generation/vt_edit.anubis b/src/generation/vt_edit.anubis
index 8e446ce..2150e1d 100644
--- a/src/generation/vt_edit.anubis
+++ b/src/generation/vt_edit.anubis
@@ -13,8 +13,23 @@ read system/string.anubis
read fields.anubis
read columns.anubis
read html.anubis
- .
-
+
+define String
+ edit_tab_entries
+ (
+ List(HK_FK_View) fk_views,
+ String indent
+ )=
+ join(",\n",
+ map((HK_FK_View fk_view)
+ |->
+ since fk_view is fk_view(app_name, table_name, fk_col),
+ indent+"hk_v_edit_tab(String fk_table_name, "+fk_col+", \"default\")"
+ ,
+ fk_views)
+ )
+.
+
public define Maybe(One)
/* Generate
@@ -32,14 +47,25 @@ public define Maybe(One)
with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
with view_name = if edit_view is
{
- edit_view_all then "default",
- edit_view(view_name, _) then view_name
+ edit_view_all then "default",
+ edit_view(view_name, _, _) then view_name
},
with current_edit_view = if edit_view is
{
- edit_view_all then to_List_String(columns, false),
- edit_view(_, cols) then cols
+ edit_view_all then columns,
+ edit_view(view_name, cols, _) then
+ if get_HK_Model_Column_list_from_name_list(columns, cols) is
+ {
+ failure then println("generate_VT_edit: can't get all specified columns for table \""+table_name+"\" view name \""+view_name+"\" cols["+join(", ",cols)+"]");[],
+ success(got_columns) then got_columns,
+ }
+ },
+ with current_fk_views = if edit_view is
+ {
+ edit_view_all then [],
+ edit_view(_, _, lfk) then lfk
},
+
//generate the type of the table that contain all components
if write_string(stream,
"\n\n"+
@@ -52,9 +78,13 @@ public define Maybe(One)
" )=\n"+
" with edit_entries = (List(VT_edit_entry))\n"+
" [\n"+
- edit_entries(columns, table_name, " ", [])+"\n"+
+ edit_entries(current_edit_view, table_name, " ", [])+"\n"+
" ],\n"+
- " vt_edit(\""+table_name+"\", \""+view_name+"\", edit_entries).\n\n"
+ " with fk_view_entries = (List(HK_V_Edit_Tab))\n"+
+ " [\n"+
+ edit_tab_entries(current_fk_views, " ")+"\n"+
+ " ],\n"+
+ " vt_edit(\""+table_name+"\", \""+view_name+"\", edit_entries, fk_view_entries).\n\n"
) is //end of the function
{
failure then println("can't write generate_VT_view "+type_name); failure,
@@ -90,8 +120,8 @@ public define Maybe(One)
else
if view is
{
- edit_view_all then true, //list_view_all is default view
- edit_view(view_name, _) then
+ edit_view_all then true, //list_view_all is default view
+ edit_view(view_name, _, _) then
//if not we search for view named 'default'
if view_name = "default" then true else false
},
@@ -118,8 +148,8 @@ public define String
[view . t] then
with view_name = if view is
{
- edit_view_all then "default",
- edit_view(view_name, _) then view_name
+ edit_view_all then "default",
+ edit_view(view_name, _, _) then view_name
},
_generate_get_editable_if_else( table_name, t,
so_far +
diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis
index 82cb6f3..c5f6b4c 100644
--- a/src/model.3.0.0.anubis
+++ b/src/model.3.0.0.anubis
@@ -528,7 +528,7 @@ public define HK_Table production_supplier_table =
list_view("default", ["company", "phone", "mobile", "email"])
],
//list_edit
- [ edit_view("default", ["company", "supplier_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile",
+ [ edit_view("default", ["company", "contact_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile",
"siret", "tva_number", "date_created", "last_modified", "comments"])]
)
).
@@ -606,7 +606,7 @@ public define HK_Table staff_table =
],
//list_edit
- [ edit_view("default", ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "date_modified", "comments"])]
+ [ edit_view("default", ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "last_modified", "comments"])]
)
).
--
libgit2 0.21.4