protected commentLocalId: string;
protected deletedText: string;
protected updatedText: string;
+ protected archiveText: string;
protected wysiwygEditor: any = null;
protected wysiwygLanguage: string;
protected editButton: HTMLElement;
protected deleteButton: HTMLElement;
protected replyButton: HTMLElement;
+ protected archiveButton: HTMLElement;
protected input: HTMLInputElement;
setup() {
this.commentId = this.$opts.commentId;
this.commentLocalId = this.$opts.commentLocalId;
this.deletedText = this.$opts.deletedText;
- this.updatedText = this.$opts.updatedText;
+ this.deletedText = this.$opts.deletedText;
+ this.archiveText = this.$opts.archiveText;
// Editor reference and text options
this.wysiwygLanguage = this.$opts.wysiwygLanguage;
this.editButton = this.$refs.editButton;
this.deleteButton = this.$refs.deleteButton;
this.replyButton = this.$refs.replyButton;
+ this.archiveButton = this.$refs.archiveButton;
this.input = this.$refs.input as HTMLInputElement;
this.setupListeners();
if (this.deleteButton) {
this.deleteButton.addEventListener('click', this.delete.bind(this));
}
+
+ if (this.archiveButton) {
+ this.archiveButton.addEventListener('click', this.archive.bind(this));
+ }
}
protected toggleEditMode(show: boolean) : void {
window.$events.success(this.deletedText);
}
+ protected async archive(): Promise<void> {
+ this.showLoading();
+ const isArchived = this.archiveButton.dataset.isArchived === 'true';
+
+ await window.$http.put(`/comment/${this.commentId}/${isArchived ? 'unarchive' : 'archive'}`);
+ this.$emit('archive');
+ window.$events.success(this.archiveText);
+ }
+
protected showLoading(): HTMLElement {
const loading = getLoading();
loading.classList.add('px-l');