Commit 3b01c02a44ca5cb94ff2fe3d7ca7f658dd2eaefc

Authored by David RENÉ
1 parent 9f88d4ed

working version of the Stepper

Showing 2 changed files with 91 additions and 32 deletions   Show diff stats
web/XL_web_stepper.anubis
@@ -10,7 +10,9 @@ transmit xlib/web/CXM_jquery.anubis @@ -10,7 +10,9 @@ transmit xlib/web/CXM_jquery.anubis
10 transmit xlib/web/types/XL_web_stepper.anubis 10 transmit xlib/web/types/XL_web_stepper.anubis
11 transmit xlib/web/controllers_web_site.anubis 11 transmit xlib/web/controllers_web_site.anubis
12 read xlib/web/CXM_page_message.anubis 12 read xlib/web/CXM_page_message.anubis
  13 +read xlib/web/jQuery/CXM_jquery_button.anubis
13 read xlib/web_controllers/language/language_management.anubis 14 read xlib/web_controllers/language/language_management.anubis
  15 +read xlib/web/widgets/icons_set.anubis
14 16
15 public define Maybe(WEB_Stepper) 17 public define Maybe(WEB_Stepper)
16 get_stepper_by_uid 18 get_stepper_by_uid
@@ -87,20 +89,24 @@ public define HTML_Partial_Content @@ -87,20 +89,24 @@ public define HTML_Partial_Content
87 web_stepper_button 89 web_stepper_button
88 ( 90 (
89 WEB_Step _step, 91 WEB_Step _step,
90 - WEB_Step_Session stp_session 92 + WEB_Step_Session stp_session,
  93 + (String)->String _T
91 )= 94 )=
92 - partial_content(div(class("steppers_buttons"), _step.buttons(stp_session))) 95 + partial_content(
  96 + div(class("stepper_buttons"),
  97 + _step.buttons(stp_session, _T)))
93 . 98 .
94 99
95 public define HTML_Partial_Content 100 public define HTML_Partial_Content
96 web_stepper_main_view 101 web_stepper_main_view
97 ( 102 (
98 WEB_Step _step, 103 WEB_Step _step,
99 - WEB_Step_Session stp_session 104 + WEB_Step_Session stp_session,
  105 + (String)->String _T
100 )= 106 )=
101 partial_content( 107 partial_content(
102 div(class("stepper_main_view"), 108 div(class("stepper_main_view"),
103 - _step.view(stp_session))) 109 + _step.view(stp_session, _T)))
104 . 110 .
105 111
106 public define HTML_Partial_Content 112 public define HTML_Partial_Content
@@ -109,40 +115,54 @@ public define HTML_Partial_Content @@ -109,40 +115,54 @@ public define HTML_Partial_Content
109 WEB_Step_Session stp_session, 115 WEB_Step_Session stp_session,
110 (String)->String _T 116 (String)->String _T
111 )= 117 )=
112 - partial_content(div(class("stepper_message"), show_page_message(get_Page_Message(stp_session.session.fields, _T)))) 118 + with page_msg = get_Page_Message(stp_session.session.fields, _T),
  119 + //if there is no message return empty to avoid to have an empty div with padding
  120 + if page_msg = no_message then
  121 + partial_empty
  122 + else
  123 + partial_content(
  124 + div(class("stepper_message"),
  125 + show_page_message(page_msg)))
113 . 126 .
114 127
115 public define HTML_Partial_Content 128 public define HTML_Partial_Content
116 - web_stepper_name 129 + web_stepper_full_description
117 ( 130 (
118 - WEB_Step_Session stp_session 131 + WEB_Step current_step,
  132 + (String)->String _T
119 )= 133 )=
120 - partial_content(empty) 134 + if current_step.full_description = "" then
  135 + partial_content(empty)
  136 + else
  137 + partial_content(
  138 + div(class("stepper_full_description"),
  139 + text(_T(current_step.full_description))))
121 . 140 .
122 141
123 public define Bool 142 public define Bool
124 is_current 143 is_current
125 ( 144 (
126 - WEB_Step step,  
127 - WEB_Step_Session stp_session 145 + WEB_Step step,
  146 + WEB_Step current_step
128 )= 147 )=
129 - stp_session.current_step = step.name 148 + current_step.name = step.name
130 . 149 .
131 150
132 public define Bool 151 public define Bool
133 is_active 152 is_active
134 ( 153 (
135 - WEB_Step step,  
136 - WEB_Step_Session stp_session 154 + WEB_Step step,
  155 + WEB_Step current_step
137 )= 156 )=
138 - true 157 + step.index < current_step.index
139 . 158 .
140 159
141 public define HTML_Partial_Content 160 public define HTML_Partial_Content
142 web_stepper_crumble 161 web_stepper_crumble
143 ( 162 (
144 - WEB_Stepper stepper,  
145 - WEB_Step_Session stp_session 163 + WEB_Stepper _stepper,
  164 + WEB_Step _current_step,
  165 + (String) -> String _T
146 )= 166 )=
147 partial_content( 167 partial_content(
148 div(class("stepper_crumble"), 168 div(class("stepper_crumble"),
@@ -150,18 +170,24 @@ public define HTML_Partial_Content @@ -150,18 +170,24 @@ public define HTML_Partial_Content
150 ul(class("multi-step-list"), 170 ul(class("multi-step-list"),
151 171
152 map((WEB_Step step) |-> 172 map((WEB_Step step) |->
153 - with active = if is_active(step, stp_session) then " active" else "",  
154 - current = if is_current(step, stp_session) then " current" else "",  
155 -  
156 - li(class("multi-step-item"+active+current), 173 + with active = if is_active(step, _current_step) then " active" else "",
  174 + current = if is_current(step, _current_step) then " current" else "",
  175 + with go = if is_active(step, _current_step) then
  176 + with url = format_web_action_name_to_js(_stepper.web_controller, [("stepper_uid",_stepper.uid), ("step",step.name), ("step_a", "go")]),
  177 + event(onclick, "stepper_go("+url+");")
  178 + else
  179 + empty,
  180 +
  181 + li([class("multi-step-item"+active+current),
  182 + go],
157 div(class("item-wrap"), 183 div(class("item-wrap"),
158 p(class("item-title"), 184 p(class("item-title"),
159 - text(step.name) 185 + text(_T(to_upper(step.name)))
160 ) 186 )
161 ) 187 )
162 ) 188 )
163 , 189 ,
164 - stepper.steps 190 + _stepper.steps
165 ) 191 )
166 192
167 ) 193 )
@@ -180,7 +206,9 @@ public define HTML_Partial_Content @@ -180,7 +206,9 @@ public define HTML_Partial_Content
180 )= 206 )=
181 println("web_stepper_view _current_step.name ["+_current_step.name+"]"); 207 println("web_stepper_view _current_step.name ["+_current_step.name+"]");
182 208
183 - partial_content([css(css_file("xlib/css/stepper.css")), 209 + partial_content([
  210 + css(css_file("xlib/css/stepper.css")),
  211 + js(js_file("xlib/js/stepper.js")),
184 js_inline(jquery_ready("$('#stepper_form').on('submit', function(e) { e.stopPropagation(); return false; });")) 212 js_inline(jquery_ready("$('#stepper_form').on('submit', function(e) { e.stopPropagation(); return false; });"))
185 ], [ 213 ], [
186 div([id("stepper"), class("stepper")], [ 214 div([id("stepper"), class("stepper")], [
@@ -188,11 +216,11 @@ public define HTML_Partial_Content @@ -188,11 +216,11 @@ public define HTML_Partial_Content
188 hidden("step", _current_step.name), //add current step name as hidden argument 216 hidden("step", _current_step.name), //add current step name as hidden argument
189 hidden("stepper_uid",_stepper.uid), //add stepper_uid as hidden argument 217 hidden("stepper_uid",_stepper.uid), //add stepper_uid as hidden argument
190 //construct bread crumb line 218 //construct bread crumb line
191 - partial(web_stepper_crumble(_stepper, stp_session)),  
192 - partial(web_stepper_name(stp_session)), 219 + partial(web_stepper_crumble(_stepper, _current_step, _T)),
  220 + partial(web_stepper_full_description(_current_step, _T)),
193 partial(web_stepper_message(stp_session, _T)), 221 partial(web_stepper_message(stp_session, _T)),
194 - partial(web_stepper_main_view(_current_step, stp_session)), //OK  
195 - partial(web_stepper_button(_current_step, stp_session)) 222 + partial(web_stepper_main_view(_current_step, stp_session, _T)), //OK
  223 + partial(web_stepper_button(_current_step, stp_session, _T))
196 ]) 224 ])
197 ]) 225 ])
198 ]) 226 ])
@@ -237,6 +265,10 @@ public define WEB_Controller_Result @@ -237,6 +265,10 @@ public define WEB_Controller_Result
237 ajax(_web_session, web_stepper_view(_stepper, new_session, _T)) 265 ajax(_web_session, web_stepper_view(_stepper, new_session, _T))
238 266
239 // ajax(_session, no_content) 267 // ajax(_session, no_content)
  268 + else if action = "go" then
  269 + set_Page_Message(stepper_session.session.fields, no_message);
  270 + replace_Session(_web_session.fields, _stepper.uid, stepper_session.session);
  271 + ajax(_web_session, web_stepper_view(_stepper, stepper_session, _T))
240 else if action = "init" then 272 else if action = "init" then
241 ajax(_web_session, no_content) 273 ajax(_web_session, no_content)
242 else 274 else
@@ -283,3 +315,25 @@ public define WEB_Controller_Result @@ -283,3 +315,25 @@ public define WEB_Controller_Result
283 315
284 } 316 }
285 . 317 .
  318 +
  319 +public define HTML_Partial_Content
  320 + stepper_submit_button
  321 + (
  322 + String label,
  323 + WEB_Action_Name wan,
  324 + String submit_action,
  325 + List((String, String)) extra_args
  326 + )=
  327 + with url = format_web_action_name_to_js(wan,[("step_a", "submit"), ("submit_a",submit_action) . extra_args]),
  328 + jquery_button(jquery_img_button(icn16_check, label, "", jQuery_actioner(same, jqscript("stepper_submit("+url+");")), left))
  329 +.
  330 +
  331 +public define HTML_Partial_Content
  332 + stepper_submit_button
  333 + (
  334 + String label,
  335 + WEB_Action_Name wan,
  336 + String submit_action,
  337 + )=
  338 + stepper_submit_button(label, wan, submit_action, [])
  339 +.
web/types/XL_web_stepper.anubis
@@ -9,6 +9,9 @@ @@ -9,6 +9,9 @@
9 9
10 transmit web_session.anubis 10 transmit web_session.anubis
11 transmit xlib/generic/types/stepper.anubis 11 transmit xlib/generic/types/stepper.anubis
  12 +
  13 +public type WEB_Step:...
  14 +
12 // 15 //
13 //public type Step_status: 16 //public type Step_status:
14 // initial, 17 // initial,
@@ -46,7 +49,7 @@ public type Step_View_Status: @@ -46,7 +49,7 @@ public type Step_View_Status:
46 public type WEB_Step_Status: 49 public type WEB_Step_Status:
47 web_step_status( 50 web_step_status(
48 String step_name, 51 String step_name,
49 - String index, 52 + Int index,
50 Step_Status status, 53 Step_Status status,
51 Step_View_Status v_status 54 Step_View_Status v_status
52 ) 55 )
@@ -63,12 +66,13 @@ public type WEB_Step_Session: @@ -63,12 +66,13 @@ public type WEB_Step_Session:
63 public type WEB_Step: 66 public type WEB_Step:
64 web_step( 67 web_step(
65 String name, //step name 68 String name, //step name
66 - String index, //step number 69 + String full_description,
  70 + Int index, //step index
67 String thread, //thread name like general, VoIP, etc. 71 String thread, //thread name like general, VoIP, etc.
68 List(WEB_Step) childs, 72 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, //return the view according to WEB_Step_Session  
71 - (WEB_Step_Session stp_session) -> HTML_Partial_Content buttons, 73 + (WEB_Step_Session stp_session) -> WEB_Step_Status status, //return the step status
  74 + (WEB_Step_Session stp_session, (String)->String _T) -> HTML_Partial_Content view, //return the view according to WEB_Step_Session
  75 + (WEB_Step_Session stp_session, (String)->String _T) -> HTML_Partial_Content buttons,
72 (WEB_Step_Session stp_session, WEB_Session web_session) -> WEB_Step_Session submit, 76 (WEB_Step_Session stp_session, WEB_Session web_session) -> WEB_Step_Session submit,
73 ) 77 )
74 . 78 .
@@ -77,6 +81,7 @@ public type WEB_Stepper: @@ -77,6 +81,7 @@ public type WEB_Stepper:
77 web_stepper( 81 web_stepper(
78 String name, //name of the stepper 82 String name, //name of the stepper
79 String uid, //uid of the stepper (currently same as name) 83 String uid, //uid of the stepper (currently same as name)
  84 + WEB_Action_Name web_controller,
80 (WEB_Session web_session) -> WEB_Step_Session start, //start function to call at very first time 85 (WEB_Session web_session) -> WEB_Step_Session start, //start function to call at very first time
81 List(WEB_Step) steps //All available steps in stepper 86 List(WEB_Step) steps //All available steps in stepper
82 //Step_Session session 87 //Step_Session session