Commit 2fa1e96b6ee35a30ee585ea888cc8b61f0092caf
1 parent
045c7412
add stepper and web_stepper into library.
Showing
3 changed files
with
305 additions
and
0 deletions
Show diff stats
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 04/04/2020 | ||
| 5 | + * Time: 01:23 | ||
| 6 | + * © David RENÉ | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +transmit xlib/web/types/making_a_web_site.anubis | ||
| 10 | +transmit session.anubis | ||
| 11 | + | ||
| 12 | +public type Step_Status: | ||
| 13 | + initial, | ||
| 14 | + valid, | ||
| 15 | + no_valid | ||
| 16 | +. | ||
| 17 | + | ||
| 18 | +public type Step_Session: | ||
| 19 | + step_session( | ||
| 20 | + Int current_step, | ||
| 21 | + Session session | ||
| 22 | + ) | ||
| 23 | +. | ||
| 24 | + | ||
| 25 | +public type Step: | ||
| 26 | + step( | ||
| 27 | + String name, //step name | ||
| 28 | + Int index, //step number | ||
| 29 | + (Step_Session stp_session) -> Step_Session process, | ||
| 30 | + (Step_Session stp_session) -> HTML_Partial_Content view | ||
| 31 | + ) | ||
| 32 | +. | ||
| 33 | + | ||
| 34 | + | ||
| 35 | +public type Stepper: | ||
| 36 | + stepper( | ||
| 37 | + String name, | ||
| 38 | + List(Step) steps, | ||
| 39 | + Step_Session session | ||
| 40 | + ) | ||
| 41 | +. |
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 24/04/2020 | ||
| 5 | + * Time: 15:12 | ||
| 6 | + * © David RENÉ | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +transmit xlib/web/types/XL_web_stepper.anubis | ||
| 10 | +transmit xlib/web/controllers_web_site.anubis | ||
| 11 | + | ||
| 12 | +public define Maybe(WEB_Stepper) | ||
| 13 | + get_stepper_by_uid | ||
| 14 | + ( | ||
| 15 | + String _uid, | ||
| 16 | + List(WEB_Stepper) steppers | ||
| 17 | + )= | ||
| 18 | + if steppers is | ||
| 19 | + { | ||
| 20 | + [] then failure, | ||
| 21 | + [h . t] then | ||
| 22 | + if h.uid = _uid then | ||
| 23 | + success(h) | ||
| 24 | + else | ||
| 25 | + get_stepper_by_uid(_uid, t) | ||
| 26 | + } | ||
| 27 | +. | ||
| 28 | + | ||
| 29 | +public define Maybe(WEB_Stepper) | ||
| 30 | + get_stepper | ||
| 31 | + ( | ||
| 32 | + List(Web_arg) _lwa, | ||
| 33 | + List(WEB_Stepper) steppers | ||
| 34 | + )= | ||
| 35 | + if get_String(_lwa, "stepper_uid") is | ||
| 36 | + { | ||
| 37 | + failure then failure | ||
| 38 | + success(stepper_uid) then get_stepper_by_uid(stepper_uid, steppers) | ||
| 39 | + } | ||
| 40 | +. | ||
| 41 | + | ||
| 42 | +public define Maybe(WEB_Step) | ||
| 43 | + get_current_step | ||
| 44 | + ( | ||
| 45 | + List(WEB_Step) steps, | ||
| 46 | + String current_step | ||
| 47 | + )= | ||
| 48 | + if steps is | ||
| 49 | + { | ||
| 50 | + [] then failure, | ||
| 51 | + [h . t] then | ||
| 52 | + if h.name = current_step then | ||
| 53 | + success(h) | ||
| 54 | + else | ||
| 55 | + if get_current_step(h.childs, current_step) is | ||
| 56 | + { | ||
| 57 | + failure then get_current_step(t, current_step), | ||
| 58 | + success(step) then success(step) | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | +. | ||
| 62 | + | ||
| 63 | +public define Maybe(WEB_Step) | ||
| 64 | + get_step | ||
| 65 | + ( | ||
| 66 | + List(Web_arg) _lwa, | ||
| 67 | + List(WEB_Step) steps, | ||
| 68 | + )= | ||
| 69 | + if get_String(_lwa, "step") is | ||
| 70 | + { | ||
| 71 | + failure then failure | ||
| 72 | + success(step) then get_current_step(steps, step) | ||
| 73 | + } | ||
| 74 | +. | ||
| 75 | + | ||
| 76 | +public define HTML_Partial_Content | ||
| 77 | + web_stepper_button | ||
| 78 | + ( | ||
| 79 | + WEB_Step_Session stp_session | ||
| 80 | + )= | ||
| 81 | + partial_content(empty) | ||
| 82 | +. | ||
| 83 | + | ||
| 84 | +public define HTML_Partial_Content | ||
| 85 | + web_stepper_main_view | ||
| 86 | + ( | ||
| 87 | + WEB_Step_Session stp_session | ||
| 88 | + )= | ||
| 89 | + partial_content(empty) | ||
| 90 | +. | ||
| 91 | + | ||
| 92 | +public define HTML_Partial_Content | ||
| 93 | + web_stepper_message | ||
| 94 | + ( | ||
| 95 | + WEB_Step_Session stp_session | ||
| 96 | + )= | ||
| 97 | + partial_content(empty) | ||
| 98 | +. | ||
| 99 | + | ||
| 100 | +public define HTML_Partial_Content | ||
| 101 | + web_stepper_name | ||
| 102 | + ( | ||
| 103 | + WEB_Step_Session stp_session | ||
| 104 | + )= | ||
| 105 | + partial_content(empty) | ||
| 106 | +. | ||
| 107 | + | ||
| 108 | +public define HTML_Partial_Content | ||
| 109 | + web_stepper_crumble | ||
| 110 | + ( | ||
| 111 | + WEB_Stepper stepper, | ||
| 112 | + WEB_Step_Session stp_session | ||
| 113 | + )= | ||
| 114 | + partial_content(empty) | ||
| 115 | +. | ||
| 116 | + | ||
| 117 | +public define HTML_Partial_Content | ||
| 118 | + web_stepper_view | ||
| 119 | + ( | ||
| 120 | + WEB_Stepper stepper, | ||
| 121 | + WEB_Step_Session stp_session | ||
| 122 | + )= | ||
| 123 | + with _current_step = get_current_step(stepper.steps, stp_session.current_step), | ||
| 124 | + | ||
| 125 | + partial_content([ | ||
| 126 | + div(id("stepper"), [ | ||
| 127 | + partial(web_stepper_crumble(stepper, stp_session)), | ||
| 128 | + partial(web_stepper_name(stp_session)), | ||
| 129 | + partial(web_stepper_message(stp_session)), | ||
| 130 | + partial(web_stepper_main_view(stp_session)), | ||
| 131 | + partial(web_stepper_button(stp_session)) | ||
| 132 | + ]) | ||
| 133 | + ]) | ||
| 134 | +. | ||
| 135 | + | ||
| 136 | +public define WEB_Controller_Result | ||
| 137 | + manage_stepper_action | ||
| 138 | + ( | ||
| 139 | + List(Web_arg) _lwa, | ||
| 140 | + WEB_Session _session, | ||
| 141 | + WEB_Step _step | ||
| 142 | + )= | ||
| 143 | + with action = get_String(_lwa, "step_a", "N/A"), | ||
| 144 | + if action = "submit" then | ||
| 145 | + ajax(_session, no_content) | ||
| 146 | + else if action = "init" then | ||
| 147 | + ajax(_session, no_content) | ||
| 148 | + else | ||
| 149 | + ajax(_session, no_content) | ||
| 150 | +. | ||
| 151 | + | ||
| 152 | +public define WEB_Controller_Result | ||
| 153 | + manage_stepper | ||
| 154 | + ( | ||
| 155 | + WEB_Session _session, | ||
| 156 | + List(WEB_Stepper) _steppers | ||
| 157 | + )= | ||
| 158 | + with _lwa = *_session.web_request.lwa, | ||
| 159 | + if get_stepper(_lwa, _steppers) is | ||
| 160 | + { | ||
| 161 | + failure then ajax(_session, no_content), | ||
| 162 | + success(stepper) then | ||
| 163 | + //get session of the stepper | ||
| 164 | + with stepper_session = get_Session(_session.fields, stepper.uid, session(stepper.uid, empty_fields_list)), | ||
| 165 | + if get_String(_lwa, "step") is | ||
| 166 | + { | ||
| 167 | + failure then ajax(_session, no_content) | ||
| 168 | + success(step_name) then | ||
| 169 | + if step_name = "start" then | ||
| 170 | + ajax(_session, web_stepper_view(stepper, stepper.start(_session))) | ||
| 171 | + else | ||
| 172 | + if get_current_step(stepper.steps, step_name) is | ||
| 173 | + { | ||
| 174 | + failure then ajax(_session, no_content), | ||
| 175 | + success(step) then | ||
| 176 | + manage_stepper_action(_lwa, _session, step) | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + } | ||
| 181 | +. |
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 23/04/2020 | ||
| 5 | + * Time: 19:48 | ||
| 6 | + * © David RENÉ | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +read web_session.anubis | ||
| 11 | +transmit xlib/generic/types/stepper.anubis | ||
| 12 | +// | ||
| 13 | +//public type Step_status: | ||
| 14 | +// initial, | ||
| 15 | +// valid, | ||
| 16 | +// no_valid. | ||
| 17 | + | ||
| 18 | + | ||
| 19 | +public define WEB_Action_Name web_stepper_start = controller_action("web_stepper", "start"). | ||
| 20 | + | ||
| 21 | +public define List((String, String)) | ||
| 22 | + stepper_args | ||
| 23 | + ( | ||
| 24 | + String uid, | ||
| 25 | + String index, | ||
| 26 | + List((String, String)) extra_args | ||
| 27 | + )= | ||
| 28 | + [("stepper_uid",uid), ("step", index) . extra_args] | ||
| 29 | +. | ||
| 30 | + | ||
| 31 | +public define List((String, String)) | ||
| 32 | + stepper_args | ||
| 33 | + ( | ||
| 34 | + String uid, | ||
| 35 | + String index | ||
| 36 | + )= | ||
| 37 | + stepper_args(uid, index, []) | ||
| 38 | +. | ||
| 39 | + | ||
| 40 | +public type Step_View_Status: | ||
| 41 | + invisible, | ||
| 42 | + locked, | ||
| 43 | + selectable | ||
| 44 | +. | ||
| 45 | + | ||
| 46 | +public type WEB_Step_Status: | ||
| 47 | + web_step_status( | ||
| 48 | + String step_name, | ||
| 49 | + String index, | ||
| 50 | + Step_Status status, | ||
| 51 | + Step_View_Status v_status | ||
| 52 | + ) | ||
| 53 | +. | ||
| 54 | + | ||
| 55 | +public type WEB_Step_Session: | ||
| 56 | + web_step_session( | ||
| 57 | + List(WEB_Step_Status) web_steps_status, | ||
| 58 | + String current_step, | ||
| 59 | + Session step_session | ||
| 60 | + ) | ||
| 61 | +. | ||
| 62 | + | ||
| 63 | +public type WEB_Step: | ||
| 64 | + web_step( | ||
| 65 | + String name, //step name | ||
| 66 | + String index, //step number | ||
| 67 | + String thread, //thread name like general, VoIP, etc. | ||
| 68 | + List(WEB_Step) childs, | ||
| 69 | + (One) -> WEB_Step_Status init, //return the initial step status | ||
| 70 | + (WEB_Step_Session stp_session) -> HTML_Partial_Content view, | ||
| 71 | + (WEB_Step_Session stp_session, WEB_Session web_session) -> WEB_Step_Session submit, | ||
| 72 | + ) | ||
| 73 | +. | ||
| 74 | + | ||
| 75 | +public type WEB_Stepper: | ||
| 76 | + web_stepper( | ||
| 77 | + String name, | ||
| 78 | + String uid, | ||
| 79 | + (WEB_Session web_session) -> WEB_Step_Session start, | ||
| 80 | + List(WEB_Step) steps | ||
| 81 | + //Step_Session session | ||
| 82 | + ) | ||
| 83 | +. |