liquid_feedback_frontend
view app/main/index/_head.lua @ 1663:05d2f46c60c5
Fixed cancel link in preview
| author | bsw | 
|---|---|
| date | Mon Feb 15 14:20:07 2021 +0100 (2021-02-15) | 
| parents | 22398d337507 | 
| children | 446d2798f424 | 
 line source
     1 local unit_id = config.single_unit_id or request.get_param{ name = "unit" }
     2 local area_id = config.single_area_id or request.get_param{ name = "area" }
     4 local initiative = param.get("initiative", "table")
     5 local issue = param.get("issue", "table")
     6 if issue then
     7   area_id = issue.area_id
     8   unit_id = issue.area.unit_id
     9 end
    11 if unit_id == "all" then
    12   unit_id = nil 
    13   area_id = nil
    14 end
    15 local unit
    16 if unit_id then
    17   unit = Unit:by_id(unit_id)
    18 end
    19 if area_id == "all" then
    20   area_id = nil
    21 end
    22 local area
    23 if area_id then
    24   area = Area:by_id(area_id)
    25 end
    27 if unit then
    28   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    29     ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    30       ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
    31       if unit.description and #(unit.description) > 0 then
    32         ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description }
    33       end
    34       if config.render_external_reference_unit then
    35         config.render_external_reference_unit(unit)
    36       end
    37     end }
    40     if not (config.voting_only and config.disable_delegations) and app.session.member_id and (
    41       app.session.member:has_voting_right_for_unit_id(unit.id) 
    42       or app.session.member:has_initiative_right_for_unit_id(unit.id) 
    43     ) then
    44       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    46         unit:load_delegation_info_once_for_member_id(app.session.member_id)
    48         local text
    49         if unit.delegation_info.own_delegation_scope == "unit" then
    50           local member = Member:by_id(unit.delegation_info.first_trustee_id)
    51           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    52           execute.view{
    53             module = "member",
    54             view = "_show_thumb",
    55             params = {
    56               member = member
    57             }
    58           }
    59           text = _"change delegation..."
    60         else
    61           text = _"delegate..."
    62         end
    64         ui.link {
    65           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
    66           module = "delegation", view = "show", params = {
    67             unit_id = unit.id,
    68           },
    69           content = text
    70         }
    72       end }
    73     end
    74   end }
    75 end
    77 if area then
    79   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    80     if unit then
    81       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    82         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
    83         if area.description and #(area.description) > 0 then
    84           ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description }
    85         end
    86       end }
    87     end
    88     if not (config.voting_only and config.disable_delegations) and app.session.member_id and (
    89       app.session.member:has_voting_right_for_unit_id(area.unit_id) 
    90       or app.session.member:has_initiative_right_for_unit_id(area.unit_id) 
    91     ) then
    92       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    94         area:load_delegation_info_once_for_member_id(app.session.member_id)
    96         local text
    97         if area.delegation_info.own_delegation_scope == "area" then
    98           local member = Member:by_id(area.delegation_info.first_trustee_id)
    99           if member then
   100             ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
   101             execute.view{
   102               module = "member",
   103               view = "_show_thumb",
   104               params = {
   105                 member = member
   106               }
   107             }
   108           else
   109             ui.tag{ content = _"Delegation abandoned" }
   110           end
   111           text = _"change delegation..."
   112         else
   113           text = _"delegate..."  
   114         end
   116         ui.link {
   117           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   118           module = "delegation", view = "show", params = {
   119             area_id = area.id,
   120           },
   121           content = text
   122         }
   124         if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
   125           ui.link {
   126             attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   127             module = "draft", view = "new",
   128             params = { area_id = area.id },
   129             content = function()
   130               ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
   131               ui.tag{ content = _"new issue" }
   132             end
   133           }
   134         end
   135       end }
   136     end
   137   end }
   138 end
