bsw@1484: local function field(name, label, value, tooltip) bsw@1484: ui.field.text{ bsw@1484: container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, bsw@1484: attr = { id = "field_" .. name, class = "mdl-textfield__input" }, bsw@1484: label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name }, bsw@1484: label = label, bsw@1484: name = name, bsw@1484: value = value or nil bsw@1484: } bsw@1484: if tooltip then bsw@1484: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip } bsw@1484: end bsw@1484: end bsw@1484: bsw@1484: local function rational_field(name, label, value_num, value_den, tooltip) bsw@1484: bsw@1484: ui.container{ bsw@1484: attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, bsw@1484: content = function() bsw@1484: ui.tag{ bsw@1484: attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name }, bsw@1484: content = label bsw@1484: } bsw@1484: ui.field.text{ bsw@1484: container_attr = { style = "display: inline-block;" }, bsw@1484: attr = { style = "width: 3em;", id = "field_" .. name .. "_num", class = "mdl-textfield__input" }, bsw@1484: name = name .. "_num", bsw@1484: value = value_num or nil bsw@1484: } bsw@1484: slot.put(" / ") bsw@1484: ui.field.text{ bsw@1484: container_attr = { style = "display: inline-block;" }, bsw@1484: attr = { style = "width: 3em;", id = "field_" .. name .. "_den", class = "mdl-textfield__input" }, bsw@1484: name = name .. "_den", bsw@1484: value = value_den or nil bsw@1484: } bsw@1484: end bsw@1484: } bsw@1484: if tooltip then bsw@1484: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name .. "_num" }, content = tooltip } bsw@1484: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name .. "_den" }, content = tooltip } bsw@1484: end bsw@1484: end bsw@1484: bsw@1484: local function majority_field(name, label, value_num, value_den, strict, tooltip) bsw@1484: bsw@1484: ui.container{ bsw@1484: attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, bsw@1484: content = function() bsw@1484: ui.tag{ bsw@1484: attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name }, bsw@1484: content = label bsw@1484: } bsw@1484: ui.tag{ tag = "select", attr = { name = name .. "_strict" }, content = function() bsw@1484: ui.tag{ tag = "option", attr = { value = "0", selected = not strict and "selected" or nil }, content = "≥" } bsw@1484: ui.tag{ tag = "option", attr = { value = "1", selected = strict and "selected" or nil }, content = ">" } bsw@1484: end } bsw@1484: slot.put(" ") bsw@1484: ui.field.text{ bsw@1484: container_attr = { style = "display: inline-block;" }, bsw@1484: attr = { style = "width: 3em;", id = "field_" .. name .. "_num", class = "mdl-textfield__input" }, bsw@1484: name = name .. "_num", bsw@1484: value = value_num or nil bsw@1484: } bsw@1484: slot.put(" / ") bsw@1484: ui.field.text{ bsw@1484: container_attr = { style = "display: inline-block;" }, bsw@1484: attr = { style = "width: 3em;", id = "field_" .. name .. "_den", class = "mdl-textfield__input" }, bsw@1484: name = name .. "_den", bsw@1484: value = value_den or nil bsw@1484: } bsw@1484: end bsw@1484: } bsw@1484: if tooltip then bsw@1484: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name .. "_num" }, content = tooltip } bsw@1484: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name .. "_den" }, content = tooltip } bsw@1484: end bsw@1484: end bsw@1484: bsw@1484: bsw@194: local policy = Policy:by_id(param.get_id()) or Policy:new() bsw@194: bsw@1045: local hint = not policy.id bsw@1045: bsw@1184: ui.titleAdmin(_"Policy") bsw@1045: bsw@1463: ui.grid{ content = function() bsw@194: bsw@1463: ui.cell_main{ content = function() bsw@1463: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw@1463: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw@1463: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = policy and policy.name or _"New policy" } bsw@1463: end } bsw@1463: ui.container{ attr = { class = "mdl-card__content" }, content = function() bsw@1463: ui.form{ bsw@1463: attr = { class = "vertical" }, bsw@1463: record = policy, bsw@1045: module = "admin", bsw@1463: action = "policy_update", bsw@1463: routing = { bsw@1463: default = { bsw@1463: mode = "redirect", bsw@1463: module = "admin", bsw@1463: view = "index" bsw@1463: } bsw@1463: }, bsw@1463: id = policy.id, bsw@1463: content = function() bsw@194: bsw@1484: field("index", "Index (for sorting)", hint and "1" or nil) bsw@1484: ui.field.boolean{ label = _"Active?", name = "active", value = hint and true or nil } bsw@194: bsw@1484: field("name", "Name") bsw@1484: bsw@1463: ui.field.text{ label = _"Description", name = "description", multiline = true } bsw@1463: ui.field.text{ label = _"Hint", readonly = true, bsw@1463: value = _"Interval format:" .. " 3 mons 2 weeks 1 day 10:30:15" } bsw@194: bsw@1484: bsw@1484: ui.heading{ level = 5, content = _"Admission phase" } bsw@1484: field("min_admission_time", _"Minimum admission time", hint and "0" or nil, _"Minimum time an issue has to stay in admission phase before it can be accepted for discussion (if it reaches the 1st quorum).") bsw@1484: field("max_admission_time", _"Maximum admission time", hint and "30 days" or nil, _"Maximum time within which an issue has to reach the 1st quorum, otherwise it will be canceled.") bsw@1484: ui.field.boolean{ attr = { id = "field_polling" }, label = _"Polling mode", name = "polling", value = hint and false or nil } bsw@1484: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_polling" }, content = _"Skip admission phase and start issue in discussion phase (can only be started by members with polling privilege). If enabled, minimum and maximum admission time as well as 1st quorum needs to be cleared." } bsw@1484: bsw@1484: ui.heading{ level = 5, content = _"First quorum" } bsw@1484: ui.container{ content = _"Minimum supporter count (including support via delegation) one initiative of an issue has to reach to let the issue pass the 1st quorum and to proceed to discussion phase. Further requirements can occur due to per subject area issue limiter settings. See subject area settings." } bsw@1484: field("issue_quorum", _"Absolute issue quorum", hint and "1" or nil, _"Minimum absolute number of supporters.") bsw@1484: rational_field("issue_quorum", "Relative issue quorum", hint and "1" or nil, hint and "100" or nil, _"Minimum number of supporters relative to the number of active participants in the organizational unit.") bsw@1045: bsw@1484: ui.heading{ level = 5, content = _"Discussion phase" } bsw@1484: field("discussion_time", _"Discussion time", hint and "30 days" or nil, _"Duration of discussion phase of an issue.") bsw@1484: bsw@1484: ui.heading{ level = 5, content = _"Verification phase" } bsw@1484: field("verification_time", _"Verfication time", hint and "7 days" or nil, _"Duration of verification phase of an issue.") bsw@1484: bsw@1484: ui.heading{ level = 5, content = _"Second quorum" } bsw@1484: ui.container{ content = _"Minimum supporter count (including support via delegation) an initiative has to reach to be an eligible candidate for the voting phase." } bsw@1484: field("initiative_quorum", _"Absolute initiative quorum", hint and "1" or nil, _"Minimum absolute number of supporters.") bsw@1484: rational_field("initiative_quorum", "Relative initiative quorum", hint and "1" or nil, hint and "100" or nil, _"Minimum number of supporters relative to the number of active participants in the organizational unit.") bsw@194: bsw@1484: ui.heading{ level = 5, content = _"Voting phase" } bsw@1484: field("voting_time", _"Voting time", hint and "15 days" or nil, _"Duration of voting phase of an issue.") bsw@194: bsw@1484: ui.heading{ level = 5, content = _"Required majorities" } bsw@1484: majority_field("direct_majority", _"Majority", hint and "50" or nil, hint and "100" or nil, policy.direct_majority_strict, "The required majority of approval votes relative to the sum of approval and disapproval votes for the same initiative.") bsw@1484: field("direct_majority_positive", _"Absolute number of approval votes", hint and "0" or nil, _"The minimum absolute number of approval votes.") bsw@1484: field("direct_majority_non_negative", _"Absolute number of approval and abstention votes", hint and "0" or nil, _"The minimum absolute number of approval votes.") bsw@1484: bsw@1484: ui.heading{ level = 5, content = _"Experimental features" } bsw@1484: ui.container{ content = _"The following settings for experimental features should only be changed with sufficient knowledge about the Schulze method and its implementation in LiquidFeedback." } bsw@1463: ui.field.text{ label = _"Indirect majority numerator", name = "indirect_majority_num", value = hint and "50" or nil } bsw@1463: ui.field.text{ label = _"Indirect majority denominator", name = "indirect_majority_den", value = hint and "100" or nil } bsw@1463: ui.field.boolean{ label = _"Strict indirect majority", name = "indirect_majority_strict", value = hint and true or nil } bsw@1463: ui.field.text{ label = _"Indirect majority positive", name = "indirect_majority_positive", value = hint and "0" or nil } bsw@1463: ui.field.text{ label = _"Indirect majority non negative", name = "indirect_majority_non_negative", value = hint and "0" or nil } bsw@282: bsw@1463: ui.field.boolean{ label = _"No reverse beat path", name = "no_reverse_beat_path", value = hint and false or nil } bsw@1463: ui.field.boolean{ label = _"No multistage majority", name = "no_multistage_majority", value = hint and false or nil } bsw@282: bsw@1484: slot.put("
") bsw@194: bsw@1464: ui.submit{ bsw@1464: attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" }, bsw@1464: text = _"update policy" bsw@1464: } bsw@1463: slot.put(" ") bsw@1464: ui.link { bsw@1464: attr = { class = "mdl-button mdl-js-button" }, bsw@1464: module = "admin", view = "index", content = _"cancel" bsw@1464: } bsw@1463: end bsw@1463: } bsw@1463: end } bsw@1463: end } bsw@1463: end } bsw@1463: end }