liquid_feedback_frontend
diff app/main/initiative/new.lua @ 901:f3d6d08b0125
Added support for creating free timed issues in poll mode
| author | bsw |
|---|---|
| date | Tue Aug 21 01:16:03 2012 +0200 (2012-08-21) |
| parents | ae9ab3edff89 |
| children | dd6c00eb215f |
line diff
1.1 --- a/app/main/initiative/new.lua Tue Aug 21 00:33:17 2012 +0200 1.2 +++ b/app/main/initiative/new.lua Tue Aug 21 01:16:03 2012 +0200 1.3 @@ -11,12 +11,34 @@ 1.4 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec() 1.5 end 1.6 1.7 +local policy_id = param.get("policy_id", atom.integer) 1.8 +local policy 1.9 + 1.10 +if policy_id then 1.11 + policy = Policy:by_id(policy_id) 1.12 +end 1.13 + 1.14 if issue_id then 1.15 ui.title(_"Add alternative initiative to issue") 1.16 else 1.17 ui.title(_"Create new issue") 1.18 end 1.19 1.20 +if not issue_id and app.session.member:has_polling_right_for_unit_id(area.unit_id) then 1.21 + ui.actions(function() 1.22 + for i, policy in ipairs(area.allowed_policies) do 1.23 + if policy.polling then 1.24 + ui.link{ 1.25 + text = policy.name, 1.26 + module = "initiative", view = "new", params = { 1.27 + area_id = area.id, policy_id = policy.id 1.28 + } 1.29 + } 1.30 + end 1.31 + end 1.32 + end) 1.33 +end 1.34 + 1.35 ui.form{ 1.36 module = "initiative", 1.37 action = "create", 1.38 @@ -31,6 +53,29 @@ 1.39 slot.put("<br />") 1.40 if issue_id then 1.41 ui.field.text{ label = _"Issue", value = issue_id } 1.42 + elseif policy_id then 1.43 + ui.field.hidden{ name = "policy_id", value = policy.id } 1.44 + ui.field.text{ label = _"Policy", value = policy.name } 1.45 + if policy.free_timeable then 1.46 + local available_timings 1.47 + if config.free_timing and config.free_timing.available_func then 1.48 + available_timings = config.free_timing.available_func(policy) 1.49 + if available_timings == false then 1.50 + error("error in free timing config") 1.51 + end 1.52 + end 1.53 + if available_timings then 1.54 + ui.field.select{ 1.55 + label = _"Free timing", 1.56 + name = _"free_timing", 1.57 + foreign_records = available_timings, 1.58 + foreign_id = "id", 1.59 + foreign_name = "name" 1.60 + } 1.61 + else 1.62 + ui.field.text{ label = _"Free timing", name = "free_timing" } 1.63 + end 1.64 + end 1.65 else 1.66 tmp = { { id = -1, name = _"Please choose a policy" } } 1.67 for i, allowed_policy in ipairs(area.allowed_policies) do