| rev | line source | 
| bsw@194 | 1 local policy = Policy:by_id(param.get_id()) or Policy:new() | 
| bsw@194 | 2 | 
| bsw@1045 | 3 local hint = not policy.id | 
| bsw@1045 | 4 | 
| bsw@1184 | 5 ui.titleAdmin(_"Policy") | 
| bsw@1045 | 6 | 
| bsw@1045 | 7 ui.section( function() | 
| bsw@194 | 8 | 
| bsw@1045 | 9   ui.sectionHead( function() | 
| bsw@1184 | 10     ui.heading { level = 1, content = policy and policy.name or _"New policy" } | 
| bsw@1045 | 11   end ) | 
| bsw@1045 | 12   ui.sectionRow( function() | 
| bsw@1045 | 13     ui.form{ | 
| bsw@1045 | 14       attr = { class = "vertical" }, | 
| bsw@1045 | 15       record = policy, | 
| bsw@194 | 16       module = "admin", | 
| bsw@1045 | 17       action = "policy_update", | 
| bsw@1045 | 18       routing = { | 
| bsw@1045 | 19         default = { | 
| bsw@1045 | 20           mode = "redirect", | 
| bsw@1045 | 21           module = "admin", | 
| bsw@1045 | 22           view = "index" | 
| bsw@1045 | 23         } | 
| bsw@1045 | 24       }, | 
| bsw@1045 | 25       id = policy.id, | 
| bsw@1045 | 26       content = function() | 
| bsw@194 | 27 | 
| bsw@1045 | 28         ui.field.text{ label = _"Index",        name = "index", value = hint and "1" or nil } | 
| bsw@194 | 29 | 
| bsw@1045 | 30         ui.field.text{ label = _"Name",        name = "name" } | 
| bsw@1045 | 31         ui.field.text{ label = _"Description", name = "description", multiline = true } | 
| bsw@1045 | 32         ui.field.text{ label = _"Hint",        readonly = true, | 
| bsw@1045 | 33                         value = _"Interval format:" .. " 3 mons 2 weeks 1 day 10:30:15" } | 
| bsw@194 | 34 | 
| bsw@1045 | 35         ui.field.text{ label = _"Admission time",     name = "admission_time", value = hint and "30 days" or nil } | 
| bsw@1045 | 36         ui.field.text{ label = _"Discussion time",    name = "discussion_time", value = hint and "30 days" or nil } | 
| bsw@1045 | 37         ui.field.text{ label = _"Verification time",  name = "verification_time", value = hint and "15 days" or nil } | 
| bsw@1045 | 38         ui.field.text{ label = _"Voting time",        name = "voting_time", value = hint and "15 days" or nil } | 
| bsw@194 | 39 | 
| bsw@1045 | 40         ui.field.text{ label = _"Issue quorum numerator",   name = "issue_quorum_num", value = hint and "10" or nil } | 
| bsw@1045 | 41         ui.field.text{ label = _"Issue quorum denominator", name = "issue_quorum_den", value = hint and "100" or nil } | 
| bsw@1045 | 42 | 
| bsw@1045 | 43         ui.field.text{ label = _"Initiative quorum numerator",   name = "initiative_quorum_num", value = hint and "10" or nil } | 
| bsw@1045 | 44         ui.field.text{ label = _"Initiative quorum denominator", name = "initiative_quorum_den", value = hint and "100" or nil } | 
| bsw@194 | 45 | 
| bsw@1045 | 46         ui.field.text{ label = _"Direct majority numerator",   name = "direct_majority_num", value = hint and "50" or nil } | 
| bsw@1045 | 47         ui.field.text{ label = _"Direct majority denominator", name = "direct_majority_den", value = hint and "100" or nil } | 
| bsw@1045 | 48         ui.field.boolean{ label = _"Strict direct majority", name = "direct_majority_strict", value = hint and true or nil } | 
| bsw@1045 | 49         ui.field.text{ label = _"Direct majority positive",   name = "direct_majority_positive", value = hint and "0" or nil } | 
| bsw@1045 | 50         ui.field.text{ label = _"Direct majority non negative", name = "direct_majority_non_negative", value = hint and "0" or nil } | 
| bsw@194 | 51 | 
| bsw@1045 | 52         ui.field.text{ label = _"Indirect majority numerator",   name = "indirect_majority_num", value = hint and "50" or nil } | 
| bsw@1045 | 53         ui.field.text{ label = _"Indirect majority denominator", name = "indirect_majority_den", value = hint and "100" or nil } | 
| bsw@1045 | 54         ui.field.boolean{ label = _"Strict indirect majority", name = "indirect_majority_strict", value = hint and true or nil } | 
| bsw@1045 | 55         ui.field.text{ label = _"Indirect majority positive",   name = "indirect_majority_positive", value = hint and "0" or nil } | 
| bsw@1045 | 56         ui.field.text{ label = _"Indirect majority non negative", name = "indirect_majority_non_negative", value = hint and "0" or nil } | 
| bsw@282 | 57 | 
| bsw@1045 | 58         ui.field.boolean{ label = _"No reverse beat path", name = "no_reverse_beat_path", value = hint and false or nil } | 
| bsw@1045 | 59         ui.field.boolean{ label = _"No multistage majority", name = "no_multistage_majority", value = hint and false or nil } | 
| bsw@1045 | 60         ui.field.boolean{ label = _"Polling mode", name = "polling", value = hint and false or nil } | 
| bsw@282 | 61 | 
| bsw@194 | 62 | 
| bsw@1045 | 63         ui.field.boolean{ label = _"Active?", name = "active", value = hint and true or nil } | 
| bsw@194 | 64 | 
| bsw@1045 | 65         ui.submit{ text = _"update policy" } | 
| bsw@1045 | 66         slot.put(" ") | 
| bsw@1045 | 67         ui.link { module = "admin", view = "index", content = _"cancel" } | 
| bsw@1045 | 68       end | 
| bsw@1045 | 69     } | 
| bsw@1045 | 70   end ) | 
| bsw@1045 | 71 end ) |