liquid_feedback_frontend

changeset 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 631f6311a9eb
children 52545dba4205
files app/main/index/_head.lua app/main/index/index.lua
line diff
     1.1 --- a/app/main/index/_head.lua	Sun Jan 31 20:37:22 2021 +0100
     1.2 +++ b/app/main/index/_head.lua	Sun Jan 31 22:04:30 2021 +0100
     1.3 @@ -1,12 +1,13 @@
     1.4 -local unit_id = config.single_unit_id or tonumber(request.get_param{ name = "unit" })
     1.5 +local unit_id = config.single_unit_id or request.get_param{ name = "unit" }
     1.6 +local area_id = config.single_area_id or request.get_param{ name = "area" }
     1.7  if unit_id == "all" then
     1.8    unit_id = nil 
     1.9 +  area_id = nil
    1.10  end
    1.11  local unit
    1.12  if unit_id then
    1.13    unit = Unit:by_id(unit_id)
    1.14  end
    1.15 -local area_id = config.single_area_id or tonumber(request.get_param{ name = "area" })
    1.16  if area_id == "all" then
    1.17    area_id = nil
    1.18  end
    1.19 @@ -14,80 +15,96 @@
    1.20  if area_id then
    1.21    area = Area:by_id(area_id)
    1.22  end
    1.23 +
    1.24 +print(unit_id, area_id, unit, area)
    1.25 +
    1.26 +if unit then
    1.27 +  ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    1.28 +    ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    1.29 +      ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
    1.30 +      if unit.description and #(unit.description) > 0 then
    1.31 +        ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description }
    1.32 +      end
    1.33 +      if config.render_external_reference_unit then
    1.34 +        config.render_external_reference_unit(unit)
    1.35 +      end
    1.36 +    end }
    1.37 +
    1.38 +
    1.39 +    if not (config.voting_only and config.disable_delegations) and app.session.member_id then
    1.40 +      ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    1.41 +          
    1.42 +        unit:load_delegation_info_once_for_member_id(app.session.member_id)
    1.43 +        
    1.44 +        local text
    1.45 +        if unit.delegation_info.own_delegation_scope == "unit" then
    1.46 +          local member = Member:by_id(unit.delegation_info.first_trustee_id)
    1.47 +          ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
    1.48 +          execute.view{
    1.49 +            module = "member",
    1.50 +            view = "_show_thumb",
    1.51 +            params = {
    1.52 +              member = member
    1.53 +            }
    1.54 +          }
    1.55 +          text = _"change delegation..."
    1.56 +        else
    1.57 +          text = _"delegate..."
    1.58 +        end
    1.59 +        
    1.60 +        ui.link {
    1.61 +          attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
    1.62 +          module = "delegation", view = "show", params = {
    1.63 +            unit_id = unit.id,
    1.64 +          },
    1.65 +          content = text
    1.66 +        }
    1.67 +
    1.68 +      end }
    1.69 +    end
    1.70 +  end }
    1.71 +end
    1.72 +
    1.73  if area then
    1.74 -  if app.session.member_id then
    1.75 -    area:load_delegation_info_once_for_member_id(app.session.member_id)
    1.76 -  end
    1.77  
    1.78    ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    1.79      if unit then
    1.80        ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    1.81 -        if not config.single_area_id then
    1.82 -          ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name .. " ยป " .. area.name }
    1.83 -        else
    1.84 -          ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
    1.85 +        ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
    1.86 +        if area.description and #(area.description) > 0 then
    1.87 +          ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description }
    1.88          end
    1.89        end }
    1.90      end
    1.91 -    if area.description and #(area.description) > 0 then
    1.92 -      if not config.single_area_id then
    1.93 -        ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = area.description }
    1.94 -      else
    1.95 -        ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = unit.description }
    1.96 -      end
    1.97 -    end
    1.98      if not (config.voting_only and config.disable_delegations) and app.session.member_id then
    1.99        ui.container{ attr = { class = "mdl-card__actions" }, content = function()
   1.100            
   1.101 -        if not config.disable_delegations then
   1.102 -
   1.103 -          if area.delegation_info.first_trustee_id then
   1.104 -            local member = Member:by_id(area.delegation_info.first_trustee_id)
   1.105 -            ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
   1.106 -            execute.view{
   1.107 -              module = "member",
   1.108 -              view = "_show_thumb",
   1.109 -              params = {
   1.110 -                member = member
   1.111 -              }
   1.112 -            }
   1.113 -          end
   1.114 -            
   1.115 -          local text
   1.116 -          if area.delegation_info.own_delegation_scope == nil then
   1.117 -            text = _"delegate..."  
   1.118 -          else
   1.119 -            text = _"change delegation..."
   1.120 -          end
   1.121 -          
   1.122 -          
   1.123 -          ui.tag{ attr = { id = "change_delegation", class = "mdl-button" }, content = text }
   1.124 -
   1.125 +        area:load_delegation_info_once_for_member_id(app.session.member_id)
   1.126  
   1.127 -          ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = "change_delegation" }, content = function()
   1.128 -
   1.129 -            ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   1.130 -              ui.link {
   1.131 -                attr = { class = "mdl-menu__link" },
   1.132 -                module = "delegation", view = "show", params = {
   1.133 -                  unit_id = area.unit_id,
   1.134 -                },
   1.135 -                content = _("unit: #{name}", { name = area.unit.name })
   1.136 -              }
   1.137 -            end }
   1.138 -
   1.139 -            ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   1.140 -              ui.link {
   1.141 -                attr = { class = "mdl-menu__link" },
   1.142 -                module = "delegation", view = "show", params = {
   1.143 -                  area_id = area.id
   1.144 -                },
   1.145 -                content = _("subject area: #{name}", { name = area.name })
   1.146 -              }
   1.147 -            end }
   1.148 -          end }
   1.149 +        local text
   1.150 +        if area.delegation_info.own_delegation_scope == "area" then
   1.151 +          local member = Member:by_id(area.delegation_info.first_trustee_id)
   1.152 +          ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
   1.153 +          execute.view{
   1.154 +            module = "member",
   1.155 +            view = "_show_thumb",
   1.156 +            params = {
   1.157 +              member = member
   1.158 +            }
   1.159 +          }
   1.160 +          text = _"change delegation..."
   1.161 +        else
   1.162 +          text = _"delegate..."  
   1.163          end
   1.164 -                
   1.165 +        
   1.166 +        ui.link {
   1.167 +          attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   1.168 +          module = "delegation", view = "show", params = {
   1.169 +            area_id = area.id,
   1.170 +          },
   1.171 +          content = text
   1.172 +        }
   1.173 +                        
   1.174          if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
   1.175            ui.link {
   1.176              attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
   1.177 @@ -102,26 +119,6 @@
   1.178        end }
   1.179      end
   1.180    end }
   1.181 -elseif unit then
   1.182 -  ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   1.183 -    ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   1.184 -      ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
   1.185 -    end }
   1.186 -    if unit.description and #(unit.description) > 0 then
   1.187 -      ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = unit.description }
   1.188 -    end
   1.189 -    if config.render_external_reference_unit then
   1.190 -      config.render_external_reference_unit(unit)
   1.191 -    end
   1.192 -    --ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function()
   1.193 -    --end }
   1.194 -  end }
   1.195 -else
   1.196 -  ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   1.197 -    ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   1.198 -      ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"All issues" }
   1.199 -    end }
   1.200 -    ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = _"All issues in your units. Use filters above to limit results." }
   1.201 -  end }
   1.202  end
   1.203 -  
   1.204 +
   1.205 +
     2.1 --- a/app/main/index/index.lua	Sun Jan 31 20:37:22 2021 +0100
     2.2 +++ b/app/main/index/index.lua	Sun Jan 31 22:04:30 2021 +0100
     2.3 @@ -8,6 +8,7 @@
     2.4  
     2.5  if unit_id == "all" then
     2.6    unit_id = nil
     2.7 +  area_id = nil
     2.8  end
     2.9  
    2.10  if area_id == "all" then
    2.11 @@ -26,6 +27,7 @@
    2.12    end
    2.13  end
    2.14  
    2.15 +
    2.16  if area_id then
    2.17    area = Area:by_id(area_id)
    2.18    if not area or area.unit_id ~= unit.id then

Impressum / About Us