liquid_feedback_frontend
view app/main/index/_head.lua @ 1596:9f55297a1a6a
Reworked subject area delegation buttons
| author | bsw | 
|---|---|
| date | Sun Jan 31 20:35:05 2021 +0100 (2021-01-31) | 
| parents | 3c15fea3f1c0 | 
| children | 6b203b43bef3 | 
 line source
     1 local unit_id = config.single_unit_id or tonumber(request.get_param{ name = "unit" })
     2 if unit_id == "all" then
     3   unit_id = nil 
     4 end
     5 local unit
     6 if unit_id then
     7   unit = Unit:by_id(unit_id)
     8 end
     9 local area_id = config.single_area_id or tonumber(request.get_param{ name = "area" })
    10 if area_id == "all" then
    11   area_id = nil
    12 end
    13 local area
    14 if area_id then
    15   area = Area:by_id(area_id)
    16 end
    17 if area then
    18   if app.session.member_id then
    19     area:load_delegation_info_once_for_member_id(app.session.member_id)
    20   end
    22   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    23     if unit then
    24       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    25         if not config.single_area_id then
    26           ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name .. " ยป " .. area.name }
    27         else
    28           ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
    29         end
    30       end }
    31     end
    32     if area.description and #(area.description) > 0 then
    33       if not config.single_area_id then
    34         ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = area.description }
    35       else
    36         ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = unit.description }
    37       end
    38     end
    39     if not (config.voting_only and config.disable_delegations) and app.session.member_id then
    40       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    42         if not config.disable_delegations then
    44           if area.delegation_info.first_trustee_id then
    45             local member = Member:by_id(area.delegation_info.first_trustee_id)
    46             ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    47             execute.view{
    48               module = "member",
    49               view = "_show_thumb",
    50               params = {
    51                 member = member
    52               }
    53             }
    54           end
    56           local text
    57           if area.delegation_info.own_delegation_scope == nil then
    58             text = _"delegate..."  
    59           else
    60             text = _"change delegation..."
    61           end
    64           ui.tag{ attr = { id = "change_delegation", class = "mdl-button" }, content = text }
    67           ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = "change_delegation" }, content = function()
    69             ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
    70               ui.link {
    71                 attr = { class = "mdl-menu__link" },
    72                 module = "delegation", view = "show", params = {
    73                   unit_id = area.unit_id,
    74                 },
    75                 content = _("unit: #{name}", { name = area.unit.name })
    76               }
    77             end }
    79             ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
    80               ui.link {
    81                 attr = { class = "mdl-menu__link" },
    82                 module = "delegation", view = "show", params = {
    83                   area_id = area.id
    84                 },
    85                 content = _("subject area: #{name}", { name = area.name })
    86               }
    87             end }
    88           end }
    89         end
    91         if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
    92           ui.link {
    93             attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
    94             module = "draft", view = "new",
    95             params = { area_id = area.id },
    96             content = function()
    97               ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
    98               ui.tag{ content = _"new issue" }
    99             end
   100           }
   101         end
   102       end }
   103     end
   104   end }
   105 elseif unit then
   106   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   107     ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   108       ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
   109     end }
   110     if unit.description and #(unit.description) > 0 then
   111       ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = unit.description }
   112     end
   113     if config.render_external_reference_unit then
   114       config.render_external_reference_unit(unit)
   115     end
   116     --ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function()
   117     --end }
   118   end }
   119 else
   120   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   121     ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   122       ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"All issues" }
   123     end }
   124     ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = _"All issues in your units. Use filters above to limit results." }
   125   end }
   126 end
