FIX: Show title on results of all poll types (#11041)
Previously, the title was shown only with pie chart results. Issue originally reported in https://meta.discourse.org/t/keep-the-heading-visible-when-showing-poll-results/167585 Also includes: UX: Move the "Show breakdown" button (Display it with other poll buttons at the bottom) FIX: Show the breakdown button only on any votes
This commit is contained in:
parent
d6e0c09e89
commit
690a38bc9b
|
@ -347,12 +347,20 @@ createWidget("discourse-poll-container", {
|
||||||
const options = poll.get("options");
|
const options = poll.get("options");
|
||||||
|
|
||||||
if (attrs.showResults) {
|
if (attrs.showResults) {
|
||||||
|
const contents = [];
|
||||||
|
|
||||||
|
if (attrs.titleHTML) {
|
||||||
|
contents.push(new RawHtml({ html: attrs.titleHTML }));
|
||||||
|
}
|
||||||
|
|
||||||
const type = poll.get("type") === "number" ? "number" : "standard";
|
const type = poll.get("type") === "number" ? "number" : "standard";
|
||||||
const resultsWidget =
|
const resultsWidget =
|
||||||
type === "number" || attrs.poll.chart_type !== PIE_CHART_TYPE
|
type === "number" || attrs.poll.chart_type !== PIE_CHART_TYPE
|
||||||
? `discourse-poll-${type}-results`
|
? `discourse-poll-${type}-results`
|
||||||
: "discourse-poll-pie-chart";
|
: "discourse-poll-pie-chart";
|
||||||
return this.attach(resultsWidget, attrs);
|
contents.push(this.attach(resultsWidget, attrs));
|
||||||
|
|
||||||
|
return contents;
|
||||||
} else if (options) {
|
} else if (options) {
|
||||||
const contents = [];
|
const contents = [];
|
||||||
|
|
||||||
|
@ -495,6 +503,7 @@ createWidget("discourse-poll-pie-canvas", {
|
||||||
|
|
||||||
createWidget("discourse-poll-pie-chart", {
|
createWidget("discourse-poll-pie-chart", {
|
||||||
tagName: "div.poll-results-chart",
|
tagName: "div.poll-results-chart",
|
||||||
|
|
||||||
html(attrs) {
|
html(attrs) {
|
||||||
const contents = [];
|
const contents = [];
|
||||||
|
|
||||||
|
@ -503,20 +512,6 @@ createWidget("discourse-poll-pie-chart", {
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.groupableUserFields.length) {
|
|
||||||
const button = this.attach("button", {
|
|
||||||
className: "btn-default poll-show-breakdown",
|
|
||||||
label: "poll.group-results.label",
|
|
||||||
title: "poll.group-results.title",
|
|
||||||
icon: "far-eye",
|
|
||||||
action: "showBreakdown",
|
|
||||||
});
|
|
||||||
|
|
||||||
contents.push(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
contents.push(new RawHtml({ html: attrs.titleHTML }));
|
|
||||||
|
|
||||||
const chart = this.attach("discourse-poll-pie-canvas", attrs);
|
const chart = this.attach("discourse-poll-pie-canvas", attrs);
|
||||||
contents.push(chart);
|
contents.push(chart);
|
||||||
|
|
||||||
|
@ -626,6 +621,18 @@ createWidget("discourse-poll-buttons", {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attrs.groupableUserFields.length && poll.voters > 0) {
|
||||||
|
const button = this.attach("button", {
|
||||||
|
className: "btn-default poll-show-breakdown",
|
||||||
|
label: "poll.group-results.label",
|
||||||
|
title: "poll.group-results.title",
|
||||||
|
icon: "far-eye",
|
||||||
|
action: "showBreakdown",
|
||||||
|
});
|
||||||
|
|
||||||
|
contents.push(button);
|
||||||
|
}
|
||||||
|
|
||||||
if (isAdmin && dataExplorerEnabled && poll.voters > 0 && exportQueryID) {
|
if (isAdmin && dataExplorerEnabled && poll.voters > 0 && exportQueryID) {
|
||||||
contents.push(
|
contents.push(
|
||||||
this.attach("button", {
|
this.attach("button", {
|
||||||
|
|
|
@ -128,7 +128,7 @@ div.poll {
|
||||||
|
|
||||||
.pie-chart-legends {
|
.pie-chart-legends {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 10px 0;
|
margin-top: 0.5em;
|
||||||
|
|
||||||
.legend {
|
.legend {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -149,7 +149,6 @@ div.poll {
|
||||||
}
|
}
|
||||||
|
|
||||||
.poll-results-chart {
|
.poll-results-chart {
|
||||||
height: 340px;
|
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ div.poll {
|
||||||
|
|
||||||
.poll-title {
|
.poll-title {
|
||||||
border-bottom: 1px solid var(--primary-low);
|
border-bottom: 1px solid var(--primary-low);
|
||||||
|
margin-bottom: 0.5em;
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue