liquid_feedback_frontend
annotate app/main/initiative/show_tab.lua @ 157:24e47baf5f9b
strip html from fallback title
if the slot is used for title, make sure the html is stripped from it
if the slot is used for title, make sure the html is stripped from it
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Fri Oct 08 20:31:09 2010 +0200 (2010-10-08) |
parents | 0849be391140 |
children | 65a1f7a01e7b |
rev | line source |
---|---|
bsw/jbe@19 | 1 local initiative = param.get("initiative", "table") |
bsw/jbe@19 | 2 local initiator = param.get("initiator", "table") |
bsw/jbe@19 | 3 |
bsw/jbe@19 | 4 if not initiative then |
bsw/jbe@19 | 5 initiative = Initiative:by_id(param.get("initiative_id", atom.number)) |
bsw/jbe@19 | 6 end |
bsw/jbe@19 | 7 |
bsw@51 | 8 if not initiator and app.session.member_id then |
bsw/jbe@19 | 9 initiator = Initiator:by_pk(initiative.id, app.session.member.id) |
bsw/jbe@19 | 10 end |
bsw/jbe@19 | 11 |
bsw/jbe@19 | 12 local current_draft_name = _"Current draft" |
bsw/jbe@19 | 13 if initiative.issue.half_frozen then |
bsw/jbe@19 | 14 current_draft_name = _"Voting proposal" |
bsw/jbe@19 | 15 end |
bsw/jbe@19 | 16 |
bsw/jbe@19 | 17 if initiative.issue.state == "finished" then |
bsw/jbe@19 | 18 current_draft_name = _"Voted proposal" |
bsw/jbe@19 | 19 end |
bsw/jbe@19 | 20 |
bsw/jbe@19 | 21 local tabs = { |
bsw/jbe@19 | 22 { |
bsw/jbe@19 | 23 name = "current_draft", |
bsw/jbe@19 | 24 label = current_draft_name, |
bsw/jbe@19 | 25 icon = { static = "icons/16/script.png" }, |
bsw/jbe@19 | 26 module = "initiative", |
bsw/jbe@19 | 27 view = "_current_draft", |
bsw/jbe@19 | 28 params = { |
bsw/jbe@19 | 29 initiative = initiative, |
bsw/jbe@19 | 30 initiator = initiator |
bsw/jbe@19 | 31 } |
bsw/jbe@19 | 32 } |
bsw/jbe@19 | 33 } |
bsw/jbe@19 | 34 |
bsw@51 | 35 if app.session.member_id then |
bsw@51 | 36 if initiative.issue.ranks_available then |
bsw@51 | 37 tabs[#tabs+1] = { |
bsw@51 | 38 name = "voting", |
bsw@51 | 39 label = _"Voting details", |
bsw@51 | 40 icon = { static = "icons/16/email_open.png" }, |
bsw@51 | 41 module = "initiative", |
bsw@51 | 42 view = "_show_voting", |
bsw@51 | 43 params = { |
bsw@51 | 44 initiative = initiative |
bsw@51 | 45 } |
bsw/jbe@19 | 46 } |
bsw@51 | 47 end |
bsw/jbe@19 | 48 end |
bsw/jbe@19 | 49 |
bsw/jbe@19 | 50 local suggestion_count = initiative:get_reference_selector("suggestions"):count() |
bsw/jbe@19 | 51 |
bsw/jbe@19 | 52 tabs[#tabs+1] = { |
bsw/jbe@19 | 53 name = "suggestions", |
bsw/jbe@19 | 54 label = _"Suggestions" .. " (" .. tostring(suggestion_count) .. ")", |
bsw/jbe@19 | 55 icon = { static = "icons/16/comments.png" }, |
bsw/jbe@19 | 56 module = "initiative", |
bsw/jbe@19 | 57 view = "_suggestions", |
bsw/jbe@19 | 58 params = { |
bsw/jbe@19 | 59 initiative = initiative |
bsw/jbe@19 | 60 } |
bsw/jbe@19 | 61 } |
bsw/jbe@19 | 62 |
bsw@51 | 63 if app.session.member_id then |
bsw@51 | 64 local members_selector = initiative:get_reference_selector("supporting_members_snapshot") |
bsw@51 | 65 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") |
bsw@51 | 66 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") |
bsw@51 | 67 :add_field("direct_interest_snapshot.weight") |
bsw@51 | 68 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") |
bsw@51 | 69 :add_where("direct_supporter_snapshot.satisfied") |
bsw@51 | 70 :add_field("direct_supporter_snapshot.informed", "is_informed") |
bsw@51 | 71 |
bsw@51 | 72 local tmp = db:query("SELECT count(1) AS count, sum(weight) AS weight FROM (" .. tostring(members_selector) .. ") as subquery", "object") |
bsw@51 | 73 local direct_satisfied_supporter_count = tmp.count |
bsw@51 | 74 local indirect_satisfied_supporter_count = (tmp.weight or 0) - tmp.count |
bsw@51 | 75 |
bsw@51 | 76 local count_string |
bsw@51 | 77 if indirect_satisfied_supporter_count > 0 then |
bsw@51 | 78 count_string = "(" .. tostring(direct_satisfied_supporter_count) .. "+" .. tostring(indirect_satisfied_supporter_count) .. ")" |
bsw@51 | 79 else |
bsw@51 | 80 count_string = "(" .. tostring(direct_satisfied_supporter_count) .. ")" |
bsw@51 | 81 end |
bsw@51 | 82 |
bsw@51 | 83 tabs[#tabs+1] = { |
bsw@51 | 84 name = "satisfied_supporter", |
bsw@51 | 85 label = _"Supporter" .. " " .. count_string, |
bsw@51 | 86 icon = { static = "icons/16/thumb_up_green.png" }, |
bsw@51 | 87 module = "member", |
bsw@51 | 88 view = "_list", |
bsw@51 | 89 params = { |
bsw@51 | 90 initiative = initiative, |
bsw@51 | 91 members_selector = members_selector |
bsw@51 | 92 } |
bsw/jbe@19 | 93 } |
bsw@51 | 94 |
bsw@51 | 95 local members_selector = initiative:get_reference_selector("supporting_members_snapshot") |
bsw@51 | 96 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") |
bsw@51 | 97 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") |
bsw@51 | 98 :add_field("direct_interest_snapshot.weight") |
bsw@51 | 99 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") |
bsw@51 | 100 :add_where("NOT direct_supporter_snapshot.satisfied") |
bsw@51 | 101 :add_field("direct_supporter_snapshot.informed", "is_informed") |
bsw@51 | 102 |
bsw@51 | 103 local tmp = db:query("SELECT count(1) AS count, sum(weight) AS weight FROM (" .. tostring(members_selector) .. ") as subquery", "object") |
bsw@51 | 104 local direct_potential_supporter_count = tmp.count |
bsw@51 | 105 local indirect_potential_supporter_count = (tmp.weight or 0) - tmp.count |
bsw@51 | 106 |
bsw@51 | 107 local count_string |
bsw@51 | 108 if indirect_potential_supporter_count > 0 then |
bsw@51 | 109 count_string = "(" .. tostring(direct_potential_supporter_count) .. "+" .. tostring(indirect_potential_supporter_count) .. ")" |
bsw@51 | 110 else |
bsw@51 | 111 count_string = "(" .. tostring(direct_potential_supporter_count) .. ")" |
bsw@51 | 112 end |
bsw@51 | 113 |
bsw@51 | 114 tabs[#tabs+1] = { |
bsw@51 | 115 name = "supporter", |
bsw@51 | 116 label = _"Potential supporter" .. " " .. count_string, |
bsw@51 | 117 icon = { static = "icons/16/thumb_up.png" }, |
bsw@51 | 118 module = "member", |
bsw@51 | 119 view = "_list", |
bsw@51 | 120 params = { |
bsw@51 | 121 initiative = initiative, |
bsw@51 | 122 members_selector = members_selector |
bsw@51 | 123 } |
bsw@51 | 124 } |
bsw@51 | 125 |
bsw@51 | 126 local initiators_members_selector = initiative:get_reference_selector("initiating_members") |
bsw@51 | 127 :add_field("initiator.accepted", "accepted") |
bsw@51 | 128 |
bsw@51 | 129 if not (initiator and initiator.accepted) then |
bsw@51 | 130 initiators_members_selector:add_where("initiator.accepted") |
bsw@51 | 131 end |
bsw@51 | 132 |
bsw@51 | 133 local initiator_count = initiators_members_selector:count() |
bsw@51 | 134 |
bsw@51 | 135 tabs[#tabs+1] = { |
bsw@51 | 136 name = "initiators", |
bsw@51 | 137 label = _"Initiators" .. " (" .. tostring(initiator_count) .. ")", |
bsw@51 | 138 icon = { static = "icons/16/user_edit.png" }, |
bsw@51 | 139 module = "initiative", |
bsw@51 | 140 view = "_initiators", |
bsw@51 | 141 params = { |
bsw@51 | 142 initiative = initiative, |
bsw@51 | 143 initiator = initiator, |
bsw@51 | 144 initiators_members_selector = initiators_members_selector |
bsw@51 | 145 } |
bsw@51 | 146 } |
bsw/jbe@19 | 147 end |
bsw/jbe@19 | 148 |
bsw/jbe@19 | 149 local drafts_count = initiative:get_reference_selector("drafts"):count() |
bsw/jbe@19 | 150 |
bsw/jbe@19 | 151 tabs[#tabs+1] = { |
bsw/jbe@19 | 152 name = "drafts", |
bsw/jbe@19 | 153 label = _"Draft history" .. " (" .. tostring(drafts_count) .. ")", |
bsw/jbe@19 | 154 icon = { static = "icons/16/script.png" }, |
bsw/jbe@19 | 155 module = "draft", |
bsw/jbe@19 | 156 view = "_list", |
bsw/jbe@19 | 157 params = { drafts = initiative.drafts } |
bsw/jbe@19 | 158 } |
bsw/jbe@19 | 159 |
bsw/jbe@19 | 160 tabs[#tabs+1] = { |
bsw/jbe@19 | 161 name = "details", |
bsw/jbe@19 | 162 label = _"Details", |
bsw/jbe@19 | 163 icon = { static = "icons/16/magnifier.png" }, |
bsw/jbe@19 | 164 module = "initiative", |
bsw/jbe@19 | 165 view = "_details", |
bsw/jbe@19 | 166 params = { |
bsw/jbe@19 | 167 initiative = initiative, |
bsw/jbe@19 | 168 members_selector = members_selector |
bsw/jbe@19 | 169 } |
bsw/jbe@19 | 170 } |
bsw/jbe@19 | 171 |
bsw/jbe@19 | 172 tabs.module = "initiative" |
bsw/jbe@19 | 173 tabs.view = "show_tab" |
bsw/jbe@19 | 174 tabs.static_params = { |
bsw/jbe@19 | 175 initiative_id = initiative.id |
bsw/jbe@19 | 176 } |
bsw/jbe@19 | 177 |
bsw/jbe@19 | 178 ui.tabs(tabs) |
bsw/jbe@19 | 179 |