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

How to close a custom dialog? #286

Open
relizondobarrios opened this issue Mar 1, 2021 · 4 comments
Open

How to close a custom dialog? #286

relizondobarrios opened this issue Mar 1, 2021 · 4 comments
Labels
feature request needs triage The issue should be triaged.

Comments

@relizondobarrios
Copy link

relizondobarrios commented Mar 1, 2021

We are creating a custom dialog where the user can select some items and then click the "Apply" button (This button is totally created by us / HTML and function (click)). When the user clicks this button, we are implementing a process. When this process is finished, we should close the dialog automatically.

This is the implementation of the custom dialog
image

Same as SELECTOR_SERVICE.openDialog(dialogData), is there a .closeDialog() method? How can we close the dialog?

@Novkirishki
Copy link
Contributor

Hi @relizondobarrios, currently it is not possible to close the dialog without providing a command in the DialogData object.

I'm marking this as a feature request and logging it in our backlog.

Can you share the reason why you need to create a custom button and not use the commands property in the DialogData?

@Novkirishki Novkirishki added feature request needs triage The issue should be triaged. labels Mar 2, 2021
@relizondobarrios
Copy link
Author

relizondobarrios commented Mar 5, 2021

Hi @Novkirishki
We have an integrated eCommerce with JD Edwards EnterpriseOne and we are moving product content maintenance to Sitefinity modules.
So to create a new product in Sitefinity, we need to get the product information stored in JDE and then using the Sitefinity API insert it into the database.
After that, we need to close the dialog and navigate to the edit view. The new product has the same information as in JDE and the user can expand the product information in Sitefinity; for example images, documents, etc.

This is the dialogue we implement:

image

image

thank you for answering

@Novkirishki
Copy link
Contributor

Hi @relizondobarrios,
from these images it seems to me that the desired UX and beahvior can be achieved with the current extensibility API.

In order to render the Cancel and Done buttons you can pass the following command models to the DialogData object when opening the dialog:
image

Upon pressing the Done button the MyDoneCommand would be executed. As long as its execute method is returning false values the dialog won't be closed. As soon as the update process is complete, you can next() true value and the dialog will close. Here is an example with setTimeout() simulating the process:
image

Hope this will help you!

@relizondobarrios
Copy link
Author

Hi @Novkirishki

Thank you for your support.

I applied the suggested sample in my code and went through a scenario.

I have an OData service to add new products to the Products content type. This service must validate the product number and based on some restrictions we decide whether or not to add the product.

image

If the product number is invalid, I display a notification with the error message, but I want to keep the dialog open because the user might want to try again.

I assumed that if you used result.next(false); the dialog will stay open and the buttons will be reset, but it didn't work as expected because the dialog closed even though I used result.next(false); or result.next(true);

The thing is, I don't know how to reset the "cancel" and "done" commands. Is this supported?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request needs triage The issue should be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants