Skip to content

Commit

Permalink
Chore: Renaming AnnotationThread.thread to AnnotationThread.threadNum…
Browse files Browse the repository at this point in the history
…ber (#241)
  • Loading branch information
pramodsum authored Jul 26, 2017
1 parent 11b1802 commit 66b1d7c
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/lib/annotations/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Annotation {
this.annotationID = data.annotationID;
this.fileVersionId = data.fileVersionId;
this.threadID = data.threadID;
this.thread = data.thread;
this.threadNumber = data.threadNumber;
this.type = data.type;
this.text = data.text;
this.location = data.location;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/AnnotationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class AnnotationDialog extends EventEmitter {

// Adding thread number to dialog
if (annotations.length > 0) {
this.element.dataset.threadNumber = annotations[0].thread;
this.element.dataset.threadNumber = annotations[0].threadNumber;
}

this.bindDOMListeners();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/annotations/AnnotationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AnnotationService extends EventEmitter {
threadID: annotation.threadID
},
message: annotation.text,
thread: annotation.thread
threadNumber: annotation.threadNumber
})
})
.then((response) => response.json())
Expand Down Expand Up @@ -227,7 +227,7 @@ class AnnotationService extends EventEmitter {
fileVersionId: data.item.id,
threadID: data.details.threadID,
type: data.details.type,
thread: data.thread,
threadNumber: data.thread,
text: data.message,
location: data.details.location,
user: {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/annotations/AnnotationThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AnnotationThread extends EventEmitter {
this.fileVersionId = data.fileVersionId;
this.location = data.location;
this.threadID = data.threadID || AnnotationService.generateID();
this.thread = data.thread || '';
this.threadNumber = data.threadNumber || '';
this.type = data.type;
this.locale = data.locale;
this.isMobile = data.isMobile;
Expand Down Expand Up @@ -158,8 +158,8 @@ class AnnotationThread extends EventEmitter {
}

// Add thread number to associated dialog and thread
this.thread = this.thread || savedAnnotation.thread;
this.dialog.element.dataset.threadNumber = this.thread;
this.threadNumber = this.threadNumber || savedAnnotation.threadNumber;
this.dialog.element.dataset.threadNumber = this.threadNumber;

// Otherwise, replace temporary annotation with annotation saved to server
this.annotations[tempIdx] = savedAnnotation;
Expand Down Expand Up @@ -454,7 +454,7 @@ class AnnotationThread extends EventEmitter {
location: this.location,
user: this.annotationService.user,
threadID: this.threadID,
thread: this.thread
threadNumber: this.threadNumber
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/__tests__/AnnotationDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ describe('lib/annotations/AnnotationDialog', () => {
text: 'blah',
user: {},
permissions: {},
thread: 1
threadNumber: 1
});

dialog.isMobile = false;
Expand Down
44 changes: 22 additions & 22 deletions src/lib/annotations/__tests__/AnnotationService-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('lib/annotations/AnnotationService', () => {
fileVersionId: 2,
threadID: AnnotationService.generateID(),
type: 'point',
thread: '1',
threadNumber: '1',
text: 'blah',
location: { x: 0, y: 0 }
});
Expand All @@ -60,7 +60,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: annotationToSave.threadID,
location: annotationToSave.location
},
thread: annotationToSave.thread,
thread: annotationToSave.threadNumber,
message: annotationToSave.text,
created_by: {}
}
Expand All @@ -70,7 +70,7 @@ describe('lib/annotations/AnnotationService', () => {
return annotationService.create(annotationToSave).then((createdAnnotation) => {
expect(createdAnnotation.fileVersionId).to.equal(annotationToSave.fileVersionId);
expect(createdAnnotation.threadID).to.equal(annotationToSave.threadID);
expect(createdAnnotation.thread).to.equal(annotationToSave.thread);
expect(createdAnnotation.threadNumber).to.equal(annotationToSave.threadNumber);
expect(createdAnnotation.type).to.equal(annotationToSave.type);
expect(createdAnnotation.text).to.equal(annotationToSave.text);
expect(createdAnnotation.location.x).to.equal(annotationToSave.location.x);
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'point',
text: 'blah',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 }
});

Expand All @@ -119,7 +119,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'highlight',
text: 'blah2',
thread: '2',
threadNumber: '2',
location: { x: 0, y: 0 }
});

Expand All @@ -137,7 +137,7 @@ describe('lib/annotations/AnnotationService', () => {
location: annotation1.location
},
message: annotation1.text,
thread: annotation1.thread,
thread: annotation1.threadNumber,
created_by: {}
},
{
Expand All @@ -151,7 +151,7 @@ describe('lib/annotations/AnnotationService', () => {
location: annotation2.location
},
message: annotation2.text,
thread: annotation2.thread,
threadNumber: annotation2.threadNumber,
created_by: {}
}
]
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'point',
text: 'blah',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 }
});

Expand All @@ -237,7 +237,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'point',
text: 'blah2',
thread: '2',
threadNumber: '2',
location: { x: 0, y: 0 }
});

Expand All @@ -246,7 +246,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: annotation1.threadID,
type: 'point',
text: 'blah3',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 }
});

Expand All @@ -255,8 +255,8 @@ describe('lib/annotations/AnnotationService', () => {
return annotationService.getThreadMap(2).then((threadMap) => {
expect(threadMap[annotation1.threadID].length).to.equal(2);
expect(threadMap[annotation2.threadID][0]).to.contain(annotation2);
expect(threadMap[annotation1.threadID][0].thread).to.equal(threadMap[annotation1.threadID][1].thread);
expect(threadMap[annotation1.threadID][0].thread).to.not.equal(
expect(threadMap[annotation1.threadID][0].threadNumber).to.equal(threadMap[annotation1.threadID][1].threadNumber);
expect(threadMap[annotation1.threadID][0].threadNumber).to.not.equal(
threadMap[annotation2.threadID][0].thread
);
});
Expand All @@ -273,7 +273,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'point',
text: 'blah',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: '2016-10-29T14:19:56'
});
Expand All @@ -284,7 +284,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: annotation1.threadID,
type: 'point',
text: 'blah4',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: '2016-10-30T14:19:56'
});
Expand All @@ -294,7 +294,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'point',
text: 'blah2',
thread: '2',
threadNumber: '2',
location: { x: 0, y: 0 },
created: '2016-10-30T14:19:56'
});
Expand All @@ -304,7 +304,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: annotation1.threadID,
type: 'point',
text: 'blah3',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: '2016-10-31T14:19:56'
});
Expand All @@ -314,8 +314,8 @@ describe('lib/annotations/AnnotationService', () => {
expect(threadMap[annotation1.threadID].length).to.equal(3);
expect(threadMap[annotation1.threadID][0]).to.equal(annotation1);
expect(threadMap[annotation1.threadID][1]).to.equal(annotation4);
expect(threadMap[annotation1.threadID][0].thread).to.equal(threadMap[annotation1.threadID][1].thread);
expect(threadMap[annotation1.threadID][0].thread).to.not.equal(threadMap[annotation2.threadID][0].thread);
expect(threadMap[annotation1.threadID][0].threadNumber).to.equal(threadMap[annotation1.threadID][1].threadNumber);
expect(threadMap[annotation1.threadID][0].threadNumber).to.not.equal(threadMap[annotation2.threadID][0].threadNumber);
});
});

Expand All @@ -326,7 +326,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: 1,
type: 'point',
text: 'blah3',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: Date.now(),
item: { id: 1 },
Expand All @@ -348,7 +348,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: AnnotationService.generateID(),
type: 'highlight',
text: 'blah2',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 }
});

Expand All @@ -365,7 +365,7 @@ describe('lib/annotations/AnnotationService', () => {
threadID: annotation2.threadID,
location: annotation2.location
},
thread: annotation2.thread,
thread: annotation2.threadNumber,
message: annotation2.text,
created_by: {}
}
Expand All @@ -385,7 +385,7 @@ describe('lib/annotations/AnnotationService', () => {
promise.then((result) => {
expect(result.length).to.equal(1);
expect(result[0].text).to.equal(annotation2.text);
expect(result[0].thread).to.equal(annotation2.thread);
expect(result[0].threadNumber).to.equal(annotation2.threadNumber);
});
});

Expand Down
16 changes: 8 additions & 8 deletions src/lib/annotations/__tests__/AnnotationThread-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('lib/annotations/AnnotationThread', () => {
isMobile: false,
location: {},
threadID: '2',
thread: '1',
threadNumber: '1',
type: 'point'
});

Expand Down Expand Up @@ -137,7 +137,7 @@ describe('lib/annotations/AnnotationThread', () => {
fileVersionId: '1',
location: {},
threadID: '2',
thread: '1',
threadNumber: '1',
type: 'point'
});

Expand All @@ -154,7 +154,7 @@ describe('lib/annotations/AnnotationThread', () => {
type: 'point',
text: 'blah',
threadID: '2',
thread: '1'
threadNumber: '1'
})
);
expect(thread.state).to.equal(STATES.hover);
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('lib/annotations/AnnotationThread', () => {
isMobile: false,
location: {},
threadID: '2',
thread: '1',
threadNumber: '1',
type: 'point'
});

Expand Down Expand Up @@ -356,7 +356,7 @@ describe('lib/annotations/AnnotationThread', () => {
isMobile: false,
location: {},
threadID: '2',
thread: '1',
threadNumber: '1',
type: 'point'
});

Expand Down Expand Up @@ -508,7 +508,7 @@ describe('lib/annotations/AnnotationThread', () => {
threadID: '1',
type: 'point',
text: 'blah',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: Date.now()
});
Expand All @@ -528,7 +528,7 @@ describe('lib/annotations/AnnotationThread', () => {
threadID: '1',
type: 'point',
text: 'blah',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: Date.now()
});
Expand All @@ -545,7 +545,7 @@ describe('lib/annotations/AnnotationThread', () => {
threadID: '1',
type: 'point',
text: 'blah',
thread: '1',
threadNumber: '1',
location: { x: 0, y: 0 },
created: Date.now()
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class DocAnnotator extends Annotator {
// Set existing thread ID if created with annotations
if (annotations.length > 0) {
threadParams.threadID = annotations[0].threadID;
threadParams.thread = annotations[0].thread;
threadParams.threadNumber = annotations[0].threadNumber;
}

if (!annotatorUtil.validateThreadParams(threadParams)) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/doc/DocHighlightDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class DocHighlightDialog extends AnnotationDialog {

// Adding thread number to dialog
if (annotations.length > 0) {
this.element.dataset.threadNumber = annotations[0].thread;
this.element.dataset.threadNumber = annotations[0].threadNumber;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/annotations/doc/__tests__/DocAnnotator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ describe('lib/annotations/doc/DocAnnotator', () => {
fileVersionId: 2,
threadID: '1',
type: TYPES.point,
thread: '1',
threadNumber: '1',
text: 'blah',
location: { x: 0, y: 0 }
});
const thread = annotator.createAnnotationThread([annotation], {}, TYPES.highlight);

expect(stubs.addThread).to.have.been.called;
expect(thread.threadID).to.equal(annotation.threadID);
expect(thread.thread).to.equal(annotation.thread);
expect(thread.threadNumber).to.equal(annotation.threadNumber);
expect(thread instanceof DocHighlightThread).to.be.true;
expect(annotator.handleValidationError).to.not.be.called;
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/annotations/doc/__tests__/DocHighlightDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('lib/annotations/doc/DocHighlightDialog', () => {
permissions: {
can_delete: true
},
thread: 1
threadNumber: 1
});
stubs.show = sandbox.stub(annotatorUtil, 'showElement');
stubs.hide = sandbox.stub(annotatorUtil, 'hideElement');
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('lib/annotations/doc/DocHighlightDialog', () => {
permissions: {
can_delete: true
},
thread: 1
threadNumber: 1
});

dialog.setup([annotation]);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/drawing/DrawingThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class DrawingThread extends AnnotationThread {
fileVersionId: this.fileVersionId,
user: this.annotationService.user,
threadID: this.threadID,
thread: this.thread
threadNumber: this.threadNumber
};
}
}
Expand Down

0 comments on commit 66b1d7c

Please sign in to comment.