liquid_feedback_frontend
view app/main/index/_head.lua @ 1621:a17ad625ffbc
Reworked member edit view
| author | bsw | 
|---|---|
| date | Sat Feb 06 22:44:34 2021 +0100 (2021-02-06) | 
| parents | a3a7120a67be | 
| children | 22398d337507 | 
 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 then
    41       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    43         unit:load_delegation_info_once_for_member_id(app.session.member_id)
    45         local text
    46         if unit.delegation_info.own_delegation_scope == "unit" then
    47           local member = Member:by_id(unit.delegation_info.first_trustee_id)
    48           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    49           execute.view{
    50             module = "member",
    51             view = "_show_thumb",
    52             params = {
    53               member = member
    54             }
    55           }
    56           text = _"change delegation..."
    57         else
    58           text = _"delegate..."
    59         end
    61         ui.link {
    62           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
    63           module = "delegation", view = "show", params = {
    64             unit_id = unit.id,
    65           },
    66           content = text
    67         }
    69       end }
    70     end
    71   end }
    72 end
    74 if area then
    76   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    77     if unit then
    78       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    79         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
    80         if area.description and #(area.description) > 0 then
    81           ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description }
    82         end
    83       end }
    84     end
    85     if not (config.voting_only and config.disable_delegations) and app.session.member_id then
    86       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    88         area:load_delegation_info_once_for_member_id(app.session.member_id)
    90         local text
    91         if area.delegation_info.own_delegation_scope == "area" then
    92           local member = Member:by_id(area.delegation_info.first_trustee_id)
    93           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    94           execute.view{
    95             module = "member",
    96             view = "_show_thumb",
    97             params = {
    98               member = member
    99             }
   100           }
   101           text = _"change delegation..."
   102         else
   103           text = _"delegate..."  
   104         end
   106         ui.link {
   107           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   108           module = "delegation", view = "show", params = {
   109             area_id = area.id,
   110           },
   111           content = text
   112         }
   114         if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
   115           ui.link {
   116             attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   117             module = "draft", view = "new",
   118             params = { area_id = area.id },
   119             content = function()
   120               ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
   121               ui.tag{ content = _"new issue" }
   122             end
   123           }
   124         end
   125       end }
   126     end
   127   end }
   128 end
