annotation: refectored reply node count code

now reply count node  multipurpose, it also indicates
if a comment which was being edited is collapsed

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I18a676885deea0afa30eb20505a76239e11c5493
This commit is contained in:
Pranam Lashkari 2024-03-25 20:42:09 +05:30 committed by Pranam Lashkari
parent 9981260b68
commit 5525ffab36
6 changed files with 30 additions and 32 deletions

View file

@ -544,7 +544,7 @@ nav.spreadsheet-color-indicator ~ #sidebar-dock-wrapper {
overflow: auto;
}
.cool-annotation-reply-count-collapsed {
.cool-annotation-info-collapsed {
text-align: center;
margin: 0;
padding: 0;

View file

@ -682,7 +682,7 @@ export class CommentSection extends CanvasSectionObject {
this.sectionProperties.commentList[rootIndex].sectionProperties.container.style.visibility = '';
rootIndex++;
}
rootComment.updateThreadCountIndicator();
rootComment.updateThreadInfoIndicator();
}
private collapseReplies(rootIndex: number, rootId: number) {
@ -690,8 +690,8 @@ export class CommentSection extends CanvasSectionObject {
for (var i = lastChild; i > rootIndex; i--) {
this.sectionProperties.commentList[i].sectionProperties.container.style.display = 'none';
this.sectionProperties.commentList[i].updateThreadCountIndicator();
}
this.sectionProperties.commentList[i].updateThreadInfoIndicator();
}
private cssToCorePixels(cssPixels: number) {
@ -763,9 +763,7 @@ export class CommentSection extends CanvasSectionObject {
if (this.isCollapsed) {
this.showCollapsedReplies(idx);
if (docType === 'text') {
selectedComment.sectionProperties.replyCountNode.style.display = 'none';
}
selectedComment.updateThreadInfoIndicator();
}
this.update();
@ -1381,7 +1379,7 @@ export class CommentSection extends CanvasSectionObject {
}
if (this.sectionProperties.docLayer._docType === 'text')
this.updateReplyCount();
this.updateThreadInfoIndicator();
}
public selectById (commentId: any): void {
@ -1757,11 +1755,11 @@ export class CommentSection extends CanvasSectionObject {
private update (): void {
if (this.sectionProperties.docLayer._docType === 'text')
this.updateReplyCount();
this.updateThreadInfoIndicator();
this.layout();
}
private updateReplyCount(): void {
private updateThreadInfoIndicator(): void {
for (var i = 0; i < this.sectionProperties.commentList.length; i++) {
var comment = this.sectionProperties.commentList[i];
var replyCount = 0;
@ -1783,9 +1781,9 @@ export class CommentSection extends CanvasSectionObject {
}
}
if (anyEdit)
comment.updateThreadCountIndicator('!');
comment.updateThreadInfoIndicator('!');
else
comment.updateThreadCountIndicator(replyCount);
comment.updateThreadInfoIndicator(replyCount);
}
}

View file

@ -275,8 +275,8 @@ export class Comment extends CanvasSectionObject {
imgAuthor.setAttribute('height', this.sectionProperties.imgSize[1]);
if (this.sectionProperties.docLayer._docType !== 'spreadsheet') {
this.sectionProperties.replyCountNode = L.DomUtil.create('div', 'cool-annotation-reply-count-collapsed', tdImg);
this.sectionProperties.replyCountNode.style.display = 'none';
this.sectionProperties.collapsedInfoNode = L.DomUtil.create('div', 'cool-annotation-info-collapsed', tdImg);
this.sectionProperties.collapsedInfoNode.style.display = 'none';
}
this.sectionProperties.authorAvatarImg = imgAuthor;
@ -687,7 +687,7 @@ export class Comment extends CanvasSectionObject {
this.sectionProperties.contentNode.style.display = '';
this.sectionProperties.nodeModify.style.display = 'none';
this.sectionProperties.nodeReply.style.display = 'none';
this.sectionProperties.replyCountNode.style.visibility = '';
this.sectionProperties.collapsedInfoNode.style.visibility = '';
this.sectionProperties.showSelectedCoordinate = true;
}
@ -1368,7 +1368,7 @@ export class Comment extends CanvasSectionObject {
this.sectionProperties.container.style.display = '';
this.sectionProperties.container.style.visibility = 'hidden';
}
this.updateThreadCountIndicator();
this.updateThreadInfoIndicator();
if (this.sectionProperties.data.resolved === 'false'
|| this.sectionProperties.commentListSection.sectionProperties.showResolved
|| this.sectionProperties.docLayer._docType === 'presentation'
@ -1376,21 +1376,21 @@ export class Comment extends CanvasSectionObject {
L.DomUtil.addClass(this.sectionProperties.container, 'cool-annotation-collapsed-show');
}
public updateThreadCountIndicator(replycount:number | string = -1): void {
public updateThreadInfoIndicator(replycount:number | string = -1): void {
if (this.sectionProperties.docLayer._docType === 'spreadsheet')
return;
if (this.isEdit())
this.sectionProperties.replyCountNode.innerText = '!';
this.sectionProperties.collapsedInfoNode.innerText = '!';
else if (replycount === '!' || typeof replycount === "number" && replycount > 0)
this.sectionProperties.replyCountNode.innerText = replycount;
this.sectionProperties.collapsedInfoNode.innerText = replycount;
else
this.sectionProperties.replyCountNode.innerText = '';
this.sectionProperties.collapsedInfoNode.innerText = '';
if (this.sectionProperties.replyCountNode.innerText === '' || this.isContainerVisible())
this.sectionProperties.replyCountNode.style.display = 'none';
else if ((!this.isContainerVisible() && this.sectionProperties.replyCountNode.innerText !== ''))
this.sectionProperties.replyCountNode.style.display = '';
if (this.sectionProperties.collapsedInfoNode.innerText === '' || this.isContainerVisible())
this.sectionProperties.collapsedInfoNode.style.display = 'none';
else if ((!this.isContainerVisible() && this.sectionProperties.collapsedInfoNode.innerText !== ''))
this.sectionProperties.collapsedInfoNode.style.display = '';
}
public setExpanded(): void {
@ -1402,7 +1402,7 @@ export class Comment extends CanvasSectionObject {
this.sectionProperties.container.style.visibility = '';
}
if (this.sectionProperties.docLayer._docType === 'text')
this.sectionProperties.replyCountNode.style.display = 'none';
this.sectionProperties.collapsedInfoNode.style.display = 'none';
L.DomUtil.removeClass(this.sectionProperties.container, 'cool-annotation-collapsed-show');
}
}

View file

@ -139,9 +139,9 @@ describe(['tagdesktop'], 'Collapsed Annotation Tests', function() {
cy.cGet('.cool-annotation-img').click();
cy.cGet('#annotation-content-area-1').should('have.text','some text0');
cy.cGet('.cool-annotation-autosavelabel').should('be.not.visible');
cy.cGet('.cool-annotation-reply-count-collapsed').should('not.have.text','!');
cy.cGet('.cool-annotation-info-collapsed').should('not.have.text','!');
cy.cGet('#map').focus();
cy.cGet('.cool-annotation-reply-count-collapsed').should('be.not.visible');
cy.cGet('.cool-annotation-info-collapsed').should('be.not.visible');
helper.closeDocument(testFileName, '');
helper.beforeAll(testFileName, 'impress', true, false, false, true);

View file

@ -127,8 +127,8 @@ describe(['tagdesktop'], 'Collapsed Annotation Tests', function() {
desktopHelper.insertComment(undefined, false);
cy.cGet('#map').focus();
helper.typeIntoDocument('{home}');
cy.cGet('.cool-annotation-reply-count-collapsed').should('have.text','!');
cy.cGet('.cool-annotation-reply-count-collapsed').should('be.visible');
cy.cGet('.cool-annotation-info-collapsed').should('have.text','!');
cy.cGet('.cool-annotation-info-collapsed').should('be.visible');
cy.cGet('.cool-annotation-img').click();
cy.cGet('.cool-annotation-autosavelabel').should('be.visible');
cy.cGet('#annotation-save-1').click();
@ -136,10 +136,10 @@ describe(['tagdesktop'], 'Collapsed Annotation Tests', function() {
cy.cGet('.cool-annotation-img').click();
cy.cGet('#annotation-content-area-1').should('have.text','some text0');
cy.cGet('.cool-annotation-autosavelabel').should('be.not.visible');
cy.cGet('.cool-annotation-reply-count-collapsed').should('not.have.text','!');
cy.cGet('.cool-annotation-info-collapsed').should('not.have.text','!');
cy.cGet('#map').focus();
helper.typeIntoDocument('{home}');
cy.cGet('.cool-annotation-reply-count-collapsed').should('be.not.visible');
cy.cGet('.cool-annotation-info-collapsed').should('be.not.visible');
helper.closeDocument(testFileName, '');
helper.beforeAll(testFileName, 'writer', true, false, false, true);

View file

@ -140,11 +140,11 @@ describe(['tagmultiuser'], 'Multiuser Annotation Tests', function () {
cy.cGet('#annotation-reply-textarea-1').type('some reply text');
cy.cGet('#annotation-reply-1').click();
cy.cGet('#annotation-content-area-2').should('contain','some reply text');
cy.cGet('#comment-container-1 .cool-annotation-reply-count-collapsed').should('have.text', '1');
cy.cGet('#comment-container-1 .cool-annotation-info-collapsed').should('have.text', '1');
cy.cSetActiveFrame('#iframe2');
cy.cGet('#annotation-content-area-2').should('contain','some reply text');
cy.cGet('#comment-container-1 .cool-annotation-reply-count-collapsed').should('have.text', '1');
cy.cGet('#comment-container-1 .cool-annotation-info-collapsed').should('have.text', '1');
});
it('Remove', function() {