Commit 3db774b081a51e9b15fb208807f52b4b13ab0ff4

Authored by totoro
1 parent 7322a51f

add hk_filter in model description and manage it

hayamiki_generator.aproj
... ... @@ -157,6 +157,7 @@
157 157 <Compile Include="hayamiki_lib\model\types\hk_text_choices.anubis" />
158 158 <Compile Include="hayamiki_lib\model\types\hk_text_field_attr.anubis" />
159 159 <Compile Include="hayamiki_lib\types\hayamiki.anubis" />
  160 + <Compile Include="hayamiki_lib\view\hk_filter.anubis" />
160 161 <Compile Include="hayamiki_lib\view\jqgrid.anubis" />
161 162 <Compile Include="hayamiki_lib\view\view_apps_renderer.anubis" />
162 163 <Compile Include="hayamiki_lib\view\view_table_manager.anubis" />
... ...
hayamiki_lib @ acfe3c6df4d
1   -Subproject commit 5ef0dd2a124781ed0bec0c17b95f4a4d78ec7822
  1 +Subproject commit acfe3c6df4dc48c85e9af860ce25e07099c278fc
... ...
src/generation/SQL_get_all.anubis
... ... @@ -113,13 +113,14 @@ public define Maybe(One)
113 113 "public define JsonMember\n"+
114 114 " get_all_"+name+"_by_clause_to_json\n"+
115 115 " (\n"+
116   -" SQLite3DataBase db,\n"+
117   -" HK_Referer referer,\n"+
118   -" String filter\n"+
  116 +" SQLite3DataBase db,\n"+
  117 +" HK_Referer referer,\n"+
  118 +" String filter,\n"+
  119 +" String order_by\n"+
119 120 " )=\n"+
120   -" with clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n\n"+
121   -" //with _and_ = if length(clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+
122   -" if get_all_"+name+"_by_clause(db, clause+filter) is\n"+
  121 +" with ref_clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n\n"+
  122 +" with _and_ = if length(ref_clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+
  123 +" if get_all_"+name+"_by_clause(db, ref_clause+_and_+filter+\" \"+order_by) is\n"+
123 124 " {\n"+
124 125 " failure then json_member(\"rows\", json_array([])),\n"+
125 126 " success(cursor) then json_member(\"rows\", json_array(_get_all_"+name+"_to_json(db, cursor, [])))\n"+
... ...
src/generation/cxm_lib_menu.anubis
... ... @@ -47,7 +47,7 @@ define String
47 47 since table is hk_table(table_name, short_name, model, display),
48 48 since display is hk_display(list_views, _),
49 49 map((HK_Viewer view ) |->
50   - with view_name = if view is list_view(v_name, _, _) then v_name else "default",
  50 + with view_name = if view is list_view(v_name, _, _, _) then v_name else "default",
51 51 indent+" "+"menu_item("+
52 52 fill("\""+short_name+(if view_name="default" then "" else " "+view_name)+"\",",max_space)+
53 53 //fill("\""+table_name+"\",",max_space)+
... ...
src/generation/header.anubis
... ... @@ -64,6 +64,7 @@ read calexium_lib/database/db_utils.anubis
64 64 read calexium_lib/database/db_types.anubis
65 65 read hayamiki_lib/view/types/hk_form.anubis
66 66 read hayamiki_lib/view/types/hk_view.anubis
  67 +read hayamiki_lib/view/types/hk_filter.anubis
67 68 read hayamiki_lib/types/hayamiki.anubis
68 69 read hayamiki_lib/controller/hk_sql_utils.anubis
69 70 read system/logger.anubis
... ...
src/generation/hk_menu.anubis
... ... @@ -42,7 +42,7 @@ define String
42 42 since table is hk_table(table_name, short_name, model, display),
43 43 since display is hk_display(list_views, _),
44 44 map((HK_Viewer view ) |->
45   - with view_name = if view is list_view(v_name, _, _) then v_name else "default",
  45 + with view_name = if view is list_view(v_name, _, _, _) then v_name else "default",
46 46 indent+" "+"hk_menu_item("+fill("\""+table_name+"\",",max_space)+ "\"view_table\", "+
47 47 fill("help_text(\""+short_name+(if view_name="default" then "" else " "+view_name)+"\"),",max_space)+
48 48 "[(\"table_name\", "+fill("\""+table_name+"\",",max_space)+"),(\"view_name\", \""+view_name+"\")])", list_views), tables))+"\n"+indent+"])", apps)).
... ...
src/generation/html.anubis
... ... @@ -111,9 +111,9 @@ public define String
111 111 public define String
112 112 make_list_view_row
113 113 (
114   - HK_Table table, //table to format
115   - String data_name, //name of data
116   - String indent, //indentation string to use
  114 + HK_Table table, //table to format
  115 + String data_name, //name of data
  116 + String indent, //indentation string to use
117 117 HK_Viewer list_view //list view to generate
118 118 )=
119 119 since table is hk_table(table_name, short, model, _), //get name and model of the table
... ... @@ -121,13 +121,13 @@ public define String
121 121 // since display is db_display(views, _), //
122 122 with current_list_column = if list_view is
123 123 {
124   - list_view_all then to_List_String(columns, false), //generate a list of columns string to view from columns model
125   - list_view(v_name, v_col, _) then v_col
  124 + list_view_all then to_List_String(columns, false), //generate a list of columns string to view from columns model
  125 + list_view(v_name, v_col, l_filters, _) then v_col
126 126 },
127 127 with action_name = if list_view is
128 128 {
129   - list_view_all then no_action,
130   - list_view(_, _, an) then an
  129 + list_view_all then no_action,
  130 + list_view(_, _, _, an) then an
131 131 },
132 132  
133 133 if current_list_column is
... ...
src/generation/vt_view.anubis
... ... @@ -7,6 +7,7 @@
7 7 */
8 8  
9 9 read hayamiki_lib/types/hayamiki.anubis
  10 +read hayamiki_lib/view/hk_filter.anubis
10 11 read tools/basis.anubis
11 12 read tools/streams.anubis
12 13 read system/string.anubis
... ... @@ -119,17 +120,17 @@ public define Maybe(One)
119 120 with view_name = if list_view is
120 121 {
121 122 list_view_all then "default",
122   - list_view(view_name, _, _) then view_name
  123 + list_view(view_name, _, _, _) then view_name
123 124 },
124 125 with current_list_view = if list_view is
125 126 {
126 127 list_view_all then to_List_String(columns, false),
127   - list_view(_, cols, _) then cols
  128 + list_view(_, cols, _, _) then cols
128 129 },
129 130 with current_view_models = if list_view is
130 131 {
131 132 list_view_all then columns,
132   - list_view(v_name, cols, _) then
  133 + list_view(v_name, cols, _, _) then
133 134 if get_HK_Model_Column_list_from_name_list(columns, cols) is
134 135 {
135 136 failure then println("generate_VT_view: can't get all specified columns for table \""+table_name+"\" view name \""+v_name+"\" cols["+join(", ",cols)+"]");[],
... ... @@ -207,7 +208,7 @@ public define Maybe(One)
207 208 if view is
208 209 {
209 210 list_view_all then true, //list_view_all is default view
210   - list_view(view_name, _, _) then
  211 + list_view(view_name, _, _, _) then
211 212 //if not we search for view named 'default'
212 213 if view_name = "default" then true else false
213 214 },
... ... @@ -235,7 +236,7 @@ public define String
235 236 with view_name = if view is
236 237 {
237 238 list_view_all then "default",
238   - list_view(view_name, _, _) then view_name
  239 + list_view(view_name, _, _, _) then view_name
239 240 },
240 241 _generate_get_viewable_if_else( table_name, t,
241 242 so_far +
... ... @@ -270,22 +271,30 @@ public define Maybe(One)
270 271 success(_) then success(unique)
271 272 }.
272 273  
  274 +define String
  275 + make_filter
  276 + (
  277 + List(HK_Filter) filters
  278 + )=
  279 + join(", \n", map((HK_Filter filter) |-> to_Anubis_source(filter), filters))
  280 +.
  281 +
273 282 public define List(String)
274 283 /* Generate
275 284  
276 285 */
277 286 _generate_list_view_name
278 287 (
279   - List(HK_Viewer) list_view, //list view to generate
280   - List(String) so_far,
281   - Bool has_default //set to true if a default view was encountered.
  288 + List(HK_Viewer) list_view, //list view to generate
  289 + List(String) so_far,
  290 + Bool has_default //set to true if a default view was encountered.
282 291 )=
283 292 if list_view is
284 293 {
285 294 [] then
286 295 //if default view was not generated, we force to generate it
287 296 if has_default = false then
288   - reverse(["\"default\"" . so_far])
  297 + reverse(["(\"default\", [])" . so_far])
289 298 else
290 299 reverse(so_far),
291 300 [view . t] then
... ... @@ -295,29 +304,29 @@ public define List(String)
295 304 if view is
296 305 {
297 306 list_view_all then true, //list_view_all is default view
298   - list_view(view_name, _, _) then
  307 + list_view(view_name, _, _, _) then
299 308 //if not we search for view named 'default'
300 309 if view_name = "default" then true else false
301 310 },
302   - with view_name = if view is
  311 + with entry = if view is
303 312 {
304   - list_view_all then "default",
305   - list_view(view_name, _, _) then view_name
  313 + list_view_all then "(\"default\", [])",
  314 + list_view(view_name, _, filter, _) then "(\""+view_name+"\", ["+make_filter(filter)+"])"
306 315 },
307   - _generate_list_view_name(t, ["\""+view_name+"\"" . so_far], new_has_default)
  316 + _generate_list_view_name(t, [entry . so_far], new_has_default)
308 317 }
309 318 .
310 319  
311 320 public define Maybe(One)
312 321 _generate_get_all_view_name
313 322 (
314   - Stream stream,
315   - HK_Table table, //
  323 + Stream stream,
  324 + HK_Table table, //
316 325 List(HK_Viewer) list_view
317 326 )=
318 327 since table is hk_table(table_name, short_name, model, display),
319 328 if write_string(stream,
320   - "\n\npublic define List(String)\n"+
  329 + "\n\npublic define List((String, List(HK_Filter)))\n"+
321 330 " get_all_"+table_name+"_view_name\n"+
322 331 " (\n"+
323 332 " One dummy\n"+
... ...
src/model.3.0.0.anubis
... ... @@ -44,267 +44,7 @@ public define HK_Table django_admin_log_table =
44 44 [ edit_view_all]
45 45 )
46 46 ).
47   -
48   -public define HK_Table production_macaddress_table =
49   - hk_table("macaddress",
50   - hk_model(
51   - [
52   -
53   - hk_column("mac", char_field(20), []),
54   - hk_column("mailfountain_id", integer_field, []),
55   - ],
56   - "obj.mac+\" = MailFountain[\"+obj.mailfountain_id+\"]\""
57   - ),
58   - hk_display(
59   - //list_view
60   - [ list_view_all],
61   - //list edit
62   - [edit_view_all]
63   - )
64   - ).
65   -
66   -public define HK_Table production_mass_storage_type_table =
67   - hk_table("mass_storage_type",
68   - hk_model(
69   - [
70   -
71   - hk_column("type", char_field(20), []),
72   - ],
73   - "to_String(obj.id)+\":\"+obj.type"
74   - ),
75   - hk_display(
76   - //list_view
77   - [ list_view_all],
78   - //list edit
79   - [edit_view_all]
80   - )
81   - ).
82   -
83   -
84   -
85   -public define HK_Table production_mass_storage_table =
86   - hk_table("mass_storage",
87   - hk_model(
88   - [
89   -
90   - hk_column("purchase_id", foreign_key("purchase"), []),
91   - hk_column("model_id", foreign_key("mass_storage_model"), []),
92   - hk_column("serial", char_field(40), []), //
93   - hk_column("status", char_field(10), []), //
94   - hk_column("date_created", datetime_field(auto_now_add), []),
95   - hk_column("last_modified", datetime_field(auto_now), []),
96   - hk_column("comments", text_field, []) // whatever the user wants to keep
97   - ],
98   - "obj.serial"
99   - ),
100   - hk_display(
101   - //list_view
102   - [
103   - list_view("current",["model_id", "serial", "status", "date_created"])
104   - ],
105   - //list_edit
106   - [ edit_view_list_form("default", ["purchase_id", "model_id", "serial", "status", "comments"])]
107   - )
108   - ).
109   -
110   - "CREATE TABLE production_purchase (
111   - id integer NOT NULL PRIMARY KEY,
112   - date date NOT NULL,
113   - buyer_id integer NOT NULL REFERENCES staff_staff (id),
114   - supplier_id integer NOT NULL REFERENCES production_supplier (id),
115   - order_ref varchar(50) NOT NULL,
116   - description varchar(200) NOT NULL,
117   - date_created datetime NOT NULL,
118   - last_modified datetime NOT NULL,
119   - comments text NOT NULL
120   - )"
121   -
122   -
123   -
124   -public define HK_Table production_mass_storage_model_table =
125   - hk_table("mass_storage_model",
126   - hk_model(
127   - [
128   -
129   - hk_column("manufacturer", char_field(20), []),
130   - hk_column("type_id", foreign_key("mass_storage_type"), []),
131   - hk_column("capacity", integer_field, []), //
132   - hk_column("tr_min", integer_field, []), //
133   - hk_column("date_created", datetime_field(auto_now_add), []),
134   - hk_column("last_modified", datetime_field(auto_now), []),
135   - hk_column("comments", text_field, []) // whatever the user wants to keep
136   - ],
137   - "obj.manufacturer"
138   - ),
139   - hk_display(
140   - //list_view
141   - [
142   - list_view("default", ["manufacturer", "type_id", "capacity", "tr_min", "last_modified", "date_created"])
143   - ],
144   - //list_edit
145   - [edit_view_all]
146   - )
147   - ).
148   -
149   -public define HK_Table production_memory_table =
150   - hk_table("memory",
151   - hk_model(
152   - [
153   -
154   - hk_column("purchase_id", foreign_key("purchase"), []),
155   - hk_column("model_id", foreign_key("memory_model"), []),
156   - hk_column("serial", char_field(40), []), //
157   - hk_column("status", char_field(10), []), //
158   - hk_column("date_created", datetime_field(auto_now_add), []),
159   - hk_column("last_modified", datetime_field(auto_now), []),
160   - hk_column("comments", text_field, []) // whatever the user wants to keep
161   - ],
162   - "obj.serial"
163   - ),
164   - hk_display(
165   - //list_view
166   - [
167   - list_view("default", ["serial", "status", "last_modified", "date_created"])
168   - ],
169   - //list_edit
170   - [edit_view_all]
171   - )
172   - ).
173   -
174   -public define HK_Table production_memory_model_table =
175   - hk_table("memory_model",
176   - hk_model(
177   - [
178   -
179   - hk_column("type_id", foreign_key("memory_type"), []),
180   - hk_column("manufacturer", char_field(20), []), //
181   - hk_column("capacity", integer_field, []) //
182   - ],
183   - "obj.manufacturer"
184   - ),
185   - hk_display(
186   - //list_view
187   - [ list_view_all],
188   - //list_edit
189   - [edit_view_all]
190   - )
191   - ).
192   -
193   -public define HK_Table production_memory_type_table =
194   - hk_table("memory_type",
195   - hk_model(
196   - [
197   -
198   - hk_column("type", char_field(20), []),
199   - ],
200   - "to_String(obj.id)+\":\"+obj.type"
201   - ),
202   - hk_display(
203   - //list_view
204   - [ list_view_all],
205   - //list edit
206   - [edit_view_all]
207   - )
208   - ).
209   -
210   -public define HK_Table production_motherboard_table =
211   - hk_table("motherboard",
212   - hk_model(
213   - [
214   -
215   - hk_column("purchase_id", foreign_key("purchase"), []),
216   - hk_column("model_id", foreign_key("motherboard_model"), []),
217   - hk_column("serial", char_field(40), []), //
218   - hk_column("week_fab", char_field(10), []), //
219   - hk_column("status", char_field(10), []), //
220   - hk_column("date_created", datetime_field(auto_now_add), []),
221   - hk_column("last_modified", datetime_field(auto_now), []),
222   - hk_column("comments", text_field, []) // whatever the user wants to keep
223   - ],
224   - "obj.serial"
225   - ),
226   - hk_display(
227   - //list_view
228   - [
229   - list_view("default", ["serial", "week_fab", "status", "last_modified", "date_created"])
230   - ],
231   - //list_edit
232   - [edit_view_all]
233   - )
234   - ).
235   -
236   -public define HK_Table production_motherboard_model_table =
237   - hk_table("motherboard_model",
238   - hk_model(
239   - [
240   -
241   - hk_column("name", char_field(30), []),
242   - hk_column("manufacturer", char_field(20), []),
243   - hk_column("has_nand", boolean_field, []),
244   - hk_column("nand_capacity", integer_field, []), //
245   - hk_column("memory", integer_field, []), //
246   - hk_column("cpu_freq", integer_field, []), //
247   - hk_column("cpu_model", char_field(30), []),
248   - hk_column("endian", char_field(1), []) // whatever the user wants to keep
249   - ],
250   - "obj.name"
251   - ),
252   - hk_display(
253   - //list_view
254   - [
255   - list_view("default", ["name", "manufacturer", "cpu_model", "cpu_freq"])
256   - ],
257   - //list_edit
258   - [edit_view_all]
259   - )
260   - ).
261 47  
262   -public define HK_Table production_power_supply_table =
263   - hk_table("power_supply",
264   - hk_model(
265   - [
266   -
267   - hk_column("purchase_id", foreign_key("purchase"), []),
268   - hk_column("model_id", foreign_key("power_supply_model"), []),
269   - hk_column("serial", char_field(40), []), //
270   - hk_column("status", char_field(10), []), //
271   - hk_column("date_created", datetime_field(auto_now_add), []),
272   - hk_column("last_modified", datetime_field(auto_now), []),
273   - hk_column("comments", text_field(rich_editor), []) // whatever the user wants to keep
274   - ],
275   - "obj.serial"
276   - ),
277   - hk_display(
278   - //list_view
279   - [
280   - list_view("default", ["serial", "status", "date_created", "last_modified"])
281   - ],
282   - //list_edit
283   - [edit_view_all]
284   - )
285   - ).
286   -
287   -public define HK_Table production_power_supply_model_table =
288   - hk_table("power_supply_model",
289   - hk_model(
290   - [
291   -
292   - hk_column("name", char_field(30), []),
293   - hk_column("manufacturer", char_field(20), []),
294   - hk_column("power", integer_field, [])
295   - ],
296   - "obj.name"
297   - ),
298   - hk_display(
299   - //list_view
300   - [
301   - list_view("default", ["name", "manufacturer"])
302   - ],
303   - //list_edit
304   - [edit_view_all]
305   - )
306   - ).
307   -
308 48 public define HK_Table production_product_reference_table =
309 49 hk_table("product_reference",
310 50 hk_model(
... ... @@ -610,7 +350,9 @@ public define HK_Table staff_table =
610 350 hk_display(
611 351 //list_view
612 352 [
613   - list_view("default", ["contact_id", "department_id", "role_id", "email"]),
  353 + list_view("default", ["contact_id", "department_id", "role_id", "email"],
  354 + [hk_filter("présent", "still_present = 1")]
  355 + ),
614 356 list_view("details", ["contact_id", "department_id", "role_id", "email", "incoming_date", "still_present"])
615 357  
616 358 ],
... ... @@ -667,17 +409,6 @@ public define HK_Database
667 409 //mf_serial_table
668 410 hk_app("production",
669 411 [
670   - production_mass_storage_table,
671   - production_mass_storage_type_table,
672   - production_mass_storage_model_table,
673   - production_memory_table,
674   - production_memory_model_table,
675   - production_memory_type_table,
676   - production_macaddress_table,
677   - production_motherboard_table,
678   - production_motherboard_model_table,
679   - production_power_supply_table,
680   - production_power_supply_model_table,
681 412 production_product_reference_table,
682 413 production_production_table,
683 414 production_production_site_table,
... ...