commentElem.parentNode.removeChild(commentElem);
window.$events.emit('success', window.trans('entities.comment_deleted_success'));
this.updateCount();
+ this.hideForm();
});
}
showForm() {
this.formContainer.style.display = 'block';
this.formContainer.parentNode.style.display = 'block';
- this.elem.querySelector('[comment-add-button]').style.display = 'none';
+ this.elem.querySelector('[comment-add-button-container]').style.display = 'none';
this.formInput.focus();
window.scrollToElement(this.formInput);
}
hideForm() {
this.formContainer.style.display = 'none';
this.formContainer.parentNode.style.display = 'none';
- this.elem.querySelector('[comment-add-button]').style.display = 'block';
+ const addButtonContainer = this.elem.querySelector('[comment-add-button-container]');
+ if (this.getCommentCount() > 0) {
+ this.elem.appendChild(addButtonContainer)
+ } else {
+ const countBar = this.elem.querySelector('[comment-count-bar]');
+ countBar.appendChild(addButtonContainer);
+ }
+ addButtonContainer.style.display = 'block';
+ }
+
+ getCommentCount() {
+ return this.elem.querySelectorAll('.comment-box[comment]').length;
}
setReply(commentElem) {