liquid_feedback_frontend
view app/main/index/_head.lua @ 1598:6b203b43bef3
Reworked unit and area head and delegation buttons
| author | bsw | 
|---|---|
| date | Sun Jan 31 22:04:30 2021 +0100 (2021-01-31) | 
| parents | 9f55297a1a6a | 
| children | d47d2b0cd7c2 | 
 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" }
     3 if unit_id == "all" then
     4   unit_id = nil 
     5   area_id = nil
     6 end
     7 local unit
     8 if unit_id then
     9   unit = Unit:by_id(unit_id)
    10 end
    11 if area_id == "all" then
    12   area_id = nil
    13 end
    14 local area
    15 if area_id then
    16   area = Area:by_id(area_id)
    17 end
    19 print(unit_id, area_id, unit, area)
    21 if unit then
    22   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    23     ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    24       ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
    25       if unit.description and #(unit.description) > 0 then
    26         ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description }
    27       end
    28       if config.render_external_reference_unit then
    29         config.render_external_reference_unit(unit)
    30       end
    31     end }
    34     if not (config.voting_only and config.disable_delegations) and app.session.member_id then
    35       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    37         unit:load_delegation_info_once_for_member_id(app.session.member_id)
    39         local text
    40         if unit.delegation_info.own_delegation_scope == "unit" then
    41           local member = Member:by_id(unit.delegation_info.first_trustee_id)
    42           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    43           execute.view{
    44             module = "member",
    45             view = "_show_thumb",
    46             params = {
    47               member = member
    48             }
    49           }
    50           text = _"change delegation..."
    51         else
    52           text = _"delegate..."
    53         end
    55         ui.link {
    56           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
    57           module = "delegation", view = "show", params = {
    58             unit_id = unit.id,
    59           },
    60           content = text
    61         }
    63       end }
    64     end
    65   end }
    66 end
    68 if area then
    70   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    71     if unit then
    72       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    73         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
    74         if area.description and #(area.description) > 0 then
    75           ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description }
    76         end
    77       end }
    78     end
    79     if not (config.voting_only and config.disable_delegations) and app.session.member_id then
    80       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    82         area:load_delegation_info_once_for_member_id(app.session.member_id)
    84         local text
    85         if area.delegation_info.own_delegation_scope == "area" then
    86           local member = Member:by_id(area.delegation_info.first_trustee_id)
    87           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    88           execute.view{
    89             module = "member",
    90             view = "_show_thumb",
    91             params = {
    92               member = member
    93             }
    94           }
    95           text = _"change delegation..."
    96         else
    97           text = _"delegate..."  
    98         end
   100         ui.link {
   101           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   102           module = "delegation", view = "show", params = {
   103             area_id = area.id,
   104           },
   105           content = text
   106         }
   108         if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
   109           ui.link {
   110             attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   111             module = "draft", view = "new",
   112             params = { area_id = area.id },
   113             content = function()
   114               ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
   115               ui.tag{ content = _"new issue" }
   116             end
   117           }
   118         end
   119       end }
   120     end
   121   end }
   122 end
