mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
polls: Add option for modal to create polls.
Earlier the `/poll` slash command was the only way to create polls. To increase user friendliness with a GUI, a button to launch a modal to create a poll, has been added to the compose box. This button is enabled only when the compose box is empty, to avoid complexities with losing / having to save as draft any message already being composed. The modal has a form which on submission frames a message using the `/poll` syntax and the data input in the form, and sets the content of the compose box to that message, which the user can then send. The question field is mandatory for form submission. Fixes: #20304.
This commit is contained in:
@@ -209,6 +209,22 @@ export function initialize(): void {
|
||||
},
|
||||
});
|
||||
|
||||
delegate("body", {
|
||||
target: "#add-poll-modal .dialog_submit_button_container",
|
||||
appendTo: () => document.body,
|
||||
onShow(instance) {
|
||||
const content = $t({defaultMessage: "Please enter a question."});
|
||||
const $elem = $(instance.reference);
|
||||
// Show tooltip to enter question only if submit button is disabled
|
||||
// (due to question field being empty).
|
||||
if ($elem.find(".dialog_submit_button").is(":disabled")) {
|
||||
instance.setContent(content);
|
||||
return undefined;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
$("body").on(
|
||||
"blur",
|
||||
".message_control_button, .delete-selected-drafts-button-container",
|
||||
|
||||
Reference in New Issue
Block a user