poll widget: Only show "Add option" if a question has been set.

This makes the UI less confusing.
This commit is contained in:
Tim Abbott
2018-12-16 11:53:36 -08:00
parent 5d31c57638
commit 728c601ff4
2 changed files with 7 additions and 0 deletions

View File

@@ -175,6 +175,7 @@ run_test('activate another person poll', () => {
const poll_question_input = set_widget_find_result('input.poll-question'); const poll_question_input = set_widget_find_result('input.poll-question');
const poll_question_header = set_widget_find_result('.poll-question-header'); const poll_question_header = set_widget_find_result('.poll-question-header');
const poll_question_container = set_widget_find_result('.poll-question-bar'); const poll_question_container = set_widget_find_result('.poll-question-bar');
const poll_comment_container = set_widget_find_result('.poll-comment-bar');
const poll_vote_button = set_widget_find_result('button.poll-vote'); const poll_vote_button = set_widget_find_result('button.poll-vote');
@@ -279,6 +280,7 @@ run_test('activate another person poll', () => {
widget_elem.handle_events(add_question_event); widget_elem.handle_events(add_question_event);
assert(!poll_question_container.visible()); assert(!poll_question_container.visible());
assert(poll_comment_container.visible());
}); });
run_test('activate own poll', () => { run_test('activate own poll', () => {
@@ -324,6 +326,7 @@ run_test('activate own poll', () => {
const poll_question_input = set_widget_find_result('input.poll-question'); const poll_question_input = set_widget_find_result('input.poll-question');
const poll_question_header = set_widget_find_result('.poll-question-header'); const poll_question_header = set_widget_find_result('.poll-question-header');
const poll_question_container = set_widget_find_result('.poll-question-bar'); const poll_question_container = set_widget_find_result('.poll-question-bar');
const poll_comment_container = set_widget_find_result('.poll-comment-bar');
const poll_vote_button = set_widget_find_result('button.poll-vote'); const poll_vote_button = set_widget_find_result('button.poll-vote');
@@ -368,4 +371,5 @@ run_test('activate own poll', () => {
question_button_callback(e); question_button_callback(e);
assert.deepEqual(out_data, undefined); assert.deepEqual(out_data, undefined);
} }
assert(poll_comment_container.visible());
}); });

View File

@@ -202,6 +202,9 @@ exports.activate = function (opts) {
} }
if (widget_data.question !== '') { if (widget_data.question !== '') {
elem.find('button.poll-question').text(i18n.t('Edit question')); elem.find('button.poll-question').text(i18n.t('Edit question'));
elem.find('.poll-comment-bar').show();
} else {
elem.find('.poll-comment-bar').hide();
} }
elem.find("button.poll-vote").on('click', function (e) { elem.find("button.poll-vote").on('click', function (e) {