Commit 75b762fec21e444f2966f74ccd85ed3b3fc4c9ad
1 parent
7934e794
add row delete support
begin of support of hk_text_choice
Showing
9 changed files
with
97 additions
and
19 deletions
Show diff stats
calexium_lib @ 095da71b904
hayamiki.aproj
| ... | ... | @@ -118,6 +118,8 @@ |
| 118 | 118 | <Compile Include="calexium_lib\web\widgets\dashboard.anubis" /> |
| 119 | 119 | <Compile Include="calexium_lib\web\widgets\fisheye_menu.anubis" /> |
| 120 | 120 | <Compile Include="calexium_lib\web\widgets\icons_set.anubis" /> |
| 121 | + <Compile Include="hayamiki_lib\controller\hk_controller.anubis" /> | |
| 122 | + <Compile Include="hayamiki_lib\controller\hk_delete.anubis" /> | |
| 121 | 123 | <Compile Include="hayamiki_lib\hk_generator.anubis" /> |
| 122 | 124 | <Compile Include="hayamiki_lib\types\hayamiki.anubis" /> |
| 123 | 125 | <Compile Include="hayamiki_lib\types\model\app.anubis" /> |
| ... | ... | @@ -484,6 +486,7 @@ |
| 484 | 486 | <Compile Include="src\generation\create_table.anubis" /> |
| 485 | 487 | <Compile Include="src\generation\fields.anubis" /> |
| 486 | 488 | <Compile Include="src\generation\files.anubis" /> |
| 489 | + <Compile Include="src\generation\fn_delete.anubis" /> | |
| 487 | 490 | <Compile Include="src\generation\header.anubis" /> |
| 488 | 491 | <Compile Include="src\generation\html.anubis" /> |
| 489 | 492 | <Compile Include="src\generation\icons.anubis" /> |
| ... | ... | @@ -669,6 +672,7 @@ |
| 669 | 672 | <Folder Include="calexium_lib\web\js" /> |
| 670 | 673 | <Folder Include="calexium_lib\web\widgets" /> |
| 671 | 674 | <Folder Include="hayamiki_lib" /> |
| 675 | + <Folder Include="hayamiki_lib\controller" /> | |
| 672 | 676 | <Folder Include="hayamiki_lib\types" /> |
| 673 | 677 | <Folder Include="hayamiki_lib\types\model" /> |
| 674 | 678 | <Folder Include="hayamiki_lib\types\controler" /> | ... | ... |
hayamiki_lib @ dbebf0f2d57
src/generation/columns.anubis
| ... | ... | @@ -138,7 +138,7 @@ public define Maybe(String) |
| 138 | 138 | }, |
| 139 | 139 | foreign_key(_,_) then success(name), |
| 140 | 140 | integer_field then success(name), |
| 141 | - char_field(Int size) then success(name), | |
| 141 | + char_field(_,_) then success(name), | |
| 142 | 142 | text_field then success(name) |
| 143 | 143 | }. |
| 144 | 144 | |
| ... | ... | @@ -225,7 +225,8 @@ public define Maybe(String) |
| 225 | 225 | }, |
| 226 | 226 | 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)+")"), |
| 227 | 227 | integer_field then success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), |
| 228 | - char_field(Int size) then success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), | |
| 228 | + //TODO make choices selection if need | |
| 229 | + char_field(choices,_) then success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), | |
| 229 | 230 | text_field then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") |
| 230 | 231 | }. |
| 231 | 232 | |
| ... | ... | @@ -294,6 +295,6 @@ public define String |
| 294 | 295 | datetime_field(attrs) then "to_String("+current_type_name+"."+name+")" |
| 295 | 296 | foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", |
| 296 | 297 | integer_field then "to_String("+current_type_name+"."+name+")", |
| 297 | - char_field(Int size) then current_type_name+"."+name, | |
| 298 | + char_field(_,_) then current_type_name+"."+name, | |
| 298 | 299 | text_field then current_type_name+"."+name |
| 299 | 300 | }. | ... | ... |
src/generation/fields.anubis
| ... | ... | @@ -30,7 +30,7 @@ public define String |
| 30 | 30 | datetime_field(_) then "DB_datetime", |
| 31 | 31 | foreign_key(_,_) then "Int", |
| 32 | 32 | integer_field then "Int", |
| 33 | - char_field(Int size) then "String", | |
| 33 | + char_field(_,_) then "String", | |
| 34 | 34 | text_field then "String" |
| 35 | 35 | }. |
| 36 | 36 | |
| ... | ... | @@ -50,7 +50,7 @@ public define String |
| 50 | 50 | datetime_field(_) then fill("DATETIME", 15)+format_attributes(attributes), |
| 51 | 51 | foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ", |
| 52 | 52 | integer_field then fill("INTEGER", 15) +format_attributes(attributes), |
| 53 | - char_field(Int size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), | |
| 53 | + char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), | |
| 54 | 54 | text_field then fill("TEXT", 15) +format_attributes(attributes), |
| 55 | 55 | }. |
| 56 | 56 | |
| ... | ... | @@ -70,7 +70,7 @@ public define String |
| 70 | 70 | datetime_field(_) then "db_datetime(\"\")", |
| 71 | 71 | foreign_key(_,_) then "(Int)0", |
| 72 | 72 | integer_field then "(Int)0", |
| 73 | - char_field(Int size) then "\"\"", | |
| 73 | + char_field(choices,size) then "\"\"", | |
| 74 | 74 | text_field then "\"\"" |
| 75 | 75 | }. |
| 76 | 76 | |
| ... | ... | @@ -91,7 +91,7 @@ public define String |
| 91 | 91 | datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, \""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", |
| 92 | 92 | foreign_key(_,_) then "get_Int(lwa, \""+name+"\")", |
| 93 | 93 | integer_field then "get_Int(lwa, \""+name+"\")", |
| 94 | - char_field(Int size) then "get_String(lwa, \""+name+"\")", | |
| 94 | + char_field(_,_) then "get_String(lwa, \""+name+"\")", | |
| 95 | 95 | text_field then "get_String(lwa, \""+name+"\")" |
| 96 | 96 | }. |
| 97 | 97 | |
| ... | ... | @@ -112,7 +112,7 @@ public define String |
| 112 | 112 | datetime_field(_) then "db_datetime(text"+cursor_index+")", |
| 113 | 113 | foreign_key(_,_) then "(Int)db_integer"+cursor_index, |
| 114 | 114 | integer_field then "(Int)db_integer"+cursor_index, |
| 115 | - char_field(Int size) then "text"+cursor_index, | |
| 115 | + char_field(_,_) then "text"+cursor_index, | |
| 116 | 116 | text_field then "text"+cursor_index |
| 117 | 117 | }. |
| 118 | 118 | |
| ... | ... | @@ -144,6 +144,6 @@ public define String |
| 144 | 144 | }, |
| 145 | 145 | foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", |
| 146 | 146 | integer_field then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", |
| 147 | - char_field(Int size) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | |
| 147 | + char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | |
| 148 | 148 | text_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" |
| 149 | 149 | }. | ... | ... |
src/generation/files.anubis
| ... | ... | @@ -19,6 +19,7 @@ read generation/header.anubis |
| 19 | 19 | read generation/types.anubis |
| 20 | 20 | read generation/create_table.anubis |
| 21 | 21 | read generation/menu.anubis |
| 22 | +read generation/fn_delete.anubis | |
| 22 | 23 | read check.anubis |
| 23 | 24 | |
| 24 | 25 | define Maybe(One) |
| ... | ... | @@ -53,11 +54,12 @@ define Maybe(One) |
| 53 | 54 | if generate_get_all(strm, table) is { failure then failure, success(_) then |
| 54 | 55 | if generate_get_one(strm, table) is { failure then failure, success(_) then |
| 55 | 56 | if generate_update(strm, table) is { failure then failure, success(_) then |
| 57 | + if generate_delete(strm, table) is { failure then failure, success(_) then | |
| 56 | 58 | if generate_show_string(strm, table) is { failure then failure, success(_) then |
| 57 | 59 | if generate_selector(strm, table) is { failure then failure, success(_) then |
| 58 | 60 | if generate_VT_all_view(strm, table) is { failure then failure, success(_) then |
| 59 | 61 | if generate_VT_edit(strm, table) is { failure then failure, success(_) then |
| 60 | - success(unique)}}}}}}}}}}}} | |
| 62 | + success(unique)}}}}}}}}}}}}} | |
| 61 | 63 | }. |
| 62 | 64 | |
| 63 | 65 | define One |
| ... | ... | @@ -97,6 +99,7 @@ define Maybe(One) |
| 97 | 99 | List(String) view, |
| 98 | 100 | List(String) edit, |
| 99 | 101 | List(String) writer, |
| 102 | + List(String) delete, | |
| 100 | 103 | String dest_dir |
| 101 | 104 | )= |
| 102 | 105 | with file_name = dest_dir+"database/generated/vtm.anubis", |
| ... | ... | @@ -126,6 +129,10 @@ join("\n", transmit)+"\n\n"+ |
| 126 | 129 | "public define List(TM_writer)\n"+ |
| 127 | 130 | " generated_tm_writer_list =\n"+ |
| 128 | 131 | " [\n "+join(",\n ",writer)+"\n"+ |
| 132 | +" ].\n\n"+ | |
| 133 | +"public define List(TM_delete)\n"+ | |
| 134 | +" generated_tm_delete_list =\n"+ | |
| 135 | +" [\n "+join(",\n ",delete)+"\n"+ | |
| 129 | 136 | " ].\n\n" |
| 130 | 137 | ) is //end of the function |
| 131 | 138 | { |
| ... | ... | @@ -144,6 +151,7 @@ define One |
| 144 | 151 | List(String) so_far_view, |
| 145 | 152 | List(String) so_far_edit, |
| 146 | 153 | List(String) so_far_writer, |
| 154 | + List(String) so_far_delete, | |
| 147 | 155 | String dest_dir |
| 148 | 156 | )= |
| 149 | 157 | if tables is |
| ... | ... | @@ -151,9 +159,9 @@ define One |
| 151 | 159 | [] then |
| 152 | 160 | if apps is |
| 153 | 161 | { |
| 154 | - [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer, dest_dir));println("Generation finished"), | |
| 162 | + [] 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"), | |
| 155 | 163 | [app . apps_t] then |
| 156 | - _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer, dest_dir) | |
| 164 | + _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer, so_far_delete, dest_dir) | |
| 157 | 165 | |
| 158 | 166 | }, |
| 159 | 167 | |
| ... | ... | @@ -163,8 +171,8 @@ define One |
| 163 | 171 | with view = "vtm_view(\""+name+"\", get_viewable_"+name+")", |
| 164 | 172 | with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")", |
| 165 | 173 | with writer = "tm_writer(\""+name+"\", update_"+name+")", |
| 166 | - | |
| 167 | - _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer], dest_dir) | |
| 174 | + with delete = "tm_delete(\""+name+"\", delete_"+name+")", | |
| 175 | + _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) | |
| 168 | 176 | }. |
| 169 | 177 | |
| 170 | 178 | define One |
| ... | ... | @@ -174,7 +182,7 @@ define One |
| 174 | 182 | String dest_dir |
| 175 | 183 | ) |
| 176 | 184 | = |
| 177 | - _make_vtm(apps, [], [], [], [], [], dest_dir). | |
| 185 | + _make_vtm(apps, [], [], [], [], [], [], dest_dir). | |
| 178 | 186 | |
| 179 | 187 | |
| 180 | 188 | define Maybe(One) | ... | ... |
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 19/03/2016 | |
| 5 | + * Time: 17:27 | |
| 6 | + * © Calexium | |
| 7 | + */ | |
| 8 | + | |
| 9 | +read hayamiki_lib/types/hayamiki.anubis | |
| 10 | +read tools/basis.anubis | |
| 11 | +read tools/streams.anubis | |
| 12 | +read system/string.anubis | |
| 13 | +read fields.anubis | |
| 14 | +read columns.anubis | |
| 15 | +read html.anubis | |
| 16 | + | |
| 17 | +public define Maybe(One) | |
| 18 | + generate_delete | |
| 19 | + ( | |
| 20 | + Stream stream, | |
| 21 | + HK_Table table | |
| 22 | + )= | |
| 23 | + since table is hk_table(name, short_name, model, _), | |
| 24 | + since model is hk_model( columns, _), | |
| 25 | + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 26 | + | |
| 27 | + //generate the type of the table that contain all components | |
| 28 | + if write_string(stream, | |
| 29 | + "\n\n"+ | |
| 30 | + //SQL query | |
| 31 | + "read tools/int.anubis\n\n"+ | |
| 32 | + "public define Maybe(One)\n"+ | |
| 33 | + " delete_"+name+"\n"+ | |
| 34 | + " (\n"+ | |
| 35 | + " SQLite3DataBase db,\n"+ | |
| 36 | + " List(Int) ids\n"+ | |
| 37 | + " )=\n"+ | |
| 38 | + //DELETE SQL query | |
| 39 | + " if sql_query_timeout(db,\n"+ | |
| 40 | + " \"DELETE FROM "+name+"\n"+ | |
| 41 | + " WHERE id IN (\"+join(\", \", to_List_String(ids))+\");\",\n"+ | |
| 42 | + " [],\n"+ | |
| 43 | + " \"delete_"+name+"\") is\n"+ | |
| 44 | + " {\n"+ | |
| 45 | + " error(_) then failure,\n"+ | |
| 46 | + " ok(_, _, _) then success(unique)\n"+ | |
| 47 | + " }.\n\n" | |
| 48 | +// + | |
| 49 | +// "public define Maybe(One)\n"+ | |
| 50 | +// " delete_"+name+"\n"+ | |
| 51 | +// " (\n"+ | |
| 52 | +// " SQLite3DataBase db,\n"+ | |
| 53 | +// " List(Web_arg) lwa\n"+ | |
| 54 | +// " )=\n"+ | |
| 55 | +// " if extract_ids_from_web_arg(lwa) is\n"+ | |
| 56 | +// " {\n"+ | |
| 57 | +// " failure then failure,\n"+ | |
| 58 | +// " success(ids) then success(delete_"+name+"(db, ids))\n"+ | |
| 59 | +// " }.\n\n" | |
| 60 | + | |
| 61 | + ) is //end of the function | |
| 62 | + { | |
| 63 | + failure then println("can't write generate_update "+type_name); failure, | |
| 64 | + success(_) then success(unique) | |
| 65 | + }. | ... | ... |
src/generation/html.anubis
| ... | ... | @@ -78,7 +78,7 @@ public define String |
| 78 | 78 | datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), |
| 79 | 79 | foreign_key(app,foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), |
| 80 | 80 | integer_field then to_HTML_cell_text(column, data_name, general_type_name), |
| 81 | - char_field(Int size) then to_HTML_cell_text(column, data_name, general_type_name), | |
| 81 | + char_field(choices,size) then to_HTML_cell_text(column, data_name, general_type_name), | |
| 82 | 82 | text_field then to_HTML_cell_text(column, data_name, general_type_name), |
| 83 | 83 | } |
| 84 | 84 | }. | ... | ... |
src/generation/icons.anubis
| ... | ... | @@ -30,7 +30,7 @@ public define String |
| 30 | 30 | datetime_field(attrs) then icn16_clock, |
| 31 | 31 | foreign_key(app,foreign_table) then icn16_question, |
| 32 | 32 | integer_field then icn16_question, |
| 33 | - char_field(Int size) then icn16_question, | |
| 33 | + char_field(choice, size) then icn16_question, | |
| 34 | 34 | text_field then icn16_question |
| 35 | 35 | }. |
| 36 | 36 | ... | ... |