mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-23 22:21:54 +08:00
Comments: Started archive display, created mode for tree node
Some checks failed
test-js / build (push) Has been cancelled
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-migrations / build (8.4) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
test-php / build (8.4) (push) Has been cancelled
Some checks failed
test-js / build (push) Has been cancelled
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-migrations / build (8.4) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
test-php / build (8.4) (push) Has been cancelled
This commit is contained in:
@ -137,10 +137,12 @@ export class PageComment extends Component {
|
||||
protected async archive(): Promise<void> {
|
||||
this.showLoading();
|
||||
const isArchived = this.archiveButton.dataset.isArchived === 'true';
|
||||
const action = isArchived ? 'unarchive' : 'archive';
|
||||
|
||||
await window.$http.put(`/comment/${this.commentId}/${isArchived ? 'unarchive' : 'archive'}`);
|
||||
this.$emit('archive');
|
||||
const response = await window.$http.put(`/comment/${this.commentId}/${action}`);
|
||||
this.$emit(action, {new_thread_dom: htmlToDom(response.data as string)});
|
||||
window.$events.success(this.archiveText);
|
||||
this.container.closest('.comment-branch')?.remove();
|
||||
}
|
||||
|
||||
protected showLoading(): HTMLElement {
|
||||
|
@ -9,6 +9,12 @@ export interface CommentReplyEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
export interface ArchiveEvent extends Event {
|
||||
detail: {
|
||||
new_thread_dom: HTMLElement;
|
||||
}
|
||||
}
|
||||
|
||||
export class PageComments extends Component {
|
||||
|
||||
private elem: HTMLElement;
|
||||
@ -17,6 +23,7 @@ export class PageComments extends Component {
|
||||
private commentCountBar: HTMLElement;
|
||||
private commentsTitle: HTMLElement;
|
||||
private addButtonContainer: HTMLElement;
|
||||
private archiveContainer: HTMLElement;
|
||||
private replyToRow: HTMLElement;
|
||||
private formContainer: HTMLElement;
|
||||
private form: HTMLFormElement;
|
||||
@ -43,6 +50,7 @@ export class PageComments extends Component {
|
||||
this.commentCountBar = this.$refs.commentCountBar;
|
||||
this.commentsTitle = this.$refs.commentsTitle;
|
||||
this.addButtonContainer = this.$refs.addButtonContainer;
|
||||
this.archiveContainer = this.$refs.archiveContainer;
|
||||
this.replyToRow = this.$refs.replyToRow;
|
||||
this.formContainer = this.$refs.formContainer;
|
||||
this.form = this.$refs.form as HTMLFormElement;
|
||||
@ -75,6 +83,14 @@ export class PageComments extends Component {
|
||||
this.setReply(event.detail.id, event.detail.element);
|
||||
});
|
||||
|
||||
this.elem.addEventListener('page-comment-archive', (event: ArchiveEvent) => {
|
||||
this.archiveContainer.append(event.detail.new_thread_dom);
|
||||
});
|
||||
|
||||
this.elem.addEventListener('page-comment-unarchive', (event: ArchiveEvent) => {
|
||||
this.container.append(event.detail.new_thread_dom)
|
||||
});
|
||||
|
||||
if (this.form) {
|
||||
this.removeReplyToButton.addEventListener('click', this.removeReplyTo.bind(this));
|
||||
this.hideFormButton.addEventListener('click', this.hideForm.bind(this));
|
||||
|
Reference in New Issue
Block a user