Skip to content
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

New: drawing dialog #364

Merged
merged 21 commits into from
Sep 8, 2017
Merged

New: drawing dialog #364

merged 21 commits into from
Sep 8, 2017

Conversation

Minh-Ng
Copy link
Contributor

@Minh-Ng Minh-Ng commented Sep 3, 2017

Ability to save and delete drawings by selecting them and using the dialog. Also displayed while in drawing mode. Requires #362

<button class="bp-btn-plain ${constants.CLASS_ADD_DRAWING_BTN}"
title="${__('annotation_draw_save')}">
${ICON_DRAW_SAVE}
Save
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translate these strings

<button class="bp-btn-plain ${constants.CLASS_DELETE_DRAWING_BTN}"
title="${__('annotation_draw_delete')}">
${ICON_DRAW_DELETE}
Delete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well


if (this.deleteButtonEl) {
this.deleteButtonEl.addEventListener('click', this.deleteAnnotation);
this.deleteButtonEl.addEventListener('touchend', this.deleteAnnotation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe click will fire in the touch chain of things. If not we we should only add the touch listeners if the browser hasTouch

*/
setup(annotations) {
// Create outermost element container
this.element = document.createElement('div');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe refer to this as the wrapper or container so it's a little more specific? e.g. DrawingDialogContainerEl

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine for the wrapper to remain as this.element since a lot of general dialog functionality is tied to this.element. We generally keep any type specific dialogs specified separately i.e. See Point annotation dialogs for example https://github.com/box/box-content-preview/blob/master/src/lib/annotations/AnnotationDialog.js#L276 vs. highlight dialogs https://github.com/box/box-content-preview/blob/master/src/lib/annotations/doc/DocHighlightDialog.js#L253

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this dialog be set up on mobile?

Copy link
Contributor Author

@Minh-Ng Minh-Ng Sep 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work the same exact way on mobile (unless DOM trees are set up differently). The designs are the same for mobile and desktop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I meant do we need any mobile specific dialog stuff here. Assuming this will be similar to the plain highlight dialog, which has a differently styled dialogs/functionality on mobile devices

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait just noticed your comment about the design matching on mobile and desktop. This should be fine then.

* @return {void}
*/
exitAnnotationModes(mode, buttonEl) {
exitAnnotationModesExcept(mode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe exitInactiveAnnotationModes?

@@ -454,6 +454,10 @@ class DocAnnotator extends Annotator {
bindDOMListeners() {
super.bindDOMListeners();

if (!this.permissions.canAnnotate) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment on #362

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove

}

this.element.removeEventListener('click', annotatorUtil.prevDefAndStopProp);
if (this.pageEl && this.pageEl.contains(this.element)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect the page element to not have the annotation dialog at some point? I think we assume that this isn't the case for other annotation types so curious if that's possible w/ draw annotations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a correct assumption. I put this here in the case that a page was reinserted into the DOM without its child elements. (Possibly on scale/rerender or something of the sort)

*/
setup(annotations) {
// Create outermost element container
this.element = document.createElement('div');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine for the wrapper to remain as this.element since a lot of general dialog functionality is tied to this.element. We generally keep any type specific dialogs specified separately i.e. See Point annotation dialogs for example https://github.com/box/box-content-preview/blob/master/src/lib/annotations/AnnotationDialog.js#L276 vs. highlight dialogs https://github.com/box/box-content-preview/blob/master/src/lib/annotations/doc/DocHighlightDialog.js#L253

}

// Show dialog so we can get width
const clientRect = this.element.getBoundingClientRect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a note here for me to add the annotationDialog.flipDialog implementation here :)

* @return {void}
*/
show() {
annotatorUtil.showElement(this.element);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the mobile dialog going to be the same as the desktop one? See the show/hide methods in AnnotationDialog.js about mobile dialog specific logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, mobile and desktop dialog will be the same.

*/
setup(annotations) {
// Create outermost element container
this.element = document.createElement('div');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this dialog be set up on mobile?

* @return {void}
*/
createDialog() {
if (this.dialog) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious as to why we would need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dialog on a drawing in progress is different than the dialog on a saved drawing. Upon saving a drawing thread, we create a new dialog that is calculated as a saved drawing. (This adds the 'user drew' label and removes the save button.)

event.preventDefault();
event.stopPropagation();
}
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline after the block!

}

super.destroy();
this.reset();
this.emit('threadcleanup');
}

reset() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs

@Minh-Ng Minh-Ng merged commit 5003c3d into box:master Sep 8, 2017
@Minh-Ng Minh-Ng deleted the feature/dd branch September 8, 2017 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants