liquid_feedback_frontend

diff app/main/initiative/_list_element.lua @ 1665:97dfef4eb2d7

Optionally show attachment previews in listings
author bsw
date Mon Feb 15 15:24:26 2021 +0100 (2021-02-15)
parents 32cc544d5a5b
children f582e3d6434c
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 +

Impressum / About Us