mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 12:26:04 +08:00
DEV: Remove buffered rendering from input tips
This is another refactoring in the multi-step process to remove all uses of our custom Render Buffer. Previous commit: 2290ec9e87ab005fcb6666c1448bdbe4e7b92bd6 in this series. This commit affects the display of input tips. It is just a refactor and does not change any functionality.
This commit is contained in:
@ -1,21 +1,30 @@
|
|||||||
import { alias, not } from "@ember/object/computed";
|
import { alias, not } from "@ember/object/computed";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
|
|
||||||
export default Component.extend(
|
export default Component.extend({
|
||||||
bufferedRender({
|
classNameBindings: [":tip", "good", "bad"],
|
||||||
classNameBindings: [":tip", "good", "bad"],
|
rerenderTriggers: ["validation"],
|
||||||
rerenderTriggers: ["validation"],
|
tipIcon: null,
|
||||||
|
tipReason: null,
|
||||||
|
|
||||||
bad: alias("validation.failed"),
|
bad: alias("validation.failed"),
|
||||||
good: not("bad"),
|
good: not("bad"),
|
||||||
|
|
||||||
buildBuffer(buffer) {
|
tipIconHTML() {
|
||||||
const reason = this.get("validation.reason");
|
let icon = iconHTML(this.good ? "check" : "times");
|
||||||
if (reason) {
|
return `${icon}`.htmlSafe();
|
||||||
buffer.push(iconHTML(this.good ? "check" : "times") + " " + reason);
|
},
|
||||||
}
|
|
||||||
|
didReceiveAttrs() {
|
||||||
|
this._super(...arguments);
|
||||||
|
let reason = this.get("validation.reason");
|
||||||
|
if (reason) {
|
||||||
|
this.set("tipIcon", this.tipIconHTML());
|
||||||
|
this.set("tipReason", reason);
|
||||||
|
} else {
|
||||||
|
this.set("tipIcon", null);
|
||||||
|
this.set("tipReason", null);
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
);
|
});
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{{tipIcon}} {{tipReason}}
|
Reference in New Issue
Block a user