liquid_feedback_frontend
view app/main/draft/show.lua @ 1810:0a243b9aac6b
Added missing local statement
| author | bsw | 
|---|---|
| date | Thu Dec 02 13:22:15 2021 +0100 (2021-12-02) | 
| parents | 17e7082c377a | 
| children | 
 line source
     1 local draft = Draft:new_selector():add_where{ "id = ?", param.get_id() }:optional_object_mode():exec()
     3 if not draft then
     4   execute.view { module = "index", view = "404" }
     5   request.set_status("404 Not Found")
     6   return
     7 end
     9 local member = app.session.member
    11 if member then
    12   draft.initiative:load_everything_for_member_id(member.id)
    13   draft.initiative.issue:load_everything_for_member_id(member.id)
    14 end
    16 local source = param.get("source", atom.boolean)
    18 execute.view{ module = "issue", view = "_head", params = { issue = draft.initiative.issue, link_issue = true } }
    20 ui.grid{ content = function()
    22   ui.cell_main{ content = function()
    24     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    26       ui.container{ attr = { class = "mdl-card__title mdl-card--has-fab mdl-card--border" }, content = function ()
    28         ui.heading { 
    29           attr = { class = "mdl-card__title-text" },
    30           level = 2,
    31           content = function()
    32             ui.link{
    33               module = "initiative", view = "show", id = draft.initiative.id,
    34               content = draft.initiative.display_name
    35             }
    36             ui.container{ content = _("Draft revision #{id}", { id = draft.id } ) }
    37           end 
    38         }
    39       end }
    41       ui.container{ attr = { class = "draft mdl-card__title mdl-card--border" }, content = function()
    42         if config.render_external_reference and config.render_external_reference.draft then
    43           config.render_external_reference.draft(draft, function (callback)
    44             ui.sectionRow(callback)
    45           end)
    46         end
    48         execute.view{
    49           module = "draft",
    50           view = "_show",
    51           params = { draft = draft, source = source }
    52         }
    56       end }      
    58       if config.attachments then
    60         local files = File:new_selector()
    61           :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
    62           :add_where{ "draft_attachment.draft_id = ?", draft.id }
    63           :reset_fields()
    64           :add_field("file.id")
    65           :add_field("draft_attachment.title")
    66           :add_field("draft_attachment.description")
    67           :add_order_by("draft_attachment.id")
    68           :exec()
    70         if #files > 0 then
    71           ui.container {
    72             attr = { class = "mdl-card__content mdl-card--border" },
    73             content = function()
    74               for i, file in ipairs(files) do
    75                 ui.link{ module = "file", view = "show.jpg", id = file.id, content = function()
    76                   ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
    77                 end }
    78                 ui.container{ content = file.title or "" }
    79                 ui.container{ content = file.description or "" }
    80                 slot.put("<br /><br />")
    81               end
    82             end
    83           }
    84         end
    85       end
    87       ui.container{ attr = { class = "mdl-card__actions" }, content = function()
    88         if source then
    89           ui.link{
    90             attr = { class = "mdl-button mdl-js-button" },
    91             content = _"Rendered",
    92             module = "draft",
    93             view = "show",
    94             id = param.get_id(),
    95             params = { source = false }
    96           }
    97         else
    98           ui.link{
    99             attr = { class = "mdl-button mdl-js-button" },
   100             content = _"Source",
   101             module = "draft",
   102             view = "show",
   103             id = param.get_id(),
   104             params = { source = true }
   105           }
   106         end
   108       end }
   109     end }
   111   end }
   113   ui.cell_sidebar{ content = function()
   114     if config.logo then
   115       config.logo()
   116     end
   117     execute.view {
   118       module = "issue", view = "_sidebar", 
   119       params = {
   120         issue = draft.initiative.issue,
   121         initiative = draft.initiative,
   122         member = app.session.member
   123       }
   124     }
   125   end }
   127 end }
