/* * 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) } } } .