comparison mod_adhoc_dataforms_demo/mod_adhoc_dataforms_demo.lua @ 4050:1eb2b9483081

mod_adhoc_dataforms_demo: Treat 'execute' action as 'next' except in first step
author Kim Alvefur <zash@zash.se>
date Tue, 23 Jun 2020 19:54:06 +0200
parents 78f1de5301fc
children 3e2e708fd18b
comparison
equal deleted inserted replaced
4049:78f1de5301fc 4050:1eb2b9483081
132 status = "completed", 132 status = "completed",
133 info = "State was:\n" 133 info = "State was:\n"
134 .. serialization.serialize(state, { fatal = false }), 134 .. serialization.serialize(state, { fatal = false }),
135 }; 135 };
136 end 136 end
137 if state and data.action == "execute" then
138 data.action = "next";
139 elseif not state and data.action == "next" then
140 -- Prevent jumping directly to step 2
141 return { status = "canceled", error = "Invalid action" };
142 end
137 state = state or { step = 1, forms = { } }; 143 state = state or { step = 1, forms = { } };
138 144
139 if data.action == "next" then 145 if data.action == "next" then
140 state.step = state.step + 1; 146 state.step = state.step + 1;
141 elseif data.action == "prev" then 147 elseif data.action == "prev" then
161 end 167 end
162 168
163 local next_step = { 169 local next_step = {
164 status = "executing", 170 status = "executing",
165 form = current_form, 171 form = current_form,
172 default = "next",
166 actions = { 173 actions = {
167 "next", "complete" 174 "next", "complete"
168 }, 175 },
169 }; 176 };
170 if state.step > 1 then 177 if state.step > 1 then