2020-02-19 11:57:59 -05:00
|
|
|
import { default as computed, on } from "discourse-common/utils/decorators";
|
2019-10-28 15:32:09 -04:00
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
classNames: ["share-report"],
|
|
|
|
|
|
|
|
group: null,
|
|
|
|
query: null,
|
|
|
|
visible: false,
|
|
|
|
|
|
|
|
@computed("group", "query")
|
|
|
|
link() {
|
2019-10-28 21:34:08 -04:00
|
|
|
return Discourse.BaseUrl + "/g/" + this.group + "/reports/" + this.query.id;
|
2019-10-28 15:32:09 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_mouseDownHandler(event) {
|
|
|
|
if (!this.element || this.isDestroying || this.isDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ($(this.element).has(event.target).length !== 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.send("close");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_keydownHandler(event) {
|
|
|
|
if (!this.element || this.isDestroying || this.isDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.keyCode === 27) {
|
|
|
|
this.send("close");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
@on("init")
|
|
|
|
_setupHandlers() {
|
|
|
|
this._boundMouseDownHandler = Ember.run.bind(this, this._mouseDownHandler);
|
|
|
|
this._boundKeydownHandler = Ember.run.bind(this, this._keydownHandler);
|
|
|
|
},
|
|
|
|
|
|
|
|
didInsertElement() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
$("html")
|
|
|
|
.on("mousedown.outside-share-link", this._boundMouseDownHandler)
|
|
|
|
.on("keydown.share-view", this._boundKeydownHandler);
|
|
|
|
},
|
|
|
|
|
|
|
|
willDestroyElement() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
$("html")
|
|
|
|
.off("mousedown.outside-share-link", this._boundMouseDownHandler)
|
|
|
|
.off("keydown.share-view", this._boundKeydownHandler);
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2019-10-28 17:13:43 -04:00
|
|
|
open() {
|
2019-10-28 15:32:09 -04:00
|
|
|
this.set("visible", true);
|
|
|
|
window.setTimeout(
|
|
|
|
() =>
|
|
|
|
$(this.element)
|
|
|
|
.find("input")
|
|
|
|
.select()
|
|
|
|
.focus(),
|
|
|
|
160
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2019-10-28 17:13:43 -04:00
|
|
|
close() {
|
2019-10-28 15:32:09 -04:00
|
|
|
this.set("visible", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|