-
-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Polls Widget on ZT. #1551
base: main
Are you sure you want to change the base?
Changes from 1 commit
827ef2c
af39cee
17d3ade
3b29642
990118a
78fd5df
9d75f50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
from zulipterminal.config.symbols import ( | ||
CHECK_MARK, | ||
COLUMN_TITLE_BAR_LINE, | ||
INVALID_MARKER, | ||
PINNED_STREAMS_DIVIDER, | ||
SECTION_DIVIDER_LINE, | ||
) | ||
|
@@ -2172,3 +2173,37 @@ def keypress(self, size: urwid_Size, key: str) -> str: | |
self.controller.exit_popup() | ||
return key | ||
return super().keypress(size, key) | ||
|
||
|
||
class PollResultsView(PopUpView): | ||
def __init__( | ||
self, | ||
controller: Any, | ||
poll_question: str, | ||
poll_options: Dict[str, Dict[str, Any]], | ||
) -> None: | ||
poll_results_content: List[Tuple[str, List[Tuple[str, str]]]] = [("", [])] | ||
|
||
for option_key, option_data in poll_options.items(): | ||
option_text = option_data["option"] | ||
if len(option_text) >= 13: | ||
option_text = option_text[:10] + "…" | ||
Comment on lines
+2189
to
+2190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We definitely need a cut-off length, since otherwise this causes problems :) However, this length seems rather small? For example, even something like 'None of the above' doesn't fit, or 'long long long'?
|
||
voter_names = option_data["votes"] | ||
|
||
voters_display = ( | ||
"\n".join(map(str, voter_names)) | ||
if voter_names | ||
else f"{INVALID_MARKER} No votes yet" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does make it stand out better 👍 |
||
) | ||
|
||
poll_results_content[0][1].append((option_text, voters_display)) | ||
|
||
popup_width, column_widths = self.calculate_table_widths( | ||
poll_results_content, len(poll_question) | ||
) | ||
|
||
widgets = self.make_table_with_categories(poll_results_content, column_widths) | ||
|
||
super().__init__( | ||
controller, widgets, "SHOW_POLL_VOTES", popup_width, poll_question | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type seems inaccurate? This is one benefit of defining more complex data types that you're passing around, even if via typeddicts, since you can refer to them as a name and update them in one place.