-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[#54275] Live update the work package progress modal with morphing on turbo frame re-rendering. #15213
[#54275] Live update the work package progress modal with morphing on turbo frame re-rendering. #15213
Conversation
960dc33
to
12b3edc
Compare
Given the requests for previews are going to the `edit` action, this relies on a path that includes a `:work_package_id` in the request's path. Since the work package in a create context is unpersisted, there isn't an id to be provided here. This commit mimicks the behavior in the Angular side of the application by setting the `:work_package_id` to "new" in create contexts.
8b478b3
to
e086ecb
Compare
003bd67
to
80a992e
Compare
Reproduction scenario is: * a work package with nothing set, * open the modal, set the work to 10, * => remaining work is set to 10h and % is set to 0% * set remaining work to 8 (so that it's touched) * => % complete is set to 20% * unset work * => before: work was set back to 8h (because not changed from its initial `nil` value) => ko * => after: work is kept as unset and an error message is displayed saying that work must be set if remaining work is set. => ok
In status based mode, `remainingTime` is marked as `writable: false`. The popover edit field tries to write it, but that is ignored when submitting the creation, and it renders nil instead. When then submitting, this nil value will be submitted and result in the error "Remaining work must be set when work is set". By setting `render_nil: false` for `remainingTime` in the `WorkPackageRepresenter`, the field is not returned back from the form endpoint when it is not set. This way, the field is not rendered in the form on submit, and the error is avoided. In work-based mode, the remainingTime being not sent back by the form anymore when it is nil means we have to deal with it being undefined, which is why the progress popover had to be modified too.
I do not like sleep like this. But because I do not manage to find a better synchronization strategy for the turbo stream to come back and update values, I prefer something slow and working than something fast an breaking. Using `page.driver.wait_for_network_idle` does not seem to wait for long enough as Angular has to do its Angular things to update the model being created. Please fix it if you can.
For some reason this stopped working on the live-preview branch. Upon inspecting the behavior of the method with some debuggers, it seemed correct that the specs were to fail as it does fail as well upon manual testing. What's interesting is that it only fails: 1. On subsequent modal updates 2. Not on initial modal loading This is the best fix I could come up with in the meantime. I'm not aware of a reason within the current branch as to why this stopped working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't played around with it for a very long time. But the cases I tried all worked so I think it is almost done.
I suspect there is an error in there when a relative url root is configured for the application, though.
['work_package[status_id_touched]', formParams.get('work_package[status_id_touched]') || ''], | ||
]; | ||
|
||
const wpPath = this.ensureValidPathname(form.action); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried it out but I suspect this will fail if the application is run with a relative url root like /custom
. In this case, the matching would not work.
private frameMorphRenderer:(event:CustomEvent<TurboBeforeFrameRenderEventDetail>) => void; | ||
|
||
connect() { | ||
this.debouncedPreview = debounce((event:Event) => { void this.preview(event); }, 500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would reduce the debounce time as it feels a bit sluggish. On the other hand, when reducing the time, I oftentimes ran into the situation where my last input would be eaten up. Knowing of this problem, even when not changing the time, I could time my input so that they would be eaten up. I don't know if it is just a forced scenario or something that is likely to happen to users that just type in numbers at the wrong time. Since the inserted values normally shouldn't be that long I would think that it is less likely to happen so I would be willing to accept this potential problem and also the need for the sluggy behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In datepickers, we have a similar pattern and also use a debounce of 500: https://github.com/opf/openproject/blob/dev/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts#L802
So I'd leave it as it is and fine-tune later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny code review, LGTM/WCGW!
Description
This is a follow up PR on #14768 , adding live updating on the % done when editing working hours.
The PR also experiments with introducing turbo frame morphing across the project for a smoother turbo rendering experience. Once this PR is merged, we don't need to implement our custom morph rendering, just use the one provided with turbo.
Work Package: https://community.openproject.org/work_packages/54275
Edge cases that do not work correctly
There are some edge cases that do not work correctly with the live update. Once they are addressed, we can merge this PR:
Case 1
Case 2
Case 3
Case 4 (@aaron-contreras)
Case 5 (@cbliard)