From 2fa1e96b6ee35a30ee585ea888cc8b61f0092caf Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 10 May 2020 02:01:19 +0900 Subject: [PATCH] add stepper and web_stepper into library. --- generic/types/stepper.anubis | 41 +++++++++++++++++++++++++++++++++++++++++ web/XL_web_stepper.anubis | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/types/XL_web_stepper.anubis | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 305 insertions(+), 0 deletions(-) create mode 100644 generic/types/stepper.anubis create mode 100644 web/XL_web_stepper.anubis create mode 100644 web/types/XL_web_stepper.anubis diff --git a/generic/types/stepper.anubis b/generic/types/stepper.anubis new file mode 100644 index 0000000..1859fb9 --- /dev/null +++ b/generic/types/stepper.anubis @@ -0,0 +1,41 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 04/04/2020 + * Time: 01:23 + * © David RENÉ + */ + +transmit xlib/web/types/making_a_web_site.anubis +transmit session.anubis + +public type Step_Status: + initial, + valid, + no_valid +. + +public type Step_Session: + step_session( + Int current_step, + Session session + ) +. + +public type Step: + step( + String name, //step name + Int index, //step number + (Step_Session stp_session) -> Step_Session process, + (Step_Session stp_session) -> HTML_Partial_Content view + ) +. + + +public type Stepper: + stepper( + String name, + List(Step) steps, + Step_Session session + ) +. diff --git a/web/XL_web_stepper.anubis b/web/XL_web_stepper.anubis new file mode 100644 index 0000000..4313791 --- /dev/null +++ b/web/XL_web_stepper.anubis @@ -0,0 +1,181 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 24/04/2020 + * Time: 15:12 + * © David RENÉ + */ + +transmit xlib/web/types/XL_web_stepper.anubis +transmit xlib/web/controllers_web_site.anubis + +public define Maybe(WEB_Stepper) + get_stepper_by_uid + ( + String _uid, + List(WEB_Stepper) steppers + )= + if steppers is + { + [] then failure, + [h . t] then + if h.uid = _uid then + success(h) + else + get_stepper_by_uid(_uid, t) + } +. + +public define Maybe(WEB_Stepper) + get_stepper + ( + List(Web_arg) _lwa, + List(WEB_Stepper) steppers + )= + if get_String(_lwa, "stepper_uid") is + { + failure then failure + success(stepper_uid) then get_stepper_by_uid(stepper_uid, steppers) + } +. + +public define Maybe(WEB_Step) + get_current_step + ( + List(WEB_Step) steps, + String current_step + )= + if steps is + { + [] then failure, + [h . t] then + if h.name = current_step then + success(h) + else + if get_current_step(h.childs, current_step) is + { + failure then get_current_step(t, current_step), + success(step) then success(step) + } + } +. + +public define Maybe(WEB_Step) + get_step + ( + List(Web_arg) _lwa, + List(WEB_Step) steps, + )= + if get_String(_lwa, "step") is + { + failure then failure + success(step) then get_current_step(steps, step) + } +. + +public define HTML_Partial_Content + web_stepper_button + ( + WEB_Step_Session stp_session + )= + partial_content(empty) +. + +public define HTML_Partial_Content + web_stepper_main_view + ( + WEB_Step_Session stp_session + )= + partial_content(empty) +. + +public define HTML_Partial_Content + web_stepper_message + ( + WEB_Step_Session stp_session + )= + partial_content(empty) +. + +public define HTML_Partial_Content + web_stepper_name + ( + WEB_Step_Session stp_session + )= + partial_content(empty) +. + +public define HTML_Partial_Content + web_stepper_crumble + ( + WEB_Stepper stepper, + WEB_Step_Session stp_session + )= + partial_content(empty) +. + +public define HTML_Partial_Content + web_stepper_view + ( + WEB_Stepper stepper, + WEB_Step_Session stp_session + )= + with _current_step = get_current_step(stepper.steps, stp_session.current_step), + + partial_content([ + div(id("stepper"), [ + partial(web_stepper_crumble(stepper, stp_session)), + partial(web_stepper_name(stp_session)), + partial(web_stepper_message(stp_session)), + partial(web_stepper_main_view(stp_session)), + partial(web_stepper_button(stp_session)) + ]) + ]) +. + +public define WEB_Controller_Result + manage_stepper_action + ( + List(Web_arg) _lwa, + WEB_Session _session, + WEB_Step _step + )= + with action = get_String(_lwa, "step_a", "N/A"), + if action = "submit" then + ajax(_session, no_content) + else if action = "init" then + ajax(_session, no_content) + else + ajax(_session, no_content) +. + +public define WEB_Controller_Result + manage_stepper + ( + WEB_Session _session, + List(WEB_Stepper) _steppers + )= + with _lwa = *_session.web_request.lwa, + if get_stepper(_lwa, _steppers) is + { + failure then ajax(_session, no_content), + success(stepper) then + //get session of the stepper + with stepper_session = get_Session(_session.fields, stepper.uid, session(stepper.uid, empty_fields_list)), + if get_String(_lwa, "step") is + { + failure then ajax(_session, no_content) + success(step_name) then + if step_name = "start" then + ajax(_session, web_stepper_view(stepper, stepper.start(_session))) + else + if get_current_step(stepper.steps, step_name) is + { + failure then ajax(_session, no_content), + success(step) then + manage_stepper_action(_lwa, _session, step) + } + } + + } +. diff --git a/web/types/XL_web_stepper.anubis b/web/types/XL_web_stepper.anubis new file mode 100644 index 0000000..ab8870e --- /dev/null +++ b/web/types/XL_web_stepper.anubis @@ -0,0 +1,83 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 23/04/2020 + * Time: 19:48 + * © David RENÉ + */ + + +read web_session.anubis +transmit xlib/generic/types/stepper.anubis +// +//public type Step_status: +// initial, +// valid, +// no_valid. + + +public define WEB_Action_Name web_stepper_start = controller_action("web_stepper", "start"). + +public define List((String, String)) + stepper_args + ( + String uid, + String index, + List((String, String)) extra_args + )= + [("stepper_uid",uid), ("step", index) . extra_args] +. + +public define List((String, String)) + stepper_args + ( + String uid, + String index + )= + stepper_args(uid, index, []) +. + +public type Step_View_Status: + invisible, + locked, + selectable +. + +public type WEB_Step_Status: + web_step_status( + String step_name, + String index, + Step_Status status, + Step_View_Status v_status + ) +. + +public type WEB_Step_Session: + web_step_session( + List(WEB_Step_Status) web_steps_status, + String current_step, + Session step_session + ) +. + +public type WEB_Step: + web_step( + String name, //step name + String index, //step number + String thread, //thread name like general, VoIP, etc. + List(WEB_Step) childs, + (One) -> WEB_Step_Status init, //return the initial step status + (WEB_Step_Session stp_session) -> HTML_Partial_Content view, + (WEB_Step_Session stp_session, WEB_Session web_session) -> WEB_Step_Session submit, + ) +. + +public type WEB_Stepper: + web_stepper( + String name, + String uid, + (WEB_Session web_session) -> WEB_Step_Session start, + List(WEB_Step) steps + //Step_Session session + ) +. -- libgit2 0.21.4