aboutsummaryrefslogtreecommitdiffstats
path: root/util/adhoc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/adhoc.lua')
-rw-r--r--util/adhoc.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/util/adhoc.lua b/util/adhoc.lua
index d81b8242..a0ad52bb 100644
--- a/util/adhoc.lua
+++ b/util/adhoc.lua
@@ -2,7 +2,7 @@
local function new_simple_form(form, result_handler)
return function(self, data, state)
- if state then
+ if state or data.form then
if data.action == "cancel" then
return { status = "canceled" };
end
@@ -16,15 +16,21 @@ end
local function new_initial_data_form(form, initial_data, result_handler)
return function(self, data, state)
- if state then
+ if state or data.form then
if data.action == "cancel" then
return { status = "canceled" };
end
local fields, err = form:data(data.form);
return result_handler(fields, err, data);
else
+ local values, err = initial_data(data);
+ if type(err) == "table" then
+ return {status = "error"; error = err}
+ elseif type(err) == "string" then
+ return {status = "error"; error = {type = "cancel"; condition = "internal-server-error", err}}
+ end
return { status = "executing", actions = {"next", "complete", default = "complete"},
- form = { layout = form, values = initial_data(data) } }, "executing";
+ form = { layout = form, values = values } }, "executing";
end
end
end