DEV: Allow `{{d-button}}` to include a href

This commit is contained in:
Robin Ward 2019-06-10 13:24:15 -04:00
parent 62345a7f8d
commit 86f3e74799
1 changed files with 15 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import { default as computed } from "ember-addons/ember-computed-decorators"; import { default as computed } from "ember-addons/ember-computed-decorators";
import DiscourseURL from "discourse/lib/url";
export default Ember.Component.extend({ export default Ember.Component.extend({
// subclasses need this // subclasses need this
@ -53,12 +54,20 @@ export default Ember.Component.extend({
}, },
click() { click() {
if (typeof this.action === "string") { let { action } = this;
this.sendAction("action", this.actionParam);
} else if (typeof this.action === "object" && this.action.value) { if (action) {
this.action.value(this.actionParam); if (typeof action === "string") {
} else if (typeof this.action === "function") { this.sendAction("action", this.actionParam);
this.action(this.actionParam); } else if (typeof action === "object" && action.value) {
action.value(this.actionParam);
} else if (typeof this.action === "function") {
action(this.actionParam);
}
}
if (this.href && this.href.length) {
DiscourseURL.routeTo(this.href);
} }
return false; return false;