54 Commits

Author SHA1 Message Date
Christophe Bliard 447e07b38d Fix flaky spec in progress_modal_spec
failing spec: spec/features/work_packages/progress_modal_spec.rb:195
failing run: https://github.com/opf/openproject/actions/runs/21204407008/job/60997306384

In the spec, another page is visited during the test, meaning the
internal ids of the capybara elements may not be the same as the ones
before the page is reloaded. This is a problem because the
`progress_popover` caches the container element, and it's not valid
anymore (it's stale).

One fix could be to create a new `progress_popover` instance after the other page is visited.

I found it better to be able to pass a lambda for the container element
to the `progress_popover` constructor, so that it always gets it afresh
and will never be stale.
2026-01-22 15:30:43 +01:00
ulferts fa1e5e0c9d attempt to fix flickering spec
rspec ./spec/features/work_packages/progress_modal_spec.rb:195
2025-12-12 15:41:32 +01:00
ulferts 3cf1384ca2 attempt to fix flickering spec
./spec/features/work_packages/progress_modal_spec.rb:195
2025-11-28 14:26:08 +01:00
Christophe Bliard 72736f413f Restore direct click and work around issue with other specs
The `./spec/features/work_packages/tabs/relations_children_spec.rb`
works better when using `target.click` instead of
`target.trigger('click')`.

The `./spec/features/work_packages/progress_modal_spec.rb` was scrolling
to the middle of the screen when clicking on the work field to display
the progress popover for some reason.

Then when updating the status field on the work package creation page,
it was made active by clicking it, which displayed the dropdown, and
then it was clicked again for the autocompletion, which scrolled at the
top of the page for some reason. Problem is: the dropdown is fixed and
scrolling up make it overlap the status field, and when calling
`target.click`, Capybara refuses saying that something overlaps it.

The adopted solution is to scroll to the top of the page before updating
the status. Not satisfying, but works.
2025-07-22 08:18:11 +02:00
Christophe Bliard d194ce1650 Restore progress preview controller as it was before
The date picker preview controller and the progress preview controller
were abstracted into a super class. It's too hard to make deep
modifications to the date picker preview controller while keeping the
compatibility with the progress preview controller.

For instance, we break the progress values being formatted on blur
without noticing. This commit adds a test just for this.

This commit undoes some changes made in 5429b8b (commit title is
"Extract logic of the progress modal to be reused for the datepicker
modal").

Once the date picker progress controller works as expected, we'll see
which part can be reused and extracted into an abstraction.
2025-02-25 09:18:22 +01:00
Oliver Günther f791d33b72 Replace specs 2025-01-14 10:20:35 +01:00
Christophe Bliard 4ac1b1ca7a Remove :percent_complete_edition feature flag
% complete edition will be released in 14.6
2024-09-25 15:31:11 +02:00
Christophe Bliard 0a5765f21a Fix lost progress popover state on submit with invalid values
When submitting with invalid values, the progress popover was updated
via turbo-stream with a modal which did not include the touched fields.
This caused the fields to be ignored on the second submit, even if they
appeared to be invalid. This was also causing the preview to not work as
expected.

This has been changed:
- the update is done through a turbo-stream morph instead of an update.
  It avoids disconnecting and reconnecting the stimulus controllers.
- the touched fields are now correctly sent to the component for
  rendering. The state is maintained in the stimulus controller instead
  of the hidden fields. Fields are still needed for form submission.
- the fields sent to the server when previewing are exactly the same as
  the ones being sent on submit.
- the turbo_stream commands are sent directly from the controller. None
  are sent if the update completed successfully as the modal will be
  closed by client side javascript anyway.
- the referrer-field is now just the field name instead of the full
  work package key, to reduce noise.
2024-09-17 13:49:35 +02:00
Christophe Bliard c40bd5fdc2 Recompute progress values when changing status on new work package form
Because of the weird way we initialize the fake work package, it could
believe that the status did not change and no recomputation was needed.
This is an edge case, and I'm not satisfied with its design.
2024-09-17 10:03:38 +02:00
Christophe Bliard 49bbcb0bd3 Change i18n key to prevent inconsistent translation issues 2024-09-03 12:12:42 +02:00
Christophe Bliard beb2e80174 [57258] Indicate delta in remaining work derived message
When work is increased or decreased and remaining work is also increased
or decreased by the same amount, indicate the delta in the hint message
to reduce user confusion.

See comments 12 to 18 of work package 57258 for more details.
2024-09-03 12:05:22 +02:00
Christophe Bliard 78ef2f98f1 [57258] Display derivation hints in status-based mode
https://community.openproject.org/wp/57258

It was calculated but not displayed. This is now covered by a feature
test.

In the progress popover, when the input is a select, the event being
listened to to render a preview is `change` instead of `input. It's
because cuprite does not emit the `input` event when selecting an option
in a select input. It only emits `change`. `ProgressEditField` has been
updated to correctly focus and change the value of a select (for
status selection inside the popover).

Also to allow `ProgressEditField#expect_modal_field_value` to work
regardless of the field being disabled or readonly, the disabled value
default to `:all` which matches both disabled and enabled inputs, and
the `readonly` parameter has been removed. To check for it, call
`ProgressEditField#expect_modal_field_read_only` directly instead.
2024-08-30 18:00:39 +02:00
Christophe Bliard 6d19bfd552 Remove debug statements 2024-08-28 16:04:56 +02:00
Christophe Bliard 93a6873dd9 [57512] Make it easier to clear all fields
https://community.openproject.org/wp/57512

When work is modified and remaining work and % complete are both empty,
the % complete field should not be untouched because that would lead to
it having a value again, which is tedious when one wants to clear all
values.
2024-08-28 14:57:53 +02:00
Christophe Bliard b1dec39313 Update wording to match the one used in user messages 2024-08-23 14:49:13 +02:00
Christophe Bliard b19d34a642 Recompute % complete when cleared with work and work is set again
Also correctly reference scenario ids from work package #57370
https://community.openproject.org/wp/57370
2024-08-23 11:00:56 +02:00
Christophe Bliard a09b683d51 Recompute remaining work when cleared and work is set again 2024-08-23 09:11:59 +02:00
Christophe Bliard 7e5bfe1d60 Recompute work when cleared and remaining work is set again 2024-08-23 08:33:49 +02:00
Christophe Bliard 078d21c3dc Keep Work value when it's set
If Remaining work and % Complete are both modified and Work is initially
empty, then it will be derived, but if it is set then it's % Complete
and Remaining work which will change.

The goal is to keep the Work value unchanged as much as possible.
2024-08-22 12:17:16 +02:00
Christophe Bliard c063cbccef refactor: Merge focus tests together 2024-08-21 12:01:51 +02:00
Christophe Bliard dfa4ee2bdb refactor: Use more expressive names in progress modal spec
Introduce `Components::WorkPackages::ProgressPopover` to interact with
progress popover in a more natural way and abstract details away.
2024-08-21 11:51:58 +02:00
Oliver Günther 12ee9e6b83 Merge remote-tracking branch 'origin/idea/56781-remove-years-from-copyrights' into dev 2024-08-06 10:17:59 +02:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
Aaron Contreras b3124c0c8a Merge branch 'dev' into feature/52233-allow-to-edit-p-complete-in-work-based-mode 2024-07-29 11:43:13 -05:00
Ivan Kuchin 54a71c80b0 use everywhere the wait_for_network_idle helper that checks for ability to wait 2024-07-29 13:06:36 +02:00
Christophe Bliard 38fcd07836 [52233] Add feature flag for modification of % complete field
Feature flag is percent_complete_edition. So % complete edition will be
shipped but disabled in 14.4.

It will eventually be activated in 15.0 when there will be a total %
complete calculation mode so that we can bundle both features together
in one release.
2024-07-17 17:24:04 +02:00
Christophe Bliard 706c5b228a Fix progress value live preview in new work package page
The values were not retained between modifications of percent values, so
a new parameter `initial` was introduced to "save" the entered values
between edits.

It also fixed the progress modal having empty values when opening it a
second time in the create work package page.
2024-07-15 17:32:33 +02:00
Christophe Bliard 8b91097b24 [52233] Implement new business rules
- It's allowed to set only one progress value while the two others are
  unset.
- It's not allowed to have two progress values set while the other one
  is unset.
- Do not output "inconsistent % complete" error if work < remaining work
  to avoid having too many errors displayed at the same time.
2024-07-12 16:39:01 +02:00
Christophe Bliard 0d79dba094 No longer display migration warning when only % complete is set
Because now we can set it.
2024-07-12 14:11:58 +02:00
Christophe Bliard 3b9819ee4f Fix feature tests now that % Complete is editable 2024-07-11 13:17:38 +02:00
Christophe Bliard 7725acc10c [52233] Allow edition of % Complete
Still incomplete and some tests are failing, but this is usable first
draft.
2024-07-11 09:58:16 +02:00
Christophe Bliard 7aee487fb1 Fix feature test expectations regarding rounding issue 2024-07-10 14:59:57 +02:00
Christophe Bliard 5ac1787fd6 [55997] Add duration_format setting with hours_only by default
https://community.openproject.org/wp/55997

The `duration_format` setting can take two values: "hours_only" or
"days_and_hours". The default value is "hours_only".

The `duration_format` setting is used to determine how durations are
displayed in the frontend and in some exports.

It can be changed in Administration > Calendar and Dates > Working days
and hours.
2024-07-02 17:06:35 +02:00
Christophe Bliard 23637b1fe8 Fix tests for new duration display with days and hours only
No need to adjust the number of seconds to the nearest minute anymore. 2
decimals when displaying hours are enough.
2024-06-10 15:24:46 +02:00
Christophe Bliard ed9c63d2fd Fix tests due to changes in rounding duration to minute 2024-06-03 17:08:59 +02:00
Aaron Contreras e8e3ee8787 Adapt specs to new format 2024-05-24 11:44:27 -05:00
Aaron Contreras ec5b0300d6 Parse and format modal progress fields 2024-05-07 11:48:22 -05:00
Christophe Bliard 4fabb80cf9 Merge branch 'release/14.0' into feature-add-turbo-frame-morphing 2024-04-23 08:56:39 +02:00
Christophe Bliard 00c078e535 [54370] Prevent error when saving unset progress modal
See https://community.openproject.org/wp/54370

It was producing a 500 error.
2024-04-22 16:09:55 +02:00
Christophe Bliard 9b657120bd Avoid sending the remainingTime in create form when status-based
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.
2024-04-22 12:24:46 +02:00
Aaron Contreras 309a5bad27 Merge branch 'release/14.0' into feature-add-turbo-frame-morphing 2024-04-18 14:45:37 -05:00
Christophe Bliard 67df322099 Round progress values to 2 decimals
Having more decimals leads to inconsistencies and long values.
2024-04-18 17:44:09 +02:00
Aaron Contreras e086ecb8fe Flag changed fields for change detection on server side 2024-04-17 10:49:01 -05:00
Christophe Bliard 479cb7c3d5 [54308] Make rounding consistent with 2 decimals in progress modal
See https://community.openproject.org/wp/54308

2 decimals is what is used by default everywhere else.
2024-04-17 15:36:23 +02:00
Aaron Contreras a19dcdf586 Merge branch 'release/14.0' into feature-add-turbo-frame-morphing 2024-04-15 09:53:32 -05:00
Aaron Contreras 7c6552b317 Add feature specs for cases known to be buggy with live updating 2024-04-15 09:53:03 -05:00
Aaron Contreras 7c8d75e5d7 Render help text for missing values only on work-based mode 2024-04-12 08:07:08 -05:00
Ivan Kuchin 81f0499961 fix test fail caused by stale shared object
Not sure what is the best way, following fails:

```shell
rspec './spec/features/work_packages/progress_modal_spec.rb[1:4:1:1:1,1:6:1:1,1:6:2:1]' --seed 33667
```
2024-04-11 16:00:19 +02:00
Aaron Contreras 1c0780313d Render migration warning banner message when % complete is the only field set 2024-04-09 23:17:45 -05:00
Aaron Contreras 2c52c4129c Ensure only valid status transitions are allowed in the modal 2024-04-09 16:49:59 -05:00