liquid_feedback_frontend
changeset 1092:5b65ea5c24f5
Fixed free timings in poll mode
author | bsw |
---|---|
date | Fri Oct 17 13:03:31 2014 +0200 (2014-10-17) |
parents | 20680a81c3e1 |
children | c2baf086cc8d |
files | app/main/initiative/_action/create.lua app/main/initiative/new.lua |
line diff
1.1 --- a/app/main/initiative/_action/create.lua Fri Oct 17 11:30:09 2014 +0200 1.2 +++ b/app/main/initiative/_action/create.lua Fri Oct 17 13:03:31 2014 +0200 1.3 @@ -98,11 +98,42 @@ 1.4 end 1.5 end 1.6 1.7 +local timing 1.8 +if policy.free_timeable then 1.9 + local free_timing_string = util.trim(param.get("free_timing")) 1.10 + if not free_timing_string or #free_timing_string < 1 then 1.11 + slot.put_into("error", _"Choose timing") 1.12 + return false 1.13 + end 1.14 + local available_timings 1.15 + if config.free_timing and config.free_timing.available_func then 1.16 + available_timings = config.free_timing.available_func(policy) 1.17 + if available_timings == false then 1.18 + error("error in free timing config") 1.19 + end 1.20 + end 1.21 + if available_timings then 1.22 + local timing_available = false 1.23 + for i, available_timing in ipairs(available_timings) do 1.24 + if available_timing.id == free_timing_string then 1.25 + timing_available = true 1.26 + end 1.27 + end 1.28 + if not timing_available then 1.29 + slot.put_into("error", _"Invalid timing") 1.30 + return false 1.31 + end 1.32 + end 1.33 + timing = config.free_timing.calculate_func(policy, free_timing_string) 1.34 + if not timing then 1.35 + error("error in free timing config") 1.36 + end 1.37 +end 1.38 + 1.39 if param.get("preview") or param.get("edit") then 1.40 return 1.41 end 1.42 1.43 - 1.44 local initiative = Initiative:new() 1.45 1.46 if not issue then 1.47 @@ -116,29 +147,6 @@ 1.48 initiative.polling = true 1.49 1.50 if policy.free_timeable then 1.51 - local free_timing_string = util.trim(param.get("free_timing")) 1.52 - local available_timings 1.53 - if config.free_timing and config.free_timing.available_func then 1.54 - available_timings = config.free_timing.available_func(policy) 1.55 - if available_timings == false then 1.56 - error("error in free timing config") 1.57 - end 1.58 - end 1.59 - if available_timings then 1.60 - local timing_available = false 1.61 - for i, available_timing in ipairs(available_timings) do 1.62 - if available_timing.id == free_timing_string then 1.63 - timing_available = true 1.64 - end 1.65 - end 1.66 - if not timing_available then 1.67 - error('Invalid timing') 1.68 - end 1.69 - end 1.70 - local timing = config.free_timing.calculate_func(policy, free_timing_string) 1.71 - if not timing then 1.72 - error("error in free timing config") 1.73 - end 1.74 issue.discussion_time = timing.discussion 1.75 issue.verification_time = timing.verification 1.76 issue.voting_time = timing.voting
2.1 --- a/app/main/initiative/new.lua Fri Oct 17 11:30:09 2014 +0200 2.2 +++ b/app/main/initiative/new.lua Fri Oct 17 13:03:31 2014 +0200 2.3 @@ -75,12 +75,16 @@ 2.4 if not issue then 2.5 ui.container { content = policy.name } 2.6 end 2.7 + if param.get("free_timing") then 2.8 + ui.container { content = param.get("free_timing") } 2.9 + end 2.10 slot.put("<br />") 2.11 2.12 ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") } 2.13 ui.field.hidden{ name = "policy_id", value = param.get("policy_id") } 2.14 ui.field.hidden{ name = "name", value = param.get("name") } 2.15 ui.field.hidden{ name = "draft", value = param.get("draft") } 2.16 + ui.field.hidden{ name = "free_timing", value = param.get("free_timing") } 2.17 local formatting_engine 2.18 if config.enforce_formatting_engine then 2.19 formatting_engine = config.enforce_formatting_engine 2.20 @@ -165,30 +169,28 @@ 2.21 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id 2.22 } 2.23 if policy and policy.free_timeable then 2.24 - ui.sectionRow( function() 2.25 - local available_timings 2.26 - if config.free_timing and config.free_timing.available_func then 2.27 - available_timings = config.free_timing.available_func(policy) 2.28 - if available_timings == false then 2.29 - error("error in free timing config") 2.30 - end 2.31 - end 2.32 - ui.heading{ level = 4, content = _"Free timing:" } 2.33 - if available_timings then 2.34 - ui.field.select{ 2.35 - name = "free_timing", 2.36 - foreign_records = available_timings, 2.37 - foreign_id = "id", 2.38 - foreign_name = "name", 2.39 - value = param.get("free_timing") 2.40 - } 2.41 - else 2.42 - ui.field.text{ 2.43 - name = "free_timing", 2.44 - value = param.get("free_timing") 2.45 - } 2.46 - end 2.47 - end ) 2.48 + local available_timings 2.49 + if config.free_timing and config.free_timing.available_func then 2.50 + available_timings = config.free_timing.available_func(policy) 2.51 + if available_timings == false then 2.52 + error("error in free timing config") 2.53 + end 2.54 + end 2.55 + ui.heading{ level = 4, content = _"Free timing:" } 2.56 + if available_timings then 2.57 + ui.field.select{ 2.58 + name = "free_timing", 2.59 + foreign_records = available_timings, 2.60 + foreign_id = "id", 2.61 + foreign_name = "name", 2.62 + value = param.get("free_timing") 2.63 + } 2.64 + else 2.65 + ui.field.text{ 2.66 + name = "free_timing", 2.67 + value = param.get("free_timing") 2.68 + } 2.69 + end 2.70 end 2.71 end 2.72