# HG changeset patch # User bsw # Date 1613399066 -3600 # Node ID 97dfef4eb2d761a697a2eb0a0cfab54d83f94064 # Parent fcf0bc8706f42ead254e63be186fa3e73a5eaa6a Optionally show attachment previews in listings diff -r fcf0bc8706f4 -r 97dfef4eb2d7 app/main/initiative/_list_element.lua --- a/app/main/initiative/_list_element.lua Mon Feb 15 14:37:18 2021 +0100 +++ b/app/main/initiative/_list_element.lua Mon Feb 15 15:24:26 2021 +0100 @@ -19,7 +19,7 @@ end end -local class = "initiative mdl-list__item-primary-content" +local class = "initiative mdl-list__item-primary-content" if initiative.rank == 1 then class = class .. " rank1" end @@ -135,7 +135,26 @@ end end } - end } +if config.attachments and config.attachments.preview_in_listing then + + local file = File:new_selector() + :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id") + :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id } + :reset_fields() + :add_field("file.id") + :add_field("draft_attachment.title") + :add_field("draft_attachment.description") + :add_order_by("draft_attachment.id") + :limit(1) + :optional_object_mode() + :exec() + + if file then + ui.image{ attr = { class = "attachment" }, module = "file", view = "show.jpg", id = file.id, params = { preview = true } } + end +end + + diff -r fcf0bc8706f4 -r 97dfef4eb2d7 app/main/issue/_sidebar_issue.lua --- a/app/main/issue/_sidebar_issue.lua Mon Feb 15 14:37:18 2021 +0100 +++ b/app/main/issue/_sidebar_issue.lua Mon Feb 15 15:24:26 2021 +0100 @@ -1,22 +1,17 @@ local issue = param.get("issue", "table") local ommit_initiative_id = param.get ( "ommit_initiative_id", "number" ) ---[[ -ui.heading { - level = 2, - content = _"Competing initiatives" -} ---]] - if #(issue.initiatives) > (ommit_initiative_id and 1 or 0) then - execute.view { - module = "initiative", view = "_list", - params = { - issue = issue, - initiatives = issue.initiatives, - ommit_initiative_id = ommit_initiative_id + ui.container{ attr = { class = "competing_initiatives" }, content = function() + execute.view { + module = "initiative", view = "_list", + params = { + issue = issue, + initiatives = issue.initiatives, + ommit_initiative_id = ommit_initiative_id + } } - } + end } end if #issue.initiatives == 1 then diff -r fcf0bc8706f4 -r 97dfef4eb2d7 static/lf4.css --- a/static/lf4.css Mon Feb 15 14:37:18 2021 +0100 +++ b/static/lf4.css Mon Feb 15 15:24:26 2021 +0100 @@ -578,6 +578,40 @@ vertical-align: top; } +.initiatives .mdl-list__item { + display: grid; + grid-template-columns: 1fr min-content; + grid-gap: 1em; + align-items: start; +} + +.initiatives .attachment { + max-width: 180px; + max-height: 80px; +} + +.competing_initiatives .initiatives .attachment { + max-width: 80px; + max-height: 80px; +} + + +@media (max-width: 960px) { + .initiatives .mdl-list__item { + display: block; + } + .competing_initiatives .initiatives .mdl-list__item { + display: grid; + } + .initiatives .attachment { + max-width: 100%; + max-height: 120px; + margin-bottom: 2ex; + } + +} + + .initiative_pie { float: left; margin-right: 15px;