Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Modal unsaved work confirmation #7

Merged
merged 20 commits into from
Dec 13, 2018
Merged

Conversation

blackbaud-conorwright
Copy link
Contributor

@blackbaud-conorwright blackbaud-conorwright commented Oct 23, 2018

@codecov-io
Copy link

codecov-io commented Oct 23, 2018

Codecov Report

Merging #7 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #7   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          21     22    +1     
  Lines         430    439    +9     
  Branches       64     66    +2     
=====================================
+ Hits          430    439    +9
Impacted Files Coverage Δ
src/app/public/modules/confirm/confirm.module.ts 100% <100%> (ø) ⬆️
.../modules/modal/types/modal-before-close-handler.ts 100% <100%> (ø)
src/app/public/modules/modal/modal-instance.ts 100% <100%> (ø) ⬆️
...rc/app/public/modules/confirm/confirm.component.ts 100% <100%> (ø) ⬆️
src/app/public/modules/confirm/confirm.service.ts 100% <100%> (ø) ⬆️
src/app/public/modules/modal/modal.component.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ffdc3ae...5ae746a. Read the comment docs.

@blackbaud-johnly
Copy link
Contributor

Added blackbaud/skyux2#2138 to document new input.

Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

@blackbaud-conorwright

Ok. I have 4 thoughts that I'd like your thoughts on.

  1. I think we should probably have a seperate demo for just this and revert the old full page demo to how it was. That way people know that they should look at that given example for how to show the confirmation. In the current state it is hard to tell where you need to look and if someone is just looking at the fullpage then they might be confused when the confirmation pops up.
  2. I'd like to hear feedback from Todd on the default text
  3. I think it would be good if we gave another input that allows for custom text for both the modal body and the buttons. I feel like design/docs will want specific text for some apps here and so we should try to get ahead of that request
  4. I think I agree with Steve that we should possibly make the input to trigger the confirmation more generic. I think we will find out that people want this confirmation for more than just unsaved work and so I would rather name the input something such as triggerConfirmation that is a little more generic.

@blackbaud-conorwright
Copy link
Contributor Author

@Blackbaud-TrevorBurch This should be ready for another look now 👍

@blackbaud-conorwright
Copy link
Contributor Author

Aside from the message though, we still need to wait on Todd to get back for that feedback. But that won't really change the implementation, just the default message

Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

Just a couple small comments.

@Blackbaud-SteveBrush Blackbaud-SteveBrush self-assigned this Nov 1, 2018
Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

A couple of small things. The build is also failing.

src/app/public/modules/modal/modal.component.spec.ts Outdated Show resolved Hide resolved
src/app/public/modules/modal/modal.component.spec.ts Outdated Show resolved Hide resolved
@blackbaud-conorwright
Copy link
Contributor Author

@Blackbaud-TrevorBurch This should be set for another look.

Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

LGTM now

Copy link
Member

@Blackbaud-SteveBrush Blackbaud-SteveBrush left a comment

Choose a reason for hiding this comment

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

@blackbaud-conorwright Regarding the issue of having a circular dependency on confirm: I think this unearthed a bigger problem. The goal of this feature is to allow consumers the opportunity to short-circuit the closing of a modal, run a check, and either keep it open, or close it. We could be overthinking the implementation. What if we removed the generating of the "confirm" aspect entirely, and only fired an event on the modal instance instead. The consumer of the modal would subscribe to the beforeClose lifecycle hook and generate a confirm instance themselves.

(NOTE: I'm not 100% sold on the names of the types, below. Curious if you have some ideas, there.)

An example consumer component:

private hasUnsavedWork = false;

// ...

const modal = this.modalService.open(SomeComponent);

modal.beforeClose.subscribe((handler: SkyModalBeforeCloseHandler) => {
  if (!this.hasUnsavedWork) {
    handler.triggerClose();
    return;
  }

  // Unsaved work detected. Alert the user.
  const confirm = this.confirmService.open({ message: 'Are you sure?' });
  confirm.closed.subscribe((result: any) => {
    if (result.action === 'yes') {
      handler.triggerClose();
    } else {
      handler.abortClose();
    }
  });
});

modal.closed.subscribe(() => ...);

The benefits of this approach:

  1. The consumer can use the full suite of Confirm features that they require (and can even create a custom confirm if they need to).
  2. The complexity of this feature is significantly reduced.
  3. We can build on this idea later on with different lifecycle hooks (if needed).

@blackbaud-conorwright
Copy link
Contributor Author

@Blackbaud-SteveBrush The new implementation is up

Copy link

@Blackbaud-ToddRoberts Blackbaud-ToddRoberts left a comment

Choose a reason for hiding this comment

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

The new approach is ok. It is some amount of extra work for consumers to consistently implement the normal-case confirm, we will have to add guidelines/examples to UX docs.

Copy link
Member

@Blackbaud-SteveBrush Blackbaud-SteveBrush left a comment

Choose a reason for hiding this comment

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

Final comments. Looks great!

src/app/public/modules/modal/modal.component.ts Outdated Show resolved Hide resolved
Copy link
Member

@Blackbaud-SteveBrush Blackbaud-SteveBrush left a comment

Choose a reason for hiding this comment

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

LGTM. I'd appreciate it if @Blackbaud-TrevorBurch could give it one more glance.

Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

@blackbaud-conorwright sorry about this but I did spot some minor style things.

src/app/visual/modal/modal-tiled-demo.component.ts Outdated Show resolved Hide resolved
src/app/visual/modal/modal-large-demo.component.ts Outdated Show resolved Hide resolved
src/app/visual/modal/modal-fullpage-demo.component.ts Outdated Show resolved Hide resolved
src/app/visual/modal/modal-demo.component.ts Outdated Show resolved Hide resolved
@blackbaud-conorwright
Copy link
Contributor Author

No problem! I'm happy to fix style stuff :)

Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants