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

some improvements #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

kamil-malinski
Copy link

  • adds system-display-template interface to url-properties
  • adds the ability to return a custom popup-title and popup-text
  • adds the ability to return a custom url to jump to after api-call
  • adds the ability to show popup as dialog

example for endpoint that returns custom popup-title, popup-text, a custom url to jump to and showing a dialog instead of the notification:

module.exports = (router, { services, exceptions, database }) => {
    const { ItemsService } = services;
    const { ServiceUnavailableException } = exceptions;

    router.get("/cancel/:id", async (req, res, next) => {
        const id = req.params.id;

        try {
            res.json({
                title: "Success",
                text: "Event canceled",
                goto: "/content/event",
                dialog: true,
            });
        } catch (error) {
            return next(new ServiceUnavailableException(error.message));
        }
    });
}

@duydvu
Copy link
Contributor

duydvu commented Nov 11, 2022

Hi @kamil-malinski

Thanks for your contributions.

Your improvements are very nice but I think some unintended behaviors might happen with custom title & text.
For example, you call a GET to an item that contains one of these fields but you don't want them to be displayed on the popup.
I suggest that you can add a boolean props to enable/disable custom popup content.

@kamil-malinski
Copy link
Author

Hi @duydvu

I don’t use the text field or the title field of the item for the popup. The text and the title are from the response of the endpoint.

If you don’t want custom text and title just don’t put them into the response.

@duydvu
Copy link
Contributor

duydvu commented Nov 11, 2022

For example, the button triggers a request to a 3rd-party API and it returns the data that contains title or text, it will be displayed even if I don't want to.

We cannot control the data of the response returned from the API so I just want to have a way to control whether it should use the data as the dialog title & text.

@kamil-malinski
Copy link
Author

ok, I understand what you mean

I'm going to add a switch as suggested

@duydvu
Copy link
Contributor

duydvu commented Dec 24, 2022

How is it going, @kamil-malinski. Is there anything I can help?

@xu4wang
Copy link

xu4wang commented May 7, 2023

@kamil-malinski I just raised an issue #3 for navigating the browser to another page after the API call. Checking your pull request, there is already:

          if (result.data?.goto) router.push(result.data.goto);

I believe the directus APP will ask for user confirmation for unsaved changes? this is a little bit annoying regarding user experience. I am wondering do you have a solution or workaround for this?

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.

None yet

3 participants