# HG changeset patch # User bsw # Date 1413543811 -7200 # Node ID 5b65ea5c24f53d3e6139a8a57733b74a5034c694 # Parent 20680a81c3e1657a25c848159dda790f3d1b1280 Fixed free timings in poll mode diff -r 20680a81c3e1 -r 5b65ea5c24f5 app/main/initiative/_action/create.lua --- a/app/main/initiative/_action/create.lua Fri Oct 17 11:30:09 2014 +0200 +++ b/app/main/initiative/_action/create.lua Fri Oct 17 13:03:31 2014 +0200 @@ -98,11 +98,42 @@ end end +local timing +if policy.free_timeable then + local free_timing_string = util.trim(param.get("free_timing")) + if not free_timing_string or #free_timing_string < 1 then + slot.put_into("error", _"Choose timing") + return false + end + local available_timings + if config.free_timing and config.free_timing.available_func then + available_timings = config.free_timing.available_func(policy) + if available_timings == false then + error("error in free timing config") + end + end + if available_timings then + local timing_available = false + for i, available_timing in ipairs(available_timings) do + if available_timing.id == free_timing_string then + timing_available = true + end + end + if not timing_available then + slot.put_into("error", _"Invalid timing") + return false + end + end + timing = config.free_timing.calculate_func(policy, free_timing_string) + if not timing then + error("error in free timing config") + end +end + if param.get("preview") or param.get("edit") then return end - local initiative = Initiative:new() if not issue then @@ -116,29 +147,6 @@ initiative.polling = true if policy.free_timeable then - local free_timing_string = util.trim(param.get("free_timing")) - local available_timings - if config.free_timing and config.free_timing.available_func then - available_timings = config.free_timing.available_func(policy) - if available_timings == false then - error("error in free timing config") - end - end - if available_timings then - local timing_available = false - for i, available_timing in ipairs(available_timings) do - if available_timing.id == free_timing_string then - timing_available = true - end - end - if not timing_available then - error('Invalid timing') - end - end - local timing = config.free_timing.calculate_func(policy, free_timing_string) - if not timing then - error("error in free timing config") - end issue.discussion_time = timing.discussion issue.verification_time = timing.verification issue.voting_time = timing.voting diff -r 20680a81c3e1 -r 5b65ea5c24f5 app/main/initiative/new.lua --- a/app/main/initiative/new.lua Fri Oct 17 11:30:09 2014 +0200 +++ b/app/main/initiative/new.lua Fri Oct 17 13:03:31 2014 +0200 @@ -75,12 +75,16 @@ if not issue then ui.container { content = policy.name } end + if param.get("free_timing") then + ui.container { content = param.get("free_timing") } + end slot.put("
") ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") } ui.field.hidden{ name = "policy_id", value = param.get("policy_id") } ui.field.hidden{ name = "name", value = param.get("name") } ui.field.hidden{ name = "draft", value = param.get("draft") } + ui.field.hidden{ name = "free_timing", value = param.get("free_timing") } local formatting_engine if config.enforce_formatting_engine then formatting_engine = config.enforce_formatting_engine @@ -165,30 +169,28 @@ value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id } if policy and policy.free_timeable then - ui.sectionRow( function() - local available_timings - if config.free_timing and config.free_timing.available_func then - available_timings = config.free_timing.available_func(policy) - if available_timings == false then - error("error in free timing config") - end - end - ui.heading{ level = 4, content = _"Free timing:" } - if available_timings then - ui.field.select{ - name = "free_timing", - foreign_records = available_timings, - foreign_id = "id", - foreign_name = "name", - value = param.get("free_timing") - } - else - ui.field.text{ - name = "free_timing", - value = param.get("free_timing") - } - end - end ) + local available_timings + if config.free_timing and config.free_timing.available_func then + available_timings = config.free_timing.available_func(policy) + if available_timings == false then + error("error in free timing config") + end + end + ui.heading{ level = 4, content = _"Free timing:" } + if available_timings then + ui.field.select{ + name = "free_timing", + foreign_records = available_timings, + foreign_id = "id", + foreign_name = "name", + value = param.get("free_timing") + } + else + ui.field.text{ + name = "free_timing", + value = param.get("free_timing") + } + end end end