liquid_feedback_frontend
view app/main/index/_head.lua @ 1765:8d809c49c48a
Fixed syntax error
| author | bsw | 
|---|---|
| date | Mon Oct 18 16:01:55 2021 +0200 (2021-10-18) | 
| parents | 4a5a79a37db1 | 
| children | 
 line source
     1 local unit_id = config.single_unit_id or request.get_param{ name = "unit" } or app.single_unit_id
     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     end }
    32     if unit.description and #(unit.description) > 0 then
    33       ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    34         slot.put(format.text_with_links(unit.description))
    35       end }
    36     end
    37     if config.render_external_reference_unit then
    38       ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    39         config.render_external_reference_unit(unit)
    40       end }
    41     end
    44     if not (config.voting_only and config.disable_delegations) and app.session.member_id and (
    45       app.session.member:has_voting_right_for_unit_id(unit.id) 
    46       or app.session.member:has_initiative_right_for_unit_id(unit.id) 
    47     ) then
    48       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    50         unit:load_delegation_info_once_for_member_id(app.session.member_id)
    52         local text
    53         if unit.delegation_info.own_delegation_scope == "unit" then
    54           local member = Member:by_id(unit.delegation_info.first_trustee_id)
    55           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    56           execute.view{
    57             module = "member",
    58             view = "_show_thumb",
    59             params = {
    60               member = member
    61             }
    62           }
    63           text = _"change delegation..."
    64         else
    65           text = _"delegate..."
    66         end
    68         ui.link {
    69           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
    70           module = "delegation", view = "show", params = {
    71             unit_id = unit.id,
    72           },
    73           content = text
    74         }
    76       end }
    77     end
    78   end }
    79 end
    81 if area then
    83   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    84     if unit then
    85       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    86         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
    87       end }
    88       if area.description and #(area.description) > 0 then
    89         ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    90           slot.put(format.text_with_links(area.description))
    91         end }
    92       end
    93     end
    94     if not (config.voting_only and config.disable_delegations) and app.session.member_id and (
    95       app.session.member:has_voting_right_for_unit_id(area.unit_id) 
    96       or app.session.member:has_initiative_right_for_unit_id(area.unit_id) 
    97     ) then
    98       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
   100         area:load_delegation_info_once_for_member_id(app.session.member_id)
   102         local text
   103         if area.delegation_info.own_delegation_scope == "area" then
   104           local member = Member:by_id(area.delegation_info.first_trustee_id)
   105           if member then
   106             ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
   107             execute.view{
   108               module = "member",
   109               view = "_show_thumb",
   110               params = {
   111                 member = member
   112               }
   113             }
   114           else
   115             ui.tag{ content = _"Delegation abandoned" }
   116           end
   117           text = _"change delegation..."
   118         else
   119           text = _"delegate..."  
   120         end
   122         ui.link {
   123           attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   124           module = "delegation", view = "show", params = {
   125             area_id = area.id,
   126           },
   127           content = text
   128         }
   130         if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
   131           ui.link {
   132             attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   133             module = "draft", view = "new",
   134             params = { area_id = area.id },
   135             content = function()
   136               ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
   137               ui.tag{ content = _"new issue" }
   138             end
   139           }
   140         end
   141       end }
   142     end
   143   end }
   144 end
