diff --git a/calexium_lib b/calexium_lib
index 6c7ef28..64fc7e3 160000
--- a/calexium_lib
+++ b/calexium_lib
@@ -1 +1 @@
-Subproject commit 6c7ef284f883edbff71a79c32632caaab6cc8190
+Subproject commit 64fc7e3c2d3c906e186588d5cf800915903eeb2e
diff --git a/hayamiki.aproj b/hayamiki.aproj
index c41f8dd..1b5e27f 100644
--- a/hayamiki.aproj
+++ b/hayamiki.aproj
@@ -494,6 +494,7 @@
+
diff --git a/hayamiki_lib b/hayamiki_lib
index aa86c5c..291e389 160000
--- a/hayamiki_lib
+++ b/hayamiki_lib
@@ -1 +1 @@
-Subproject commit aa86c5cfded0491eb77ebe770c364d4b90790930
+Subproject commit 291e3895c2e2e9db694cff91e266a4d756fa5b4d
diff --git a/src/generation/files.anubis b/src/generation/files.anubis
index e43e197..2983f20 100644
--- a/src/generation/files.anubis
+++ b/src/generation/files.anubis
@@ -21,6 +21,7 @@ read generation/create_table.anubis
read generation/menu.anubis
read generation/fn_delete.anubis
read generation/choices_selector.anubis
+read generation/vt_edit.anubis
read check.anubis
define Maybe(One)
@@ -60,7 +61,7 @@ define Maybe(One)
if generate_selector(strm, table) is { failure then failure, success(_) then
if generate_choices_selector(strm, table) is { failure then failure, success(_) then
if generate_VT_all_view(strm, table) is { failure then failure, success(_) then
- if generate_VT_edit(strm, table) is { failure then failure, success(_) then
+ if generate_VT_all_edit(strm, table) is { failure then failure, success(_) then
success(unique)}}}}}}}}}}}}}}
}.
diff --git a/src/generation/types.anubis b/src/generation/types.anubis
index c3e1115..26b8061 100644
--- a/src/generation/types.anubis
+++ b/src/generation/types.anubis
@@ -558,7 +558,7 @@ public define Maybe(One)
}.
-public define Maybe(One)
+ public define Maybe(One)
generate_VT_edit
(
Stream stream,
diff --git a/src/generation/vt_edit.anubis b/src/generation/vt_edit.anubis
new file mode 100644
index 0000000..91d6224
--- /dev/null
+++ b/src/generation/vt_edit.anubis
@@ -0,0 +1,185 @@
+/*
+ * Created by PyramIDE.
+ * User: フランスのトトロ aka (David RENÉ)
+ * Date: 28/08/2016
+ * Time: 01:16
+ * © Calexium
+ */
+
+read hayamiki_lib/types/hayamiki.anubis
+read tools/basis.anubis
+read tools/streams.anubis
+read system/string.anubis
+read fields.anubis
+read columns.anubis
+read html.anubis
+ .
+
+public define Maybe(One)
+/* Generate
+
+*/
+ generate_VT_edit
+ (
+ Stream stream, //stream file where to write
+ HK_Table table, //
+ HK_Edit_View edit_view //edit view to generate
+ )=
+ since table is hk_table(table_name, short_name, model, display),
+ since model is hk_model( columns, _),
+ //since display is db_display(list_view, list_edit),
+
+ 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
+ },
+ with current_edit_view = if edit_view is
+ {
+ edit_view_all then to_List_String(columns, false),
+ edit_view(_, cols) then cols
+ },
+ //generate the type of the table that contain all components
+ if write_string(stream,
+ "\n\n"+
+ //SQL query
+ "define VT_edit\n"+
+ " _get_editable_"+table_name+"_"+view_name+"\n"+
+ " (\n"+
+ " "+type_name+" "+table_name+",\n"+
+ " SQLite3DataBase db\n"+
+ " )=\n"+
+ " with edit_entries = (List(VT_edit_entry))\n"+
+ " [\n"+
+ edit_entries(columns, table_name, " ", [])+"\n"+
+ " ],\n"+
+ " vt_edit(\""+table_name+"\", edit_entries).\n\n"
+ ) is //end of the function
+ {
+ failure then println("can't write generate_VT_view "+type_name); failure,
+ success(_) then success(unique)
+ }.
+
+public define Maybe(One)
+/* Generate
+
+*/
+ _generate_VT_edit
+ (
+ Stream stream, //stream file where to write
+ HK_Table table, //
+ List(HK_Edit_View) edit_view, //edit view to generate
+ Bool has_default //set to true if a default view was encountered.
+ )=
+ if edit_view is
+ {
+ [] then
+ //if default view was not generated, we force to generate it
+ if has_default = false then
+ generate_VT_edit(stream, table, edit_view_all)
+ else
+ success(unique),
+ [view . t] then
+ if generate_VT_edit(stream, table, view) is
+ {
+ failure then failure,
+ success(_) then
+ with new_has_default = if has_default = true then //already true, no need to go further
+ true
+ else
+ if view is
+ {
+ 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
+ },
+ _generate_VT_edit(stream, table, t, new_has_default)
+ }
+ }.
+
+public define String
+/* Generate
+
+*/
+ _generate_get_editable_if_else
+ (
+ String table_name, //
+ List(HK_Edit_View) edit_view, //edit view to generate
+ String so_far
+ )=
+ if edit_view is
+ {
+ [] then
+ so_far +
+ "\n"+
+ " _get_editable_"+table_name+"_default("+table_name+", db)\n",
+ [view . t] then
+ with view_name = if view is
+ {
+ edit_view_all then "default",
+ edit_view(view_name, _) then view_name
+ },
+ _generate_get_editable_if_else( table_name, t,
+ so_far +
+ " if editor_view = \""+view_name+"\" then\n"+
+ " _get_editable_"+table_name+"_"+view_name+"("+table_name+", db)\n"+
+ " else"
+ )
+ }.
+
+public define Maybe(One)
+/* Generate the function which get the right editor according to editor name
+
+*/
+ generate_get_viewable
+ (
+ Stream stream, //stream file where to write
+ HK_Table table, //
+ List(HK_Edit_View) edit_view //list view to generate
+ )=
+ since table is hk_table(table_name, short_name, model, display),
+ if write_string(stream,
+ "public define VT_edit\n"+
+ " get_editable_"+table_name+"\n"+
+ " (\n"+
+ " SQLite3DataBase db,\n"+
+ " VT_action action,\n"+
+ " String editor_view\n"+
+ " )=\n"+
+ " with "+table_name+" = if action is\n"+
+ " {\n"+
+ " new_entry then get_default_"+table_name+"\n"+
+ " edit_entry(idx) then\n"+
+ " if get_"+table_name+"(db, idx) is\n"+
+ " {\n"+
+ " failure then get_default_"+table_name+",\n"+
+ " success(data) then data\n"+
+ " }\n"+
+ " },\n"+
+ _generate_get_editable_if_else(table_name, edit_view, "")+
+ ".\n"
+ ) is //end of the function
+ {
+ failure then println("can't write generate_get_editable "+table_name); failure,
+ success(_) then success(unique)
+ }.
+
+public define Maybe(One)
+ generate_VT_all_edit
+ (
+ Stream stream,
+ HK_Table table
+ )=
+ since table is hk_table(name, short_name, model, display),
+ since model is hk_model( columns, _),
+ since display is hk_display(_, 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_edit(stream, table, list_edit, false) is //edit view to generate
+ {
+ failure then failure,
+ success(_) then generate_get_viewable(stream, table, list_edit)
+ }.
+
diff --git a/src/main.anubis b/src/main.anubis
index 99386b9..f51e91e 100644
--- a/src/main.anubis
+++ b/src/main.anubis
@@ -20,7 +20,7 @@ read hayamiki_lib/hk_generator.anubis
read model.3.0.0.anubis
read system/muscle.anubis
- global define One
+global define One
hayamiki
(
List(String) args
@@ -28,7 +28,7 @@ read system/muscle.anubis
if load_hk_generator is
{
failure then println("Hayamiki generator can't be load"),
- success(hk_gen) then forget(hk_gen.generate_model_files(domain_manager_description, ""))
+ success(hk_gen) then forget(hk_gen.generate_model_files(the_database_description, ""))
}.
global define One
diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis
index c525ccd..cf7119b 100644
--- a/src/model.3.0.0.anubis
+++ b/src/model.3.0.0.anubis
@@ -16,7 +16,7 @@ public define HK_Table settings_table =
//list_view
[ list_view_all],
//list edit
- ["var_name", "var_value"]
+ [edit_view_all]
)
).
@@ -41,7 +41,7 @@ public define HK_Table django_admin_log_table =
//list_view
[ list_view_all],
//list edit
- ["action_time", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message"]
+ [ edit_view_all]
)
).
@@ -59,7 +59,7 @@ public define HK_Table production_macaddress_table =
//list_view
[ list_view_all],
//list edit
- ["mac", "index", "mailfountain_id"]
+ [edit_view_all]
)
).
@@ -76,7 +76,7 @@ public define HK_Table production_mass_storage_type_table =
//list_view
[ list_view_all],
//list edit
- ["type"]
+ [edit_view_all]
)
).
@@ -103,7 +103,7 @@ public define HK_Table production_mass_storage_table =
list_view("current",["model_id", "serial", "status", "date_created"])
],
//list_edit
- ["purchase_id", "model_id", "serial", "status", "comments"]
+ [ edit_view("default", ["purchase_id", "model_id", "serial", "status", "comments"])]
)
).
@@ -142,7 +142,7 @@ public define HK_Table production_mass_storage_model_table =
list_view("default", ["manufacturer", "type_id", "capacity", "tr_min", "last_modified", "date_created"])
],
//list_edit
- []
+ [edit_view_all]
)
).
@@ -167,7 +167,7 @@ public define HK_Table production_memory_table =
list_view("default", ["serial", "status", "last_modified", "date_created"])
],
//list_edit
- ["purchase_id", "model_id", "serial", "status", "last_modified", "date_created", "comments"]
+ [edit_view_all]
)
).
@@ -186,7 +186,7 @@ public define HK_Table production_memory_model_table =
//list_view
[ list_view_all],
//list_edit
- ["type_id", "manufacturer", "capacity"]
+ [edit_view_all]
)
).
@@ -203,7 +203,7 @@ public define HK_Table production_memory_type_table =
//list_view
[ list_view_all],
//list edit
- ["type"]
+ [edit_view_all]
)
).
@@ -229,7 +229,7 @@ public define HK_Table production_motherboard_table =
list_view("default", ["serial", "week_fab", "status", "last_modified", "date_created"])
],
//list_edit
- ["purchase_id", "model_id", "serial", "week_fab", "status", "last_modified", "date_created", "comments"]
+ [edit_view_all]
)
).
@@ -255,7 +255,7 @@ public define HK_Table production_motherboard_model_table =
list_view("default", ["name", "manufacturer", "cpu_model", "cpu_freq"])
],
//list_edit
- ["name", "manufacturer", "has_nand", "nand_capacity", "memory", "cpu_freq", "cpu_model", "endian"]
+ [edit_view_all]
)
).
@@ -280,7 +280,7 @@ public define HK_Table production_power_supply_table =
list_view("default", ["serial", "status", "date_created", "last_modified"])
],
//list_edit
- ["purchase_id", "model_id", "serial", "status", "date_created", "last_modified", "comments"]
+ [edit_view_all]
)
).
@@ -301,7 +301,7 @@ public define HK_Table production_power_supply_model_table =
list_view("default", ["name", "manufacturer"])
],
//list_edit
- ["name", "manufacturer", "power"]
+ [edit_view_all]
)
).
@@ -331,8 +331,7 @@ public define HK_Table production_product_reference_table =
list_view("default", ["type_ref_id", "product_ref", "product_name", "description"])
],
//list_edit
- [ "type_ref_id", "product_ref", "product_name", "description", "need_memory", "need_power_supply", "need_additional_storage", "min_additional_storage", "max_additional_storage",
- "date_created", "last_modified", "comments"]
+ [ edit_view_all]
)
).
@@ -368,8 +367,8 @@ public define HK_Table production_products_table =
list_view("default", ["production_id", "date", "serial", "motherboard_id", "app_id", "status"])
],
//list_edit
- [ "production_id", "produced", "date", "serial", "security_code", "motherboard_id", "storage_id", "memory_id", "power_supply_id", "wifi", "mac",
- "app_id", "os_version", "published", "publish_date", "status", "date_created", "last_modified", "comments"]
+ [ edit_view("default", [ "production_id", "produced", "date", "serial", "security_code", "motherboard_id", "storage_id", "memory_id", "power_supply_id", "wifi", "mac",
+ "app_id", "os_version", "published", "publish_date", "status", "date_created", "last_modified", "comments"])]
)
).
@@ -402,8 +401,8 @@ public define HK_Table production_production_table =
list_view("default", ["date", "type_ref_id", "sticker_tpl_id", "product_ref_id", "site_id", "product_count", "produced_count"])
],
//list_edit
- [ "date", "assembler_id", "type_ref_id", "product_ref_id", "site_id", "serial_prefix_id", "sticker_tpl_id", "starting_index", "product_count", "produced_count", "completed",
- "active", "date_created", "last_modified", "comments"]
+ [ edit_view("default", [ "date", "assembler_id", "type_ref_id", "product_ref_id", "site_id", "serial_prefix_id", "sticker_tpl_id", "starting_index", "product_count", "produced_count", "completed",
+ "active", "date_created", "last_modified", "comments"])]
)
).
@@ -428,7 +427,7 @@ public define HK_Table production_production_site_table =
list_view("default", ["ref", "name", "city", "country"])
],
//list_edit
- [ "ref", "name", "city", "country", "next_serial", "date_created", "last_modified", "comments"]
+ [edit_view_all]
)
).
@@ -453,7 +452,7 @@ public define HK_Table production_purchase_table =
list_view("default", ["date", "supplier_id", "description"])
],
//list_edit
- ["date", "buyer_id", "supplier_id", "order_ref", "description", "comments"]
+ [edit_view_all]
)
).
@@ -471,7 +470,7 @@ public define HK_Table production_serial_prefix_table =
//list_view
[list_view_all],
//list_edit
- ["prefix", "next_start"]
+ [edit_view_all]
)
).
@@ -494,7 +493,7 @@ public define HK_Table production_type_number_table =
list_view("default", ["type_ref", "description"])
],
//list_edit
- ["type_ref", "description", "comments"]
+ [ edit_view("default", ["type_ref", "description", "comments"])]
)
).
@@ -529,8 +528,8 @@ public define HK_Table production_supplier_table =
list_view("default", ["company", "phone", "mobile", "email"])
],
//list_edit
- ["company", "supplier_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile",
- "siret", "tva_number", "date_created", "last_modified", "comments"]
+ [ edit_view("default", ["company", "supplier_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile",
+ "siret", "tva_number", "date_created", "last_modified", "comments"])]
)
).
@@ -554,7 +553,7 @@ public define HK_Table department_table =
list_view("default", ["name"])
],
//list_edit
- ["name", "description", "comments"]
+ [ edit_view("default", ["name", "description", "comments"])]
)
).
@@ -577,7 +576,7 @@ public define HK_Table role_table =
list_view("default", ["role_name"])
],
//list_edit
- ["role_name", "description", "comments"]
+ [ edit_view("default", ["role_name", "description", "comments"])]
)
).
@@ -607,7 +606,7 @@ public define HK_Table staff_table =
],
//list_edit
- ["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", "date_modified", "comments"])]
)
).
@@ -644,7 +643,7 @@ public define HK_Table address_book_contact_table =
list_view("details", ["first_name", "last_name", "company", "url", "role", "phone", "mobile", "email", "address1", "address2", "zipcode", "city", "country"])
],
//list_edit
- ["first_name", "last_name", "company", "role", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", "comments"]
+ [ edit_view("default", ["first_name", "last_name", "company", "role", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", "comments"])]
)
).
--
libgit2 0.21.4