diff --git a/calexium_lib b/calexium_lib
index 46219dd..095da71 160000
--- a/calexium_lib
+++ b/calexium_lib
@@ -1 +1 @@
-Subproject commit 46219dd336d63ea47857e197c7beb0a43ad5c4cb
+Subproject commit 095da71b9047328df7dc9476b35d0bc436fc704f
diff --git a/hayamiki.aproj b/hayamiki.aproj
index a673002..cc71370 100644
--- a/hayamiki.aproj
+++ b/hayamiki.aproj
@@ -118,6 +118,8 @@
+
+
@@ -484,6 +486,7 @@
+
@@ -669,6 +672,7 @@
+
diff --git a/hayamiki_lib b/hayamiki_lib
index b0e5ce0..dbebf0f 160000
--- a/hayamiki_lib
+++ b/hayamiki_lib
@@ -1 +1 @@
-Subproject commit b0e5ce0d6103b9179b98d3967fbdc994fcc76265
+Subproject commit dbebf0f2d57294617cf39bb95d4f998b7e2ff01d
diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis
index 1d3e273..6b17ec7 100644
--- a/src/generation/columns.anubis
+++ b/src/generation/columns.anubis
@@ -138,7 +138,7 @@ public define Maybe(String)
},
foreign_key(_,_) then success(name),
integer_field then success(name),
- char_field(Int size) then success(name),
+ char_field(_,_) then success(name),
text_field then success(name)
}.
@@ -225,7 +225,8 @@ public define Maybe(String)
},
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 then success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"),
- char_field(Int size) then success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"),
+ //TODO make choices selection if need
+ char_field(choices,_) then success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"),
text_field then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")")
}.
@@ -294,6 +295,6 @@ public define String
datetime_field(attrs) then "to_String("+current_type_name+"."+name+")"
foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")",
integer_field then "to_String("+current_type_name+"."+name+")",
- char_field(Int size) then current_type_name+"."+name,
+ char_field(_,_) then current_type_name+"."+name,
text_field then current_type_name+"."+name
}.
diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis
index fbf6ac8..0bceb7f 100644
--- a/src/generation/fields.anubis
+++ b/src/generation/fields.anubis
@@ -30,7 +30,7 @@ public define String
datetime_field(_) then "DB_datetime",
foreign_key(_,_) then "Int",
integer_field then "Int",
- char_field(Int size) then "String",
+ char_field(_,_) then "String",
text_field then "String"
}.
@@ -50,7 +50,7 @@ public define String
datetime_field(_) then fill("DATETIME", 15)+format_attributes(attributes),
foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ",
integer_field then fill("INTEGER", 15) +format_attributes(attributes),
- char_field(Int size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes),
+ char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes),
text_field then fill("TEXT", 15) +format_attributes(attributes),
}.
@@ -70,7 +70,7 @@ public define String
datetime_field(_) then "db_datetime(\"\")",
foreign_key(_,_) then "(Int)0",
integer_field then "(Int)0",
- char_field(Int size) then "\"\"",
+ char_field(choices,size) then "\"\"",
text_field then "\"\""
}.
@@ -91,7 +91,7 @@ public define String
datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, \""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,",
foreign_key(_,_) then "get_Int(lwa, \""+name+"\")",
integer_field then "get_Int(lwa, \""+name+"\")",
- char_field(Int size) then "get_String(lwa, \""+name+"\")",
+ char_field(_,_) then "get_String(lwa, \""+name+"\")",
text_field then "get_String(lwa, \""+name+"\")"
}.
@@ -112,7 +112,7 @@ public define String
datetime_field(_) then "db_datetime(text"+cursor_index+")",
foreign_key(_,_) then "(Int)db_integer"+cursor_index,
integer_field then "(Int)db_integer"+cursor_index,
- char_field(Int size) then "text"+cursor_index,
+ char_field(_,_) then "text"+cursor_index,
text_field then "text"+cursor_index
}.
@@ -144,6 +144,6 @@ public define String
},
foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")",
integer_field then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")",
- char_field(Int size) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
+ char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
text_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")"
}.
diff --git a/src/generation/files.anubis b/src/generation/files.anubis
index da1e505..da2409e 100644
--- a/src/generation/files.anubis
+++ b/src/generation/files.anubis
@@ -19,6 +19,7 @@ read generation/header.anubis
read generation/types.anubis
read generation/create_table.anubis
read generation/menu.anubis
+read generation/fn_delete.anubis
read check.anubis
define Maybe(One)
@@ -53,11 +54,12 @@ define Maybe(One)
if generate_get_all(strm, table) is { failure then failure, success(_) then
if generate_get_one(strm, table) is { failure then failure, success(_) then
if generate_update(strm, table) is { failure then failure, success(_) then
+ if generate_delete(strm, table) is { failure then failure, success(_) then
if generate_show_string(strm, table) is { failure then failure, success(_) then
if generate_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
- success(unique)}}}}}}}}}}}}
+ success(unique)}}}}}}}}}}}}}
}.
define One
@@ -97,6 +99,7 @@ define Maybe(One)
List(String) view,
List(String) edit,
List(String) writer,
+ List(String) delete,
String dest_dir
)=
with file_name = dest_dir+"database/generated/vtm.anubis",
@@ -126,6 +129,10 @@ join("\n", transmit)+"\n\n"+
"public define List(TM_writer)\n"+
" generated_tm_writer_list =\n"+
" [\n "+join(",\n ",writer)+"\n"+
+" ].\n\n"+
+"public define List(TM_delete)\n"+
+" generated_tm_delete_list =\n"+
+" [\n "+join(",\n ",delete)+"\n"+
" ].\n\n"
) is //end of the function
{
@@ -144,6 +151,7 @@ define One
List(String) so_far_view,
List(String) so_far_edit,
List(String) so_far_writer,
+ List(String) so_far_delete,
String dest_dir
)=
if tables is
@@ -151,9 +159,9 @@ define One
[] then
if apps is
{
- [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer, dest_dir));println("Generation finished"),
+ [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer, so_far_delete, dest_dir));println("Generation finished"),
[app . apps_t] then
- _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer, dest_dir)
+ _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer, so_far_delete, dest_dir)
},
@@ -163,8 +171,8 @@ define One
with view = "vtm_view(\""+name+"\", get_viewable_"+name+")",
with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")",
with writer = "tm_writer(\""+name+"\", update_"+name+")",
-
- _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer], dest_dir)
+ with delete = "tm_delete(\""+name+"\", delete_"+name+")",
+ _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer], [delete . so_far_delete], dest_dir)
}.
define One
@@ -174,7 +182,7 @@ define One
String dest_dir
)
=
- _make_vtm(apps, [], [], [], [], [], dest_dir).
+ _make_vtm(apps, [], [], [], [], [], [], dest_dir).
define Maybe(One)
diff --git a/src/generation/fn_delete.anubis b/src/generation/fn_delete.anubis
new file mode 100644
index 0000000..26cc94d
--- /dev/null
+++ b/src/generation/fn_delete.anubis
@@ -0,0 +1,65 @@
+/*
+ * Created by PyramIDE.
+ * User: フランスのトトロ aka (David RENÉ)
+ * Date: 19/03/2016
+ * Time: 17:27
+ * © 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_delete
+ (
+ Stream stream,
+ HK_Table table
+ )=
+ since table is hk_table(name, short_name, model, _),
+ since model is hk_model( columns, _),
+ with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
+
+ //generate the type of the table that contain all components
+ if write_string(stream,
+ "\n\n"+
+ //SQL query
+ "read tools/int.anubis\n\n"+
+ "public define Maybe(One)\n"+
+ " delete_"+name+"\n"+
+ " (\n"+
+ " SQLite3DataBase db,\n"+
+ " List(Int) ids\n"+
+ " )=\n"+
+ //DELETE SQL query
+ " if sql_query_timeout(db,\n"+
+ " \"DELETE FROM "+name+"\n"+
+ " WHERE id IN (\"+join(\", \", to_List_String(ids))+\");\",\n"+
+ " [],\n"+
+ " \"delete_"+name+"\") is\n"+
+ " {\n"+
+ " error(_) then failure,\n"+
+ " ok(_, _, _) then success(unique)\n"+
+ " }.\n\n"
+// +
+// "public define Maybe(One)\n"+
+// " delete_"+name+"\n"+
+// " (\n"+
+// " SQLite3DataBase db,\n"+
+// " List(Web_arg) lwa\n"+
+// " )=\n"+
+// " if extract_ids_from_web_arg(lwa) is\n"+
+// " {\n"+
+// " failure then failure,\n"+
+// " success(ids) then success(delete_"+name+"(db, ids))\n"+
+// " }.\n\n"
+
+ ) is //end of the function
+ {
+ failure then println("can't write generate_update "+type_name); failure,
+ success(_) then success(unique)
+ }.
diff --git a/src/generation/html.anubis b/src/generation/html.anubis
index e98981a..231950e 100644
--- a/src/generation/html.anubis
+++ b/src/generation/html.anubis
@@ -78,7 +78,7 @@ public define String
datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
foreign_key(app,foreign_table) then to_HTML_cell_text(column, data_name, general_type_name),
integer_field then to_HTML_cell_text(column, data_name, general_type_name),
- char_field(Int size) then to_HTML_cell_text(column, data_name, general_type_name),
+ char_field(choices,size) then to_HTML_cell_text(column, data_name, general_type_name),
text_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 53f992c..ce7ca9b 100644
--- a/src/generation/icons.anubis
+++ b/src/generation/icons.anubis
@@ -30,7 +30,7 @@ public define String
datetime_field(attrs) then icn16_clock,
foreign_key(app,foreign_table) then icn16_question,
integer_field then icn16_question,
- char_field(Int size) then icn16_question,
+ char_field(choice, size) then icn16_question,
text_field then icn16_question
}.
--
libgit2 0.21.4