| 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@1463
 | 
     7 ui.grid{ content = function()
 | 
| 
bsw@194
 | 
     8 
 | 
| 
bsw@1463
 | 
     9   ui.cell_main{ content = function()
 | 
| 
bsw@1463
 | 
    10     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw@1463
 | 
    11       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw@1463
 | 
    12         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = policy and policy.name or _"New policy" }
 | 
| 
bsw@1463
 | 
    13       end }
 | 
| 
bsw@1463
 | 
    14       ui.container{ attr = { class = "mdl-card__content" }, content = function()
 | 
| 
bsw@1463
 | 
    15         ui.form{
 | 
| 
bsw@1463
 | 
    16           attr = { class = "vertical" },
 | 
| 
bsw@1463
 | 
    17           record = policy,
 | 
| 
bsw@1045
 | 
    18           module = "admin",
 | 
| 
bsw@1463
 | 
    19           action = "policy_update",
 | 
| 
bsw@1463
 | 
    20           routing = {
 | 
| 
bsw@1463
 | 
    21             default = {
 | 
| 
bsw@1463
 | 
    22               mode = "redirect",
 | 
| 
bsw@1463
 | 
    23               module = "admin",
 | 
| 
bsw@1463
 | 
    24               view = "index"
 | 
| 
bsw@1463
 | 
    25             }
 | 
| 
bsw@1463
 | 
    26           },
 | 
| 
bsw@1463
 | 
    27           id = policy.id,
 | 
| 
bsw@1463
 | 
    28           content = function()
 | 
| 
bsw@194
 | 
    29 
 | 
| 
bsw@1463
 | 
    30             ui.field.text{ label = _"Index",        name = "index", value = hint and "1" or nil }
 | 
| 
bsw@194
 | 
    31 
 | 
| 
bsw@1463
 | 
    32             ui.field.text{ label = _"Name",        name = "name" }
 | 
| 
bsw@1463
 | 
    33             ui.field.text{ label = _"Description", name = "description", multiline = true }
 | 
| 
bsw@1463
 | 
    34             ui.field.text{ label = _"Hint",        readonly = true, 
 | 
| 
bsw@1463
 | 
    35                             value = _"Interval format:" .. " 3 mons 2 weeks 1 day 10:30:15" }
 | 
| 
bsw@194
 | 
    36 
 | 
| 
bsw@1463
 | 
    37             ui.field.text{ label = _"Minimum admission time",     name = "min_admission_time", value = hint and "0" or nil }
 | 
| 
bsw@1463
 | 
    38             ui.field.text{ label = _"Maximum admission time",     name = "max_admission_time", value = hint and "30 days" or nil }
 | 
| 
bsw@1463
 | 
    39             ui.field.text{ label = _"Discussion time",    name = "discussion_time", value = hint and "30 days" or nil }
 | 
| 
bsw@1463
 | 
    40             ui.field.text{ label = _"Verification time",  name = "verification_time", value = hint and "15 days" or nil }
 | 
| 
bsw@1463
 | 
    41             ui.field.text{ label = _"Voting time",        name = "voting_time", value = hint and "15 days" or nil }
 | 
| 
bsw@194
 | 
    42 
 | 
| 
bsw@1463
 | 
    43             ui.field.text{ label = _"Issue quorum",   name = "issue_quorum", value = hint and "1" or nil }
 | 
| 
bsw@1463
 | 
    44             ui.field.text{ label = _"Issue quorum numerator",   name = "issue_quorum_num", value = hint and "1" or nil }
 | 
| 
bsw@1463
 | 
    45             ui.field.text{ label = _"Issue quorum denominator",   name = "issue_quorum_den", value = hint and "10" or nil }
 | 
| 
bsw@1045
 | 
    46 
 | 
| 
bsw@1463
 | 
    47             ui.field.text{ label = _"Initiative quorum absolute",   name = "initiative_quorum", value = hint and "1" or nil }
 | 
| 
bsw@1463
 | 
    48             ui.field.text{ label = _"Initiative quorum numerator",   name = "initiative_quorum_num", value = hint and "10" or nil }
 | 
| 
bsw@1463
 | 
    49             ui.field.text{ label = _"Initiative quorum denominator", name = "initiative_quorum_den", value = hint and "100" or nil }
 | 
| 
bsw@194
 | 
    50 
 | 
| 
bsw@1463
 | 
    51             ui.field.text{ label = _"Direct majority numerator",   name = "direct_majority_num", value = hint and "50" or nil }
 | 
| 
bsw@1463
 | 
    52             ui.field.text{ label = _"Direct majority denominator", name = "direct_majority_den", value = hint and "100" or nil }
 | 
| 
bsw@1463
 | 
    53             ui.field.boolean{ label = _"Strict direct majority", name = "direct_majority_strict", value = hint and true or nil }
 | 
| 
bsw@1463
 | 
    54             ui.field.text{ label = _"Direct majority positive",   name = "direct_majority_positive", value = hint and "0" or nil }
 | 
| 
bsw@1463
 | 
    55             ui.field.text{ label = _"Direct majority non negative", name = "direct_majority_non_negative", value = hint and "0" or nil }
 | 
| 
bsw@194
 | 
    56 
 | 
| 
bsw@1463
 | 
    57             ui.field.text{ label = _"Indirect majority numerator",   name = "indirect_majority_num", value = hint and "50" or nil }
 | 
| 
bsw@1463
 | 
    58             ui.field.text{ label = _"Indirect majority denominator", name = "indirect_majority_den", value = hint and "100" or nil }
 | 
| 
bsw@1463
 | 
    59             ui.field.boolean{ label = _"Strict indirect majority", name = "indirect_majority_strict", value = hint and true or nil }
 | 
| 
bsw@1463
 | 
    60             ui.field.text{ label = _"Indirect majority positive",   name = "indirect_majority_positive", value = hint and "0" or nil }
 | 
| 
bsw@1463
 | 
    61             ui.field.text{ label = _"Indirect majority non negative", name = "indirect_majority_non_negative", value = hint and "0" or nil }
 | 
| 
bsw@282
 | 
    62 
 | 
| 
bsw@1463
 | 
    63             ui.field.boolean{ label = _"No reverse beat path", name = "no_reverse_beat_path", value = hint and false or nil }
 | 
| 
bsw@1463
 | 
    64             ui.field.boolean{ label = _"No multistage majority", name = "no_multistage_majority", value = hint and false or nil }
 | 
| 
bsw@1463
 | 
    65             ui.field.boolean{ label = _"Polling mode", name = "polling", value = hint and false or nil }
 | 
| 
bsw@282
 | 
    66 
 | 
| 
bsw@194
 | 
    67 
 | 
| 
bsw@1463
 | 
    68             ui.field.boolean{ label = _"Active?", name = "active", value = hint and true or nil }
 | 
| 
bsw@194
 | 
    69 
 | 
| 
bsw@1464
 | 
    70             ui.submit{ 
 | 
| 
bsw@1464
 | 
    71               attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
 | 
| 
bsw@1464
 | 
    72               text = _"update policy" 
 | 
| 
bsw@1464
 | 
    73             }
 | 
| 
bsw@1463
 | 
    74             slot.put(" ")
 | 
| 
bsw@1464
 | 
    75             ui.link { 
 | 
| 
bsw@1464
 | 
    76               attr = { class = "mdl-button mdl-js-button" },
 | 
| 
bsw@1464
 | 
    77               module = "admin", view = "index", content = _"cancel" 
 | 
| 
bsw@1464
 | 
    78             }
 | 
| 
bsw@1463
 | 
    79           end
 | 
| 
bsw@1463
 | 
    80         }
 | 
| 
bsw@1463
 | 
    81       end }
 | 
| 
bsw@1463
 | 
    82     end }
 | 
| 
bsw@1463
 | 
    83   end }
 | 
| 
bsw@1463
 | 
    84 end }
 |