Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: enhance dialog service to manage open dialog refs #46

Merged

Conversation

ScottTylerTech
Copy link
Contributor

@ScottTylerTech ScottTylerTech commented Jan 17, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added: [Y/N]
  • Docs have been added / updated: [Y/N]
  • Does this PR introduce a breaking change? [Y/N] N
  • I have linked any related GitHub issues to be closed when this PR is merged? [Y/N] Y
    This would close #45

Describe the new behavior?

Enhances the dialog service to manage open dialogs and give the ability to close all open dialogs. Similar to the MatDialogModule in Angular Material

  • Would give the dialog service the ability to manage open dialog refs and give the ability to close all dialogs currently managed.
  • When service.show() is called, the dialog ref is added to an array
  • Removal of dialog ref added to the dialog close subscription

Describe any alternatives you've considered

A viable alternative to is to create an internal service with the suggested implementation that extends on the current dialog service and use that instead.

Additional information

A specific use case for this feature: This functionality is derived from a user session termination with the tid-session manager. In an app, when the session is terminated, if there is an open dialog, the dialog persists on top of the session timeout page and the user still has the ability to navigate the dialog given its a single or stepper. The purposed enhanced functionality would allow the session manager to

Copy link

stackblitz bot commented Jan 17, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ScottTylerTech ScottTylerTech changed the title feat: add dialog reference tracking and unsubscribe functionality feat: enhance dialog service to manage open dialog refs Jan 17, 2024
@ScottTylerTech ScottTylerTech marked this pull request as ready for review January 17, 2024 22:02
@ScottTylerTech ScottTylerTech requested a review from a team as a code owner January 17, 2024 22:02
@DRiFTy17
Copy link
Collaborator

@ScottTylerTech Thanks for putting this together! It looks good so far. Could you add an example usage of it in the dialog demo with multiple dialogs? That will help us validate the functionality given we don't have unit tests set up on this repo at the moment.

@DRiFTy17 DRiFTy17 added the minor Increment the minor version when merged label Jan 18, 2024
@ScottTylerTech
Copy link
Contributor Author

@ScottTylerTech Thanks for putting this together! It looks good so far. Could you add an example usage of it in the dialog demo with multiple dialogs? That will help us validate the functionality given we don't have unit tests set up on this repo at the moment.

Sure thing.

@ScottTylerTech
Copy link
Contributor Author

@DRiFTy17

Any advice on how to shift a dialog, so they are not stacked>? Currently I just set it to movable to show the nested dialogs

image

}

private _closeAllDialogs(result: boolean, recursiveExecutionCount = 0): void {
if (recursiveExecutionCount > 2) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRiFTy17 This is needed for the nested dialogs. I have it set to 2. is there a reasonable number that it should be set to? I know within our app we do not allow dialogs to open dialogs just as UX functionality, but I know our app does not represent the full usage of forge.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So this is just a safe guard against it recursing infinitely basically in the case where closing a dialog also opens a dialog? This is probably an edge case, but I understand the need for it. I would say 2 sounds fine to me, but let's put that into a constant like MAX_NESTED_DIALOGS to avoid the magic number. If we ever run into a case where this needs to be adjusted then we could make the value configurable or something, but this looks fine to me for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@DRiFTy17 DRiFTy17 left a comment

Choose a reason for hiding this comment

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

This all looks good to me. Thanks for putting it together!

}

private _closeAllDialogs(result: boolean, recursiveExecutionCount = 0): void {
if (recursiveExecutionCount > 2) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this is just a safe guard against it recursing infinitely basically in the case where closing a dialog also opens a dialog? This is probably an edge case, but I understand the need for it. I would say 2 sounds fine to me, but let's put that into a constant like MAX_NESTED_DIALOGS to avoid the magic number. If we ever run into a case where this needs to be adjusted then we could make the value configurable or something, but this looks fine to me for now.

DRiFTy17
DRiFTy17 previously approved these changes Feb 1, 2024
Copy link
Contributor

@MikeMatusz MikeMatusz left a comment

Choose a reason for hiding this comment

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

Overall looks good, and I really like the extra documentation, just need to remove the console.table(). We had similar functionality in place in Public Safety around Material Dialogs, so we'll definitely also benefit from this feature as we migrate to Forge dialogs.

@DRiFTy17 DRiFTy17 merged commit 1877cb9 into tyler-technologies-oss:main Feb 6, 2024
1 of 2 checks passed
Copy link
Contributor

github-actions bot commented Feb 6, 2024

🚀 PR was released in v3.6.0 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Feb 6, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhance] Dialog service to track open dialogs and have the ability to close all open dialogs
4 participants