|
23 | 23 | from zulipterminal.config.symbols import (
|
24 | 24 | CHECK_MARK,
|
25 | 25 | COLUMN_TITLE_BAR_LINE,
|
| 26 | + INVALID_MARKER, |
26 | 27 | PINNED_STREAMS_DIVIDER,
|
27 | 28 | SECTION_DIVIDER_LINE,
|
28 | 29 | )
|
@@ -2172,3 +2173,37 @@ def keypress(self, size: urwid_Size, key: str) -> str:
|
2172 | 2173 | self.controller.exit_popup()
|
2173 | 2174 | return key
|
2174 | 2175 | return super().keypress(size, key)
|
| 2176 | + |
| 2177 | + |
| 2178 | +class PollResultsView(PopUpView): |
| 2179 | + def __init__( |
| 2180 | + self, |
| 2181 | + controller: Any, |
| 2182 | + poll_question: str, |
| 2183 | + poll_options: Dict[str, Dict[str, Any]], |
| 2184 | + ) -> None: |
| 2185 | + poll_results_content: List[Tuple[str, List[Tuple[str, str]]]] = [("", [])] |
| 2186 | + |
| 2187 | + for option_key, option_data in poll_options.items(): |
| 2188 | + option_text = option_data["option"] |
| 2189 | + if len(option_text) >= 13: |
| 2190 | + option_text = option_text[:10] + "…" |
| 2191 | + voter_names = option_data["votes"] |
| 2192 | + |
| 2193 | + voters_display = ( |
| 2194 | + "\n".join(map(str, voter_names)) |
| 2195 | + if voter_names |
| 2196 | + else f"{INVALID_MARKER} No votes yet" |
| 2197 | + ) |
| 2198 | + |
| 2199 | + poll_results_content[0][1].append((option_text, voters_display)) |
| 2200 | + |
| 2201 | + popup_width, column_widths = self.calculate_table_widths( |
| 2202 | + poll_results_content, len(poll_question) |
| 2203 | + ) |
| 2204 | + |
| 2205 | + widgets = self.make_table_with_categories(poll_results_content, column_widths) |
| 2206 | + |
| 2207 | + super().__init__( |
| 2208 | + controller, widgets, "SHOW_POLL_VOTES", popup_width, poll_question |
| 2209 | + ) |
0 commit comments