liquid_feedback_frontend
diff app/main/draft/new.lua @ 1843:b01d9920371b
merge
author | jbe |
---|---|
date | Thu Feb 03 15:57:22 2022 +0100 (2022-02-03) |
parents | 7b04f14c6d0a |
children | 71916d0badca |
line diff
1.1 --- a/app/main/draft/new.lua Thu Feb 03 15:54:23 2022 +0100 1.2 +++ b/app/main/draft/new.lua Thu Feb 03 15:57:22 2022 +0100 1.3 @@ -72,6 +72,12 @@ 1.4 return false 1.5 end 1.6 1.7 +if not initiative and not issue and #(area.allowed_policies) < 1 then 1.8 + slot.put_into("error", _"Subject area configuration invalid. Please contact the administrator.") 1.9 + return false 1.10 +end 1.11 + 1.12 + 1.13 ui.form{ 1.14 record = draft, 1.15 attr = { class = "vertical section", enctype = 'multipart/form-data' }, 1.16 @@ -128,13 +134,14 @@ 1.17 -- -------- PREVIEW 1.18 if param.get("preview") and slot.get_content("error") == "" then 1.19 ui.sectionRow( function() 1.20 - if not issue and not initiative then 1.21 + if not issue and not initiative and #area.allowed_policies > 1 then 1.22 ui.container { content = policy and policy.name or "" } 1.23 + slot.put("<br />") 1.24 end 1.25 if param.get("free_timing") then 1.26 ui.container { content = param.get("free_timing") } 1.27 + slot.put("<br />") 1.28 end 1.29 - slot.put("<br />") 1.30 ui.field.hidden{ name = "policy_id", value = param.get("policy_id") } 1.31 ui.field.hidden{ name = "name", value = param.get("name") } 1.32 if config.initiative_abstract then 1.33 @@ -253,14 +260,21 @@ 1.34 tmp[#tmp+1] = allowed_policy 1.35 end 1.36 end 1.37 - ui.container{ content = _"Please choose a policy for the new issue:" } 1.38 - ui.field.select{ 1.39 - name = "policy_id", 1.40 - foreign_records = tmp, 1.41 - foreign_id = "id", 1.42 - foreign_name = "name", 1.43 - value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id 1.44 - } 1.45 + if #area.allowed_policies > 1 then 1.46 + ui.container{ content = _"Please choose a policy for the new issue:" } 1.47 + ui.field.select{ 1.48 + name = "policy_id", 1.49 + foreign_records = tmp, 1.50 + foreign_id = "id", 1.51 + foreign_name = "name", 1.52 + value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id 1.53 + } 1.54 + else 1.55 + ui.field.hidden{ 1.56 + name = "policy_id", 1.57 + value = area.allowed_policies[1].id 1.58 + } 1.59 + end 1.60 if policy and policy.free_timeable then 1.61 local available_timings 1.62 if config.free_timing and config.free_timing.available_func then