| 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@1234
 | 
    35         ui.field.text{ label = _"Minimum admission time",     name = "min_admission_time", value = hint and "0" or nil }
 | 
| 
bsw@1236
 | 
    36         ui.field.text{ label = _"Maximum admission time",     name = "max_admission_time", value = hint and "30 days" or nil }
 | 
| 
bsw@1045
 | 
    37         ui.field.text{ label = _"Discussion time",    name = "discussion_time", value = hint and "30 days" or nil }
 | 
| 
bsw@1045
 | 
    38         ui.field.text{ label = _"Verification time",  name = "verification_time", value = hint and "15 days" or nil }
 | 
| 
bsw@1045
 | 
    39         ui.field.text{ label = _"Voting time",        name = "voting_time", value = hint and "15 days" or nil }
 | 
| 
bsw@194
 | 
    40 
 | 
| 
bsw@1045
 | 
    41         ui.field.text{ label = _"Issue quorum numerator",   name = "issue_quorum_num", value = hint and "10" or nil }
 | 
| 
bsw@1045
 | 
    42         ui.field.text{ label = _"Issue quorum denominator", name = "issue_quorum_den", value = hint and "100" or nil }
 | 
| 
bsw@1045
 | 
    43 
 | 
| 
bsw@1045
 | 
    44         ui.field.text{ label = _"Initiative quorum numerator",   name = "initiative_quorum_num", value = hint and "10" or nil }
 | 
| 
bsw@1045
 | 
    45         ui.field.text{ label = _"Initiative quorum denominator", name = "initiative_quorum_den", value = hint and "100" or nil }
 | 
| 
bsw@194
 | 
    46 
 | 
| 
bsw@1045
 | 
    47         ui.field.text{ label = _"Direct majority numerator",   name = "direct_majority_num", value = hint and "50" or nil }
 | 
| 
bsw@1045
 | 
    48         ui.field.text{ label = _"Direct majority denominator", name = "direct_majority_den", value = hint and "100" or nil }
 | 
| 
bsw@1045
 | 
    49         ui.field.boolean{ label = _"Strict direct majority", name = "direct_majority_strict", value = hint and true or nil }
 | 
| 
bsw@1045
 | 
    50         ui.field.text{ label = _"Direct majority positive",   name = "direct_majority_positive", value = hint and "0" or nil }
 | 
| 
bsw@1045
 | 
    51         ui.field.text{ label = _"Direct majority non negative", name = "direct_majority_non_negative", value = hint and "0" or nil }
 | 
| 
bsw@194
 | 
    52 
 | 
| 
bsw@1045
 | 
    53         ui.field.text{ label = _"Indirect majority numerator",   name = "indirect_majority_num", value = hint and "50" or nil }
 | 
| 
bsw@1045
 | 
    54         ui.field.text{ label = _"Indirect majority denominator", name = "indirect_majority_den", value = hint and "100" or nil }
 | 
| 
bsw@1045
 | 
    55         ui.field.boolean{ label = _"Strict indirect majority", name = "indirect_majority_strict", value = hint and true or nil }
 | 
| 
bsw@1045
 | 
    56         ui.field.text{ label = _"Indirect majority positive",   name = "indirect_majority_positive", value = hint and "0" or nil }
 | 
| 
bsw@1045
 | 
    57         ui.field.text{ label = _"Indirect majority non negative", name = "indirect_majority_non_negative", value = hint and "0" or nil }
 | 
| 
bsw@282
 | 
    58 
 | 
| 
bsw@1045
 | 
    59         ui.field.boolean{ label = _"No reverse beat path", name = "no_reverse_beat_path", value = hint and false or nil }
 | 
| 
bsw@1045
 | 
    60         ui.field.boolean{ label = _"No multistage majority", name = "no_multistage_majority", value = hint and false or nil }
 | 
| 
bsw@1045
 | 
    61         ui.field.boolean{ label = _"Polling mode", name = "polling", value = hint and false or nil }
 | 
| 
bsw@282
 | 
    62 
 | 
| 
bsw@194
 | 
    63 
 | 
| 
bsw@1045
 | 
    64         ui.field.boolean{ label = _"Active?", name = "active", value = hint and true or nil }
 | 
| 
bsw@194
 | 
    65 
 | 
| 
bsw@1045
 | 
    66         ui.submit{ text = _"update policy" }
 | 
| 
bsw@1045
 | 
    67         slot.put(" ")
 | 
| 
bsw@1045
 | 
    68         ui.link { module = "admin", view = "index", content = _"cancel" }
 | 
| 
bsw@1045
 | 
    69       end
 | 
| 
bsw@1045
 | 
    70     }
 | 
| 
bsw@1045
 | 
    71   end )
 | 
| 
bsw@1236
 | 
    72 end )
 |