FIX: Poll: critical display issue when results are only shown upon vote (#27732)
This commit is contained in:
parent
bb0daa33cd
commit
8b963986b3
|
@ -109,10 +109,18 @@ export default class PollInfoComponent extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get resultsOnVoteTitle() {
|
||||||
|
return htmlSafe(I18n.t("poll.results.vote.title"));
|
||||||
|
}
|
||||||
|
|
||||||
get resultsOnClose() {
|
get resultsOnClose() {
|
||||||
return this.args.results === ON_CLOSE && !this.args.closed;
|
return this.args.results === ON_CLOSE && !this.args.closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get resultsOnCloseTitle() {
|
||||||
|
return htmlSafe(I18n.t("poll.results.close.title"));
|
||||||
|
}
|
||||||
|
|
||||||
get resultsStaffOnly() {
|
get resultsStaffOnly() {
|
||||||
return (
|
return (
|
||||||
this.args.results === STAFF_ONLY &&
|
this.args.results === STAFF_ONLY &&
|
||||||
|
@ -120,6 +128,10 @@ export default class PollInfoComponent extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get resultsStaffOnlyTitle() {
|
||||||
|
return htmlSafe(I18n.t("poll.results.staff.title"));
|
||||||
|
}
|
||||||
|
|
||||||
get publicTitle() {
|
get publicTitle() {
|
||||||
return (
|
return (
|
||||||
!this.args.closed &&
|
!this.args.closed &&
|
||||||
|
@ -179,21 +191,21 @@ export default class PollInfoComponent extends Component {
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if this.resultsOnVote}}
|
{{#if this.resultsOnVote}}
|
||||||
<li>
|
<li class="results-on-vote">
|
||||||
{{icon "check"}}
|
{{icon "check"}}
|
||||||
<span>{{I18n "poll.results.vote.title"}}</span>
|
<span>{{this.resultsOnVoteTitle}}</span>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if this.resultsOnClose}}
|
{{#if this.resultsOnClose}}
|
||||||
<li>
|
<li class="results-on-close">
|
||||||
{{icon "lock"}}
|
{{icon "lock"}}
|
||||||
<span>{{I18n "poll.results.closed.title"}}</span>
|
<span>{{this.resultsOnCloseTitle}}</span>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if this.resultsStaffOnly}}
|
{{#if this.resultsStaffOnly}}
|
||||||
<li>
|
<li class="results-staff-only">
|
||||||
{{icon "shield-alt"}}
|
{{icon "shield-alt"}}
|
||||||
<span>{{I18n "poll.results.staff.title"}}</span>
|
<span>{{this.resultsStaffOnlyTitle}}</span>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if this.publicTitle}}
|
{{#if this.publicTitle}}
|
||||||
|
|
|
@ -14,7 +14,7 @@ const OPTIONS = [
|
||||||
module("Poll | Component | poll-info", function (hooks) {
|
module("Poll | Component | poll-info", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("multiple poll", async function (assert) {
|
test("public multiple poll with results anytime", async function (assert) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
isMultiple: true,
|
isMultiple: true,
|
||||||
min: 1,
|
min: 1,
|
||||||
|
@ -59,4 +59,58 @@ module("Poll | Component | poll-info", function (hooks) {
|
||||||
"displays the public label"
|
"displays the public label"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("public multiple poll with results only shown on vote", async function (assert) {
|
||||||
|
this.setProperties({
|
||||||
|
isMultiple: true,
|
||||||
|
min: 1,
|
||||||
|
max: 2,
|
||||||
|
options: OPTIONS,
|
||||||
|
close: null,
|
||||||
|
closed: false,
|
||||||
|
results: "on_vote",
|
||||||
|
showResults: false,
|
||||||
|
postUserId: 59,
|
||||||
|
isPublic: true,
|
||||||
|
hasVoted: false,
|
||||||
|
voters: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
await render(hbs`<PollInfo
|
||||||
|
@options={{this.options}}
|
||||||
|
@min={{this.min}}
|
||||||
|
@max={{this.max}}
|
||||||
|
@isMultiple={{this.isMultiple}}
|
||||||
|
@close={{this.close}}
|
||||||
|
@closed={{this.closed}}
|
||||||
|
@results={{this.results}}
|
||||||
|
@showResults={{this.showResults}}
|
||||||
|
@postUserId={{this.postUserId}}
|
||||||
|
@isPublic={{this.isPublic}}
|
||||||
|
@hasVoted={{this.hasVoted}}
|
||||||
|
@voters={{this.voters}}
|
||||||
|
/>`);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(".poll-info_instructions li.multiple-help-text").textContent.trim(),
|
||||||
|
I18n.t("poll.multiple.help.up_to_max_options", {
|
||||||
|
count: this.max,
|
||||||
|
}).replace(/<\/?[^>]+(>|$)/g, ""),
|
||||||
|
"displays the multiple help text"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(
|
||||||
|
".poll-info_instructions li.results-on-vote span"
|
||||||
|
).textContent.trim(),
|
||||||
|
I18n.t("poll.results.vote.title").replace(/<\/?[^>]+(>|$)/g, ""),
|
||||||
|
"displays the results on vote label"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(".poll-info_instructions li.is-public").textContent.trim(),
|
||||||
|
I18n.t("poll.public.title").replace(/<\/?[^>]+(>|$)/g, ""),
|
||||||
|
"displays the public label"
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue