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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refresh button to ResourceLocator field-type #5551

Merged
merged 7 commits into from
Oct 28, 2020

Conversation

niklasnatter
Copy link
Contributor

@niklasnatter niklasnatter commented Oct 14, 2020

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets fixes #4221, fixes #5547
Related issues/PRs #5340
License MIT

What's in this PR?

This PR adds a Refresh URL button to the ResourceLocator field-type. The button allows to regenerate the URL based on the current values of the Form.

Screenshot 2020-10-14 at 12 09 57

Why?

Because it is frequently requested feature 馃檪
See #4221 and #5340.

@danrot
Copy link
Contributor

danrot commented Oct 16, 2020

I have just tested it, and to me it feels a little bit weird from a user perspective...

Let's assume we have just the title and the URL field. The URL field uses the value from the title field to generate the URL. I've realized two weird behaviors:

  1. The refresh button won't be activated until I the user blurs the title field.
  2. The refresh button also activates, if the user focuses the title field and blurs it without applying any change.

The first one requires an additional click, which should not be necessary IMO, and the second one might be confusing to the user, because nothing is happening after the button click.

That made me wonder: Wouldn't it make sense to set the enableRefreshButton when a change is happening? We could do that by adding a addChangeFieldHandler. I guess alternatively that could also be done by using a @computed value for the url parts and use an autorun.

@niklasnatter
Copy link
Contributor Author

niklasnatter commented Oct 19, 2020

Yes, I think the behaviour is not perfect too. I think adding a addChangeFieldHandler would be nice, but I am not sure how to implement it.

As far as I see, the dataPath of the field is passed to the given FinishFieldHandler. Also, the the FormStoreInterface::finishField method has a dataPath parameter. In contrast, the FormStoreInterface::change method uses a name parameter. Is there a specific reason for this disparity? Or would we implement the FormStoreInterface::change method with a dataPath too, if we would implement it again? WhatShould the ChangeFieldHandler receive a name or a dataPath? 馃

Furthermore, the Form container calls the FormInspector::finishField method. The FormInspector then calls the FormStoreInterface::finishField method. Should we implement a similar FormInspector::changeField method? That feels kinda wrong to me as "Inspector" sounds like it is a read-only thing, doesnt it?

One solution for the second problem would be adding a FormStoreInterface::notifyFieldFinish and a FormStoreInterface::notifyFieldChange method and deprecating the FormStoreInterface::finishField method. But maybe I am just overthinking this? 馃槄

@niklasnatter
Copy link
Contributor Author

niklasnatter commented Oct 20, 2020

This PR depends on #5558, therefore I rebased it temporarily. Please remind me to rebase this back onto master before merging it in case I forget about it

@niklasnatter niklasnatter changed the base branch from master to release/2.1 October 20, 2020 08:54
@niklasnatter niklasnatter changed the base branch from release/2.1 to master October 27, 2020 11:09
@niklasnatter
Copy link
Contributor Author

I do not understand why circleci is failing, I have not adjusted this files as far as I see 馃槙

Copy link
Member

@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

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

A error happens on the homepage when the partsChangeDisposer is not set.

@danrot
Copy link
Contributor

danrot commented Oct 27, 2020

I do not understand why circleci is failing, I have not adjusted this files as far as I see

Probably related to #5569, but there is also a jest fix on its way. Not sure if we should merge #5569 or wait for the fix.

@alexander-schranz alexander-schranz added the Feature New functionality not yet included in Sulu label Oct 27, 2020
Copy link
Member

@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

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

Works now as expected. Thx for adding the unmount test 馃憤

@alexander-schranz alexander-schranz merged commit ae5b58e into sulu:master Oct 28, 2020
@danrot danrot mentioned this pull request Oct 28, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New functionality not yet included in Sulu
Projects
None yet
3 participants