The poll breakdown modal replaces the grouped pie charts feature.
Includes:
* MODAL: Untangle `onSelectPanel`
Previously modal-tab component would call on click the onSelectPanel callback with itself (modal-tab) as `this` which severely limited its usefulness. Now showModal binds the callback to its controller.
"The PR includes a fix/change to d-modal (b7f6ec6) that hasn't been extracted to a separate PR because it's not currently possible to test a change like this in abstract, i.e. with dynamically created controllers/components in tests. The percentage/count toggle test for the poll breakdown feature is essentially a test for that d-modal modification."
30 lines
808 B
JavaScript
30 lines
808 B
JavaScript
import I18n from "I18n";
|
|
import Component from "@ember/component";
|
|
import { equal } from "@ember/object/computed";
|
|
import { propertyEqual } from "discourse/lib/computed";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
export default Component.extend({
|
|
tagName: "li",
|
|
classNames: ["modal-tab"],
|
|
panel: null,
|
|
selectedPanel: null,
|
|
panelsLength: null,
|
|
classNameBindings: ["isActive", "singleTab", "panel.id"],
|
|
singleTab: equal("panelsLength", 1),
|
|
isActive: propertyEqual("panel.id", "selectedPanel.id"),
|
|
|
|
@discourseComputed("panel.title", "panel.rawTitle")
|
|
title(title, rawTitle) {
|
|
return title ? I18n.t(title) : rawTitle;
|
|
},
|
|
|
|
click() {
|
|
this.set("selectedPanel", this.panel);
|
|
|
|
if (this.onSelectPanel) {
|
|
this.onSelectPanel(this.panel);
|
|
}
|
|
}
|
|
});
|