liquid_feedback_frontend

annotate app/main/timeline/_list.lua @ 141:20e0b64cc1f9

use monospace/pre data on suggestion display and entry

this allows better formatting on the user suggestions without the overhead of using wiki there

fixes bug #215
author Daniel Poelzleithner <poelzi@poelzi.org>
date Wed Oct 06 14:34:45 2010 +0200 (2010-10-06)
parents 166fd10c7e81
children 90520c9fca44
rev   line source
bsw@11 1 local timeline_selector = param.get("timeline_selector", "table")
bsw@11 2 local event_names = param.get("event_names", "table")
bsw@11 3 local initiatives_per_page = param.get("initiatives_per_page", atom.number) or 3
bsw@11 4
poelzi@136 5
poelzi@136 6 -- test if selector is valid
poelzi@136 7 local test_selector = timeline_selector:get_db_conn():new_selector()
poelzi@136 8 test_selector:add_field('count(1)')
poelzi@136 9 test_selector:add_from(timeline_selector)
poelzi@136 10 test_selector:single_object_mode()
poelzi@136 11
poelzi@136 12 err, x = test_selector:try_exec()
bsw/jbe@19 13
poelzi@136 14 if err then
poelzi@136 15 slot.put_into("error", _"Invalid query")
poelzi@136 16 else
poelzi@136 17 ui.paginate{
poelzi@136 18 per_page = param.get("per_page", atom.number) or 25,
poelzi@136 19 selector = timeline_selector,
poelzi@136 20 content = function()
poelzi@136 21 local timelines = timeline_selector:exec()
poelzi@136 22 timelines:load("issue")
poelzi@136 23 timelines:load("initiative")
poelzi@136 24 timelines:load("member")
poelzi@136 25 ui.list{
poelzi@136 26 attr = { class = "nohover" },
poelzi@136 27 records = timelines,
poelzi@136 28 columns = {
poelzi@136 29 {
poelzi@136 30 field_attr = { style = "width: 10em;" },
poelzi@136 31 content = function(timeline)
bsw/jbe@19 32 ui.field.text{
poelzi@136 33 attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"},
poelzi@136 34 value = format.time(timeline.occurrence)
bsw/jbe@19 35 }
poelzi@136 36
poelzi@136 37 ui.field.text{
poelzi@136 38 attr = { style = "font-size: 75%; font-weight: bold;"},
poelzi@136 39 value = event_names[timeline.event] or timeline.event
poelzi@136 40 }
poelzi@136 41 if timeline.event == "draft_created" and timeline.count > 1 then
poelzi@136 42 ui.field.text{
poelzi@136 43 attr = { style = "font-size: 75%;"},
poelzi@136 44 value = _("(#{more_count} duplicates removed)", { more_count = timeline.count - 1 })
bsw@11 45 }
bsw@11 46 end
bsw@11 47 end
poelzi@136 48 },
poelzi@136 49 {
poelzi@136 50 content = function(timeline)
poelzi@136 51 local issue
poelzi@136 52 local initiative
poelzi@136 53 if timeline.issue then
poelzi@136 54 issue = timeline.issue
poelzi@136 55 elseif timeline.initiative then
poelzi@136 56 initiative = timeline.initiative
poelzi@136 57 issue = initiative.issue
poelzi@136 58 elseif timeline.draft then
poelzi@136 59 initiative = timeline.draft.initiative
poelzi@136 60 issue = initiative.issue
poelzi@136 61 elseif timeline.suggestion then
poelzi@136 62 initiative = timeline.suggestion.initiative
poelzi@136 63 issue = initiative.issue
poelzi@136 64 end
poelzi@136 65 if issue then
poelzi@136 66 if timeline.is_interested then
poelzi@136 67 local label = _"You are interested in this issue",
poelzi@136 68 ui.image{
poelzi@136 69 attr = { alt = label, title = label, style = "float: left; margin-right: 0.5em;" },
poelzi@136 70 static = "icons/16/eye.png"
poelzi@136 71 }
poelzi@136 72 end
poelzi@136 73 slot.put(" ")
poelzi@136 74 ui.tag{
poelzi@136 75 tag = "span",
poelzi@136 76 attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"},
poelzi@136 77 content = issue.area.name .. ", " .. _("Issue ##{id}", { id = issue.id })
poelzi@136 78 }
poelzi@136 79 else
poelzi@136 80 ui.tag{
poelzi@136 81 tag = "span",
poelzi@136 82 attr = { style = "font-size: 75%; background-color: #ccc; display: block; margin-bottom: 1ex;"},
poelzi@136 83 content = function() slot.put("&nbsp;") end
poelzi@136 84 }
poelzi@136 85 end
poelzi@136 86
poelzi@136 87 if timeline.member then
poelzi@136 88 execute.view{
poelzi@136 89 module = "member_image",
poelzi@136 90 view = "_show",
poelzi@136 91 params = {
poelzi@136 92 member = timeline.member,
poelzi@136 93 image_type = "avatar",
poelzi@136 94 show_dummy = true
poelzi@136 95 }
bsw@11 96 }
poelzi@136 97 ui.link{
poelzi@136 98 content = timeline.member.name,
poelzi@136 99 module = "member",
poelzi@136 100 view = "show",
poelzi@136 101 id = timeline.member.id
poelzi@136 102 }
poelzi@136 103 end
poelzi@136 104 if timeline.issue then
poelzi@136 105 local initiatives_selector = timeline.issue
poelzi@136 106 :get_reference_selector("initiatives")
poelzi@136 107 execute.view{
poelzi@136 108 module = "initiative",
poelzi@136 109 view = "_list",
poelzi@136 110 params = {
poelzi@136 111 issue = timeline.issue,
poelzi@136 112 initiatives_selector = initiatives_selector,
poelzi@136 113 per_page = initiatives_per_page,
poelzi@136 114 no_sort = true,
poelzi@136 115 limit = initiatives_per_page
poelzi@136 116 }
bsw@11 117 }
poelzi@136 118 elseif initiative then
poelzi@136 119 execute.view{
poelzi@136 120 module = "initiative",
poelzi@136 121 view = "_list",
poelzi@136 122 params = {
poelzi@136 123 issue = initiative.issue,
poelzi@136 124 initiatives_selector = Initiative:new_selector():add_where{ "initiative.id = ?", initiative.id },
poelzi@136 125 per_page = initiatives_per_page,
poelzi@136 126 no_sort = true
poelzi@136 127 }
poelzi@136 128 }
poelzi@136 129 end
poelzi@136 130 if timeline.suggestion then
poelzi@136 131 ui.link{
poelzi@136 132 module = "suggestion",
poelzi@136 133 view = "show",
poelzi@136 134 id = timeline.suggestion.id,
poelzi@136 135 content = timeline.suggestion.name
poelzi@136 136 }
poelzi@136 137 end
bsw@11 138 end
poelzi@136 139 },
poelzi@136 140 }
bsw@11 141 }
poelzi@136 142 end
poelzi@136 143 }
poelzi@136 144 end

Impressum / About Us