Commit 71d241d399afb00c20624ca2bba50c0d3acfc66a

Authored by David RENÉ
1 parent 32de59ae

replace p_key and foreign_key from db_id to db_id_or_null

use anbexec.1.19 for the type generator
rename hk_controller to hk_web_controller
add support of select2
ds_files/graphviz.gv
1 1 /*
2 2 * Created by 伝作 (Densaku).
3 3 * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
4   - * Date: 2019-07-14
5   - * Time: 16:15:41
  4 + * Date: 2022-05-28
  5 + * Time: 21:06:38
6 6 *
7 7 */
8 8  
... ...
hayamiki_ds_types.anubis
... ... @@ -24,4 +24,4 @@ global define One
24 24 success(ds_gen) then forget(ds_gen.generate_type_files(hayamiki_lib_types_description, [], "ds_files/"))
25 25 }.
26 26  
27   -execute anbexec hayamiki_1_19_lib_ds // generate the file
  27 +execute anbexec.1.19 hayamiki_1_19_lib_ds // generate the file
... ...
hayamiki_ds_types.aproj
... ... @@ -11,7 +11,7 @@
11 11 <MakeUsedFile>False</MakeUsedFile>
12 12 <MakeUnusedFile>False</MakeUnusedFile>
13 13 <AnubiscVerbosity>False</AnubiscVerbosity>
14   - <AnubisPath>c:\anubis.1.19\</AnubisPath>
  14 + <AnubisPath>c:\anubis\1.19\</AnubisPath>
15 15 </PropertyGroup>
16 16 <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
17 17 <OutputPath>bin\Debug\</OutputPath>
... ...
hayamiki_lib @ d57036b4baa
1   -Subproject commit 121721e07c35734855b53c726dad24f43dfcae67
  1 +Subproject commit d57036b4baa16371f6eedbf8ff6e4361f4e89081
... ...
src/generation/extractor.anubis
... ... @@ -20,12 +20,12 @@ public define String
20 20 with cursor_index = "("+cursor+")("+index+")",
21 21 if t is
22 22 {
23   - p_key then "db_id((Int)db_integer"+cursor_index+")",
  23 + p_key then "db_id_or_null"+cursor_index,
24 24 boolean_field then "db_bool"+cursor_index,
25 25 date_field(_) then "db_date(text"+cursor_index+")",
26 26 time_field(_) then "db_time(text"+cursor_index+")",
27 27 datetime_field(_) then "db_datetime(text"+cursor_index+")",
28   - foreign_key(_,_,_,_,_) then "db_id((Int)db_integer"+cursor_index+")",
  28 + foreign_key(_,_,_,_,_) then "db_id_or_null"+cursor_index,
29 29 integer_field(_) then "(Int)db_integer"+cursor_index,
30 30 float_field then "db_float"+cursor_index,
31 31 char_field(_,_) then "text"+cursor_index,
... ...
src/web_controller/controller.anubis
... ... @@ -13,7 +13,7 @@ read hayamiki_lib/view/view_table_manager_types.anubis
13 13  
14 14  
15 15 public define WEB_Controller
16   - get_hk_controller
  16 + get_hk_web_controller
17 17 (
18 18 SQLite3DataBase db,
19 19 HK_Database hk_db,
... ... @@ -32,5 +32,5 @@ public define List(WEB_Controller)
32 32 VTM _vtm,
33 33 (LogLevel, String) -> One logger
34 34 ) =
35   - [get_hk_controller(db, hk_db, _vtm, logger)]
  35 + [get_hk_web_controller(db, hk_db, _vtm, logger)]
36 36 .
... ...
src/web_controller/hayamiki.anubis
... ... @@ -658,6 +658,43 @@ define (WEB_Session) -&gt; WEB_Controller_Result
658 658 }
659 659 .
660 660  
  661 +define List(JsonValue)
  662 + to_select2_results
  663 + (
  664 + List((List(CoreAttrs), WebArgValue, String)) l,
  665 + String selected
  666 + ) =
  667 + if l is
  668 + {
  669 + [ ] then
  670 + if selected = "" then
  671 + [json_object([json_member("id", json_string("-1")),
  672 + json_member("text", json_string(""))])]
  673 + else
  674 + [ ],
  675 + [h . t] then
  676 + if h is (attrs, val, item)
  677 + then [json_object([json_member("id", json_string(val.value)),
  678 + json_member("text", json_string(item))]+
  679 + if selected = val.value then
  680 + [json_member("selected", json_bool(true))]
  681 + else
  682 + []) . to_select2_results(t, selected)]
  683 + }
  684 +.
  685 +
  686 +define JsonValue
  687 + to_select2_results
  688 + (
  689 + List((List(CoreAttrs), WebArgValue, String)) l,
  690 + String selected
  691 + ) =
  692 + println("to_select2_results: selected ["+selected+"]");
  693 + json_object([
  694 + json_member("results", json_array(to_select2_results(l, selected)))
  695 + ])
  696 +.
  697 +
661 698 define (WEB_Session) -> WEB_Controller_Result
662 699 get_selector
663 700 (
... ... @@ -674,14 +711,19 @@ define (WEB_Session) -&gt; WEB_Controller_Result
674 711 with sub_dialog = get_Bool(lwa, "sub_dialog"),
675 712 with fk_filter = get_String(lwa, "fk_filter", ""),
676 713 with selected = get_String(lwa, "selected", ""),
  714 + with select2 = get_Bool(lwa, "select2"),
677 715 with referer = get_HK_Referer_from_web_arg(lwa, ""),
678 716  
  717 + println("get_selector");
  718 +
679 719 if get_hk_controller(_vtm.hk_controllers, table_name) is
680 720 {
681 721 failure then println("can't get writer for "+table_name);redirect_to_previous,
682 722 success(controller) then
683   -
684   - ajax(json(http_ok, to_html_ajax_content(format_choices(controller.get_selector(db, referer, fk_filter), init(selected)), "")))
  723 + if select2 then
  724 + ajax(json(http_ok, to_select2_results(controller.get_selector(db, referer, fk_filter), selected)))
  725 + else
  726 + ajax(json(http_ok, to_html_ajax_content(format_choices(controller.get_selector(db, referer, fk_filter), init(selected)), "")))
685 727  
686 728 }
687 729 .
... ...