liquid_feedback_frontend
diff app/main/initiative/show.lua @ 1495:17e7082c377a
Added image attachments for initiatives
| author | bsw |
|---|---|
| date | Mon Feb 10 21:10:49 2020 +0100 (2020-02-10) |
| parents | 32cc544d5a5b |
| children | ed3c40911ae1 |
line diff
1.1 --- a/app/main/initiative/show.lua Mon Dec 09 15:54:57 2019 +0100 1.2 +++ b/app/main/initiative/show.lua Mon Feb 10 21:10:49 2020 +0100 1.3 @@ -135,6 +135,35 @@ 1.4 end 1.5 } 1.6 1.7 + if config.attachments then 1.8 + 1.9 + local files = File:new_selector() 1.10 + :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id") 1.11 + :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id } 1.12 + :reset_fields() 1.13 + :add_field("file.id") 1.14 + :add_field("draft_attachment.title") 1.15 + :add_field("draft_attachment.description") 1.16 + :add_order_by("draft_attachment.id") 1.17 + :exec() 1.18 + 1.19 + if #files > 0 then 1.20 + ui.container { 1.21 + attr = { class = "mdl-card__content mdl-card--border" }, 1.22 + content = function() 1.23 + for i, file in ipairs(files) do 1.24 + ui.link{ module = "file", view = "show.jpg", id = file.id, content = function() 1.25 + ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } } 1.26 + end } 1.27 + ui.container{ content = file.title or "" } 1.28 + ui.container{ content = file.description or "" } 1.29 + slot.put("<br /><br />") 1.30 + end 1.31 + end 1.32 + } 1.33 + end 1.34 + end 1.35 + 1.36 local drafts_count = initiative:get_reference_selector("drafts"):count() 1.37 1.38 if not config.voting_only then