-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temp hide show ui for plain and comment highlights #348
Temp hide show ui for plain and comment highlights #348
Conversation
@@ -7,7 +7,7 @@ const ANNOTATORS = [ | |||
NAME: 'Document', | |||
CONSTRUCTOR: DocAnnotator, | |||
VIEWER: ['Document', 'Presentation'], | |||
TYPE: [TYPES.point, TYPES.highlight] | |||
TYPE: [TYPES.point, TYPES.highlight, TYPES.highlight_comment] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@@ -315,6 +312,39 @@ class CreateHighlightDialog extends EventEmitter { | |||
* @return {HTMLElement} The element containing Highlight creation UI | |||
*/ | |||
createElement() { | |||
const caretTemplate = this.isMobile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move these templates out into constants somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would've made more sense than what I did :D DONE!
this.highlightCreateEl.addEventListener('click', this.onHighlightClick); | ||
|
||
if (this.hasTouch) { | ||
this.highlightCreateEl.addEventListener('touchstart', this.stopPropagation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move the adding of these 2 event handlers into its own method? so you can just call it anywhere on w/e element you pass in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this'd be valid for the touchend
-> highlightClick
event binding, as it only ever happens once. Would it be valid abstracting the binding for stopPropagation()
?
Maybe instead of
element.addEventListener('event', this.stopPropagation);
We'd do
this.bindStopPropagation(element, event);
Though, after seeing it, I'm not sure what the benefit of that is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm true. I guess it wouldn't really clean up too much.
if (this.commentHighlightEnabled) { | ||
this.highlightCurrentSelection = this.highlightCurrentSelection.bind(this); | ||
this.createHighlightDialog.addListener(CreateEvents.comment, this.highlightCurrentSelection); | ||
this.createHighlightThread = this.createHighlightThread.bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line before this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -390,7 +423,17 @@ class DocAnnotator extends Annotator { | |||
// Scale existing canvases on re-render | |||
this.scaleAnnotationCanvases(pageNum); | |||
|
|||
super.renderAnnotationsOnPage(pageNum); | |||
if (this.threads && this.threads[pageNum]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually if you just leave the call to super.renderAnnotationsOnPage(pageNum)
We can modify annotator.renderAnnotationsOnPage() to this since w/e annotation types aren't supported will get filtered out w/ the call to this.isModeAnnotatable(thread.type)
renderAnnotationsOnPage(pageNum) {
if (this.threads && this.threads[pageNum]) {
this.threads[pageNum].forEach((thread) => {
if (!this.isModeAnnotatable(thread.type)) {
return;
}
thread.show();
});
}
}
Plus then it'll be applicable to any other annotation types we don't want to render :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if there's anywhere else we can just make calls to isModeAnnotatable()
to Annotator or AnnotationThread methods to clean up some of hackier logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll override the super call to do this, but I still have to not call it, as we're calling our butchered version of show()
that takes in the flags for plain and comment highlights
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a ticket for the cleanup, as I don't want this task to turn into a refactor/cleanup PR. Then we can do it, next
…ew into Temp-hide-show-ui-for-plain-and-comment-highlights
…ew into Temp-hide-show-ui-for-plain-and-comment-highlights
@@ -751,7 +800,7 @@ class DocAnnotator extends Annotator { | |||
// hovered over at the same time, only the top-most highlight | |||
// dialog will be displayed and the others will be hidden | |||
// without delay | |||
delayThreads.forEach(showFirstDialogFilter); | |||
delayThreads.forEach(showFirstDialogFilter.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this able to be bound elsewhere?
…github.com:JustinHoldstock/box-content-preview into Temp-hide-show-ui-for-plain-and-comment-highlights
…ew into Temp-hide-show-ui-for-plain-and-comment-highlights
…github.com:JustinHoldstock/box-content-preview into Temp-hide-show-ui-for-plain-and-comment-highlights
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.commentBox = new CommentBox(containerEl); | ||
this.commentCreateEl = containerEl.querySelector(`.${constants.CLASS_ADD_HIGHLIGHT_COMMENT_BTN}`); | ||
this.commentCreateEl.addEventListener('click', this.onCommentClick); | ||
// Event listeners |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line above comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// Event listeners | ||
this.commentBox.addListener(CommentBox.CommentEvents.post, this.onCommentPost); | ||
this.commentBox.addListener(CommentBox.CommentEvents.cancel, this.onCommentCancel); | ||
// Hide comment box, by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line before comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -122,12 +149,19 @@ class DocAnnotator extends Annotator { | |||
*/ | |||
destroy() { | |||
super.destroy(); | |||
if (this.createHighlightDialog) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!this.createHighlightDialog) {
return;
}
@@ -485,7 +542,11 @@ class DocAnnotator extends Annotator { | |||
this.highlightThrottleHandle = null; | |||
} | |||
|
|||
if (this.hasTouch && this.isMobile) { | |||
if (!this.canAnnotate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now stored as this.permissions.canAnnotate
. Update this around the code! See https://github.com/box/box-content-preview/blob/master/src/lib/annotations/Annotator.js#L70
if (showPlain) { | ||
annotatorUtil.showElement(plainButtonEl); | ||
} else { | ||
annotatorUtil.hideElement(plainButtonEl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wouldn't ever show the plain highlight dialog AND the comments dialog correct? Can we combine these 2 if/else statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is for only showing/hiding the buttons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right not showing/hiding specific types of dialogs. got it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ew into Temp-hide-show-ui-for-plain-and-comment-highlights
@@ -485,6 +547,10 @@ class DocAnnotator extends Annotator { | |||
this.highlightThrottleHandle = null; | |||
} | |||
|
|||
if (!this.permissions.canAnnotate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it's unnecessary to remove it, as we don't want to be removing event listeners that don't exist. I'm not sure what our standard is for that. @jeremypress @tonyjin @minhhnguyen Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's safe to remove event listeners that don't exist. I'd personally prefer fewer lines of code over adding a guard before removing event listeners but I don't think this is something we need to standardize on.
if (showPlain) { | ||
annotatorUtil.showElement(plainButtonEl); | ||
} else { | ||
annotatorUtil.hideElement(plainButtonEl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right not showing/hiding specific types of dialogs. got it
} | ||
|
||
// TODO (@jholdstock|@spramod) remove this if statement, and make super call, upon refactor. | ||
const pageThreads = this.getThreadsOnPage(pageNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point, isn't this the same as calling super.renderAnnotationsOnPage()
? Since that also checks isModeAnnotatable(type)
and that's essentially when this.plainHighlightEnabled
and this.commentHighlightEnabled
is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the override is passing in the two flags, which are not done in the parent class
thread.show(this.plainHighlightEnabled, this.commentHighlightEnabled);
Conflicts were easy peasy!
…ew into Temp-hide-show-ui-for-plain-and-comment-highlights
This change hides UI elements in the CRUD process of Plain and Comment highlight annotations.
THIS IS A TEMPORARY CHANGE UNTIL WE CAN PROPERLY REFACTOR COMMENT AND PLAIN HIGHLIGHTS
As always, tests to come :)