liquid_feedback_frontend

changeset 1665:97dfef4eb2d7

Optionally show attachment previews in listings
author bsw
date Mon Feb 15 15:24:26 2021 +0100 (2021-02-15)
parents fcf0bc8706f4
children f582e3d6434c
files app/main/initiative/_list_element.lua app/main/issue/_sidebar_issue.lua static/lf4.css
line diff
     1.1 --- a/app/main/initiative/_list_element.lua	Mon Feb 15 14:37:18 2021 +0100
     1.2 +++ b/app/main/initiative/_list_element.lua	Mon Feb 15 15:24:26 2021 +0100
     1.3 @@ -19,7 +19,7 @@
     1.4    end
     1.5  end
     1.6  
     1.7 -local class = "initiative  mdl-list__item-primary-content"
     1.8 +local class = "initiative mdl-list__item-primary-content"
     1.9  if initiative.rank == 1 then
    1.10    class = class .. " rank1"
    1.11  end
    1.12 @@ -135,7 +135,26 @@
    1.13        end
    1.14  
    1.15      end }
    1.16 -
    1.17    end
    1.18  }
    1.19  
    1.20 +if config.attachments and config.attachments.preview_in_listing then
    1.21 +
    1.22 +  local file = File:new_selector()
    1.23 +    :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
    1.24 +    :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
    1.25 +    :reset_fields()
    1.26 +    :add_field("file.id")
    1.27 +    :add_field("draft_attachment.title")
    1.28 +    :add_field("draft_attachment.description")
    1.29 +    :add_order_by("draft_attachment.id")
    1.30 +    :limit(1)
    1.31 +    :optional_object_mode()
    1.32 +    :exec()
    1.33 +
    1.34 +  if file then
    1.35 +    ui.image{ attr = { class = "attachment" }, module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
    1.36 +  end
    1.37 +end
    1.38 +
    1.39 +
     2.1 --- a/app/main/issue/_sidebar_issue.lua	Mon Feb 15 14:37:18 2021 +0100
     2.2 +++ b/app/main/issue/_sidebar_issue.lua	Mon Feb 15 15:24:26 2021 +0100
     2.3 @@ -1,22 +1,17 @@
     2.4  local issue = param.get("issue", "table")
     2.5  local ommit_initiative_id = param.get ( "ommit_initiative_id", "number" )
     2.6  
     2.7 ---[[
     2.8 -ui.heading {
     2.9 -  level = 2,
    2.10 -  content = _"Competing initiatives"
    2.11 -}
    2.12 ---]]
    2.13 -
    2.14  if #(issue.initiatives) > (ommit_initiative_id and 1 or 0) then
    2.15 -  execute.view {
    2.16 -    module = "initiative", view = "_list",
    2.17 -    params = {
    2.18 -      issue = issue,
    2.19 -      initiatives = issue.initiatives,
    2.20 -      ommit_initiative_id = ommit_initiative_id
    2.21 +  ui.container{ attr = { class = "competing_initiatives" }, content = function()
    2.22 +    execute.view {
    2.23 +      module = "initiative", view = "_list",
    2.24 +      params = {
    2.25 +        issue = issue,
    2.26 +        initiatives = issue.initiatives,
    2.27 +        ommit_initiative_id = ommit_initiative_id
    2.28 +      }
    2.29      }
    2.30 -  }
    2.31 +  end }
    2.32  end
    2.33  
    2.34  if #issue.initiatives == 1 then
     3.1 --- a/static/lf4.css	Mon Feb 15 14:37:18 2021 +0100
     3.2 +++ b/static/lf4.css	Mon Feb 15 15:24:26 2021 +0100
     3.3 @@ -578,6 +578,40 @@
     3.4    vertical-align: top;
     3.5  }
     3.6  
     3.7 +.initiatives .mdl-list__item {
     3.8 +  display: grid;
     3.9 +  grid-template-columns: 1fr min-content;
    3.10 +  grid-gap: 1em;
    3.11 +  align-items: start;
    3.12 +}
    3.13 +
    3.14 +.initiatives .attachment {
    3.15 +  max-width: 180px;
    3.16 +  max-height: 80px;
    3.17 +}
    3.18 +
    3.19 +.competing_initiatives .initiatives .attachment {
    3.20 +  max-width: 80px;
    3.21 +  max-height: 80px;
    3.22 +}
    3.23 +
    3.24 +
    3.25 +@media (max-width: 960px) {
    3.26 +  .initiatives .mdl-list__item {
    3.27 +    display: block;
    3.28 + }
    3.29 +  .competing_initiatives .initiatives .mdl-list__item {
    3.30 +    display: grid;
    3.31 +  }
    3.32 +  .initiatives .attachment {
    3.33 +    max-width: 100%;
    3.34 +    max-height: 120px;
    3.35 +    margin-bottom: 2ex;
    3.36 +  }
    3.37 +
    3.38 +}
    3.39 +
    3.40 +
    3.41  .initiative_pie {
    3.42    float: left;
    3.43    margin-right: 15px;

Impressum / About Us