Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Read the values correclty after a refresh. For whatever reason the stimulus targets still reference the old fields and thus the old values

Henriette Darge9c8e5f96577b
diff --git a/app/components/work_packages/date_picker/form_content_component.html.erb b/app/components/work_packages/date_picker/form_content_component.html.erb
index 4868885b295..7f1c31177d3 100644
--- a/app/components/work_packages/date_picker/form_content_component.html.erb
+++ b/app/components/work_packages/date_picker/form_content_component.html.erb
@@ -42,6 +42,7 @@
first_row.with_column(mb: 1) do
render(Primer::Alpha::CheckBox.new(name: "work_package[ignore_non_working_days]",
+ id: "work_package_ignore_non_working_days",
label: I18n.t("work_packages.datepicker_modal.ignore_non_working_days.title"),
checked: !work_package.ignore_non_working_days,
disabled: disabled_checkbox?,
diff --git a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
index f576c2ae6e0..0ea4d481253 100644
--- a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
@@ -143,7 +143,7 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implements
return dates[0].getTime() !== this.startDateValue?.getTime();
}
return dates[0].getTime() !== this.startDateValue?.getTime()
- || dates[1].getTime() !== this.dueDateValue?.getTime();
+ || (dates.length > 1 && dates[1].getTime() !== this.dueDateValue?.getTime());
}
private toDate(date:string|null):Date|null {
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
index 8a781d52f7c..78c4964d431 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
@@ -52,7 +52,7 @@ export default class PreviewController extends DialogPreviewController {
private handleFlatpickrDatesChangedBound = this.handleFlatpickrDatesChanged.bind(this);
async connect() {
- this.readCurrentValues();
+ this.readInitialValues();
super.connect();
const context = await window.OpenProject.getPluginContext();
@@ -271,27 +271,41 @@ export default class PreviewController extends DialogPreviewController {
this.updateFlatpickrCalendar();
}
- readCurrentValues() {
+ readInitialValues() {
this.fieldInputTargets.forEach((inputField) => {
- if (inputField.name === 'work_package[ignore_non_working_days]') {
- // field is "Working days only", but has the name "work_package[ignore_non_working_days]" for form submission.
- // Submits "0" if checked, and "1" if not checked thanks to a hidden field with same name.
- this.currentIgnoreNonWorkingDays = !inputField.checked;
- } else if (inputField.name === 'work_package[start_date]') {
- this.currentStartDate = this.toDate(inputField.value);
- } else if (inputField.name === 'work_package[due_date]') {
- this.currentDueDate = this.toDate(inputField.value);
- this.isMilestone = false;
- } else if (inputField.name === 'work_package[duration]') {
- this.currentDuration = this.toDuration(inputField.value);
- }
+ this.assignReadValues(inputField);
+ });
+ }
- if (inputField.classList.contains('op-datepicker-modal--date-field_current')) {
- this.highlightedField = inputField;
+ readCurrentValues() {
+ const fieldNames = ['ignore_non_working_days', 'start_date', 'due_date', 'duration'];
+ fieldNames.forEach((name:string) => {
+ const field = document.getElementById(`work_package_${name}`);
+ if (field) {
+ this.assignReadValues(field as HTMLInputElement);
}
});
}
+ private assignReadValues(inputField:HTMLInputElement) {
+ if (inputField.name === 'work_package[ignore_non_working_days]') {
+ // field is "Working days only", but has the name "work_package[ignore_non_working_days]" for form submission.
+ // Submits "0" if checked, and "1" if not checked thanks to a hidden field with same name.
+ this.currentIgnoreNonWorkingDays = !inputField.checked;
+ } else if (inputField.name === 'work_package[start_date]') {
+ this.currentStartDate = this.toDate(inputField.value);
+ } else if (inputField.name === 'work_package[due_date]') {
+ this.currentDueDate = this.toDate(inputField.value);
+ this.isMilestone = false;
+ } else if (inputField.name === 'work_package[duration]') {
+ this.currentDuration = this.toDuration(inputField.value);
+ }
+
+ if (inputField.classList.contains('op-datepicker-modal--date-field_current')) {
+ this.highlightedField = inputField;
+ }
+ }
+
// called from inputs defined in the date_picker/date_form.rb
onHighlightField(e:Event) {
const fieldToHighlight = e.target as HTMLInputElement;