2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2021-05-21 22:50:24 +08:00
|
|
|
import { equal } from "@ember/object/computed";
|
2020-08-27 00:57:13 +08:00
|
|
|
import bootbox from "bootbox";
|
2021-05-21 22:50:24 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2021-06-28 17:44:18 +08:00
|
|
|
import { action } from "@ember/object";
|
2021-05-21 22:50:24 +08:00
|
|
|
import I18n from "I18n";
|
2017-06-29 04:56:44 +08:00
|
|
|
|
2019-11-28 06:44:01 +08:00
|
|
|
export default Component.extend({
|
|
|
|
classNames: ["watched-word"],
|
2017-06-29 04:56:44 +08:00
|
|
|
|
2021-05-21 22:50:24 +08:00
|
|
|
isReplace: equal("actionKey", "replace"),
|
|
|
|
isTag: equal("actionKey", "tag"),
|
2021-06-02 13:36:49 +08:00
|
|
|
isLink: equal("actionKey", "link"),
|
2021-05-21 22:50:24 +08:00
|
|
|
|
|
|
|
@discourseComputed("word.replacement")
|
|
|
|
tags(replacement) {
|
|
|
|
return replacement.split(",");
|
|
|
|
},
|
|
|
|
|
2021-06-28 17:44:18 +08:00
|
|
|
@action
|
|
|
|
deleteWord() {
|
2019-11-28 06:44:01 +08:00
|
|
|
this.word
|
|
|
|
.destroy()
|
|
|
|
.then(() => {
|
|
|
|
this.action(this.word);
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
bootbox.alert(
|
|
|
|
I18n.t("generic_error_with_reason", {
|
|
|
|
error: `http: ${e.status} - ${e.body}`,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|