liquid_feedback_frontend

diff app/main/draft/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
line diff
     1.1 --- a/app/main/draft/show.lua	Mon Dec 09 15:54:57 2019 +0100
     1.2 +++ b/app/main/draft/show.lua	Mon Feb 10 21:10:49 2020 +0100
     1.3 @@ -6,61 +6,122 @@
     1.4    return
     1.5  end
     1.6  
     1.7 +local member = app.session.member
     1.8 +
     1.9 +if member then
    1.10 +  draft.initiative:load_everything_for_member_id(member.id)
    1.11 +  draft.initiative.issue:load_everything_for_member_id(member.id)
    1.12 +end
    1.13  
    1.14  local source = param.get("source", atom.boolean)
    1.15  
    1.16 -execute.view{
    1.17 -  module = "issue",
    1.18 -  view = "_head",
    1.19 -  params = { issue = draft.initiative.issue }
    1.20 -}
    1.21 +execute.view{ module = "issue", view = "_head", params = { issue = draft.initiative.issue, link_issue = true } }
    1.22 +
    1.23 +ui.grid{ content = function()
    1.24  
    1.25 -ui.section( function()
    1.26 -  
    1.27 -  ui.sectionHead( function()
    1.28 -    ui.link{
    1.29 -      module = "initiative", view = "show", id = draft.initiative.id,
    1.30 -      content = function ()
    1.31 +  ui.cell_main{ content = function()
    1.32 +
    1.33 +    ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    1.34 +
    1.35 +      ui.container{ attr = { class = "mdl-card__title mdl-card--has-fab mdl-card--border" }, content = function ()
    1.36 +
    1.37          ui.heading { 
    1.38 -          level = 1,
    1.39 -          content = draft.initiative.display_name
    1.40 +          attr = { class = "mdl-card__title-text" },
    1.41 +          level = 2,
    1.42 +          content = function()
    1.43 +            ui.link{
    1.44 +              module = "initiative", view = "show", id = draft.initiative.id,
    1.45 +              content = draft.initiative.display_name
    1.46 +            }
    1.47 +            ui.container{ content = _("Draft revision #{id}", { id = draft.id } ) }
    1.48 +          end 
    1.49          }
    1.50 -      end
    1.51 -    }
    1.52 -    ui.container { attr = { class = "right" }, content = function()
    1.53 -      if source then
    1.54 -        ui.link{
    1.55 -          content = _"Rendered",
    1.56 +      end }
    1.57 +
    1.58 +      ui.container{ attr = { class = "draft mdl-card__title mdl-card--border" }, content = function()
    1.59 +        if config.render_external_reference and config.render_external_reference.draft then
    1.60 +          config.render_external_reference.draft(draft, function (callback)
    1.61 +            ui.sectionRow(callback)
    1.62 +          end)
    1.63 +        end
    1.64 +        
    1.65 +        execute.view{
    1.66            module = "draft",
    1.67 -          view = "show",
    1.68 -          id = param.get_id(),
    1.69 -          params = { source = false }
    1.70 +          view = "_show",
    1.71 +          params = { draft = draft, source = source }
    1.72          }
    1.73 -      else
    1.74 -        ui.link{
    1.75 -          content = _"Source",
    1.76 -          module = "draft",
    1.77 -          view = "show",
    1.78 -          id = param.get_id(),
    1.79 -          params = { source = true }
    1.80 -        }
    1.81 +
    1.82 +
    1.83 +
    1.84 +      end }      
    1.85 +
    1.86 +      if config.attachments then
    1.87 +
    1.88 +        local files = File:new_selector()
    1.89 +          :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
    1.90 +          :add_where{ "draft_attachment.draft_id = ?", draft.id }
    1.91 +          :reset_fields()
    1.92 +          :add_field("file.id")
    1.93 +          :add_field("draft_attachment.title")
    1.94 +          :add_field("draft_attachment.description")
    1.95 +          :add_order_by("draft_attachment.id")
    1.96 +          :exec()
    1.97 +
    1.98 +        if #files > 0 then
    1.99 +          ui.container {
   1.100 +            attr = { class = "mdl-card__content mdl-card--border" },
   1.101 +            content = function()
   1.102 +              for i, file in ipairs(files) do
   1.103 +                ui.link{ module = "file", view = "show.jpg", id = file.id, content = function()
   1.104 +                  ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
   1.105 +                end }
   1.106 +                ui.container{ content = file.title or "" }
   1.107 +                ui.container{ content = file.description or "" }
   1.108 +                slot.put("<br /><br />")
   1.109 +              end
   1.110 +            end
   1.111 +          }
   1.112 +        end
   1.113        end
   1.114 +
   1.115 +      ui.container{ attr = { class = "mdl-card__actions" }, content = function()
   1.116 +        if source then
   1.117 +          ui.link{
   1.118 +            attr = { class = "mdl-button mdl-js-button" },
   1.119 +            content = _"Rendered",
   1.120 +            module = "draft",
   1.121 +            view = "show",
   1.122 +            id = param.get_id(),
   1.123 +            params = { source = false }
   1.124 +          }
   1.125 +        else
   1.126 +          ui.link{
   1.127 +            attr = { class = "mdl-button mdl-js-button" },
   1.128 +            content = _"Source",
   1.129 +            module = "draft",
   1.130 +            view = "show",
   1.131 +            id = param.get_id(),
   1.132 +            params = { source = true }
   1.133 +          }
   1.134 +        end
   1.135 +        
   1.136 +      end }
   1.137      end }
   1.138 -    ui.heading { level = 2, content = _("Draft revision #{id}", { id = draft.id } ) }
   1.139 -  end)
   1.140 -  
   1.141 -  if config.render_external_reference and config.render_external_reference.draft then
   1.142 -    config.render_external_reference.draft(draft, function (callback)
   1.143 -      ui.sectionRow(callback)
   1.144 -    end)
   1.145 -  end
   1.146 -  
   1.147 -  ui.sectionRow( function()
   1.148 -  
   1.149 -    execute.view{
   1.150 -      module = "draft",
   1.151 -      view = "_show",
   1.152 -      params = { draft = draft, source = source }
   1.153 +
   1.154 +  end }
   1.155 +
   1.156 +  ui.cell_sidebar{ content = function()
   1.157 +    if config.logo then
   1.158 +      config.logo()
   1.159 +    end
   1.160 +    execute.view {
   1.161 +      module = "issue", view = "_sidebar", 
   1.162 +      params = {
   1.163 +        issue = draft.initiative.issue,
   1.164 +        initiative = draft.initiative,
   1.165 +        member = app.session.member
   1.166 +      }
   1.167      }
   1.168 -  end)
   1.169 -end)
   1.170 +  end }
   1.171 +
   1.172 +end }

Impressum / About Us