XL_web_stepper.anubis
3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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)
}
}
}
.