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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Make datepicker UI integration to work with highlighted fields and auto focusing missing date fields.
Dombi Attilabf864edeabcc
diff --git a/app/forms/projects/life_cycles/form.rb b/app/forms/projects/life_cycles/form.rbindex d4026576f59..7faa6095abe 100644--- a/app/forms/projects/life_cycles/form.rb+++ b/app/forms/projects/life_cycles/form.rb@@ -67,7 +67,8 @@ module Projects::LifeCyclescaption:,value:,data: data.merge("overview--project-life-cycles-form-target": "startDate assignable"),- show_clear_button: value.present? && !disabled+ show_clear_button: value.present? && !disabled,+ clear_button_id: "start_date_clear_button"}form.text_field **datepicker_attributes, **input_attributesend@@ -81,7 +82,8 @@ module Projects::LifeCyclesautofocus: autofocus?(:finish_date),value:,data: data.merge("overview--project-life-cycles-form-target": "finishDate assignable"),- show_clear_button: value.present?+ show_clear_button: value.present?,+ clear_button_id: "finish_date_clear_button"}form.text_field **datepicker_attributes, **input_attributesenddiff --git a/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.tsindex 6ee0d599663..765fd62cf63 100644--- a/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/overview/project-life-cycles-form.controller.ts@@ -81,7 +81,7 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControllprivate updateFlatpickrCalendar() {const dates:Date[] = _.compact(this.dateInputFields.map((field) => this.toDate(field.value)));const ignoreNonWorkingDays = false;- const mode = this.mode;+ const mode = 'range';document.dispatchEvent(new CustomEvent('date-picker:flatpickr-set-values', {@@ -94,31 +94,19 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControll);}- private get mode():'single'|'range' {- return 'range';- }-- highlightField(field:HTMLInputElement) {- this.clearHighLight();- field.classList.add('op-datepicker-modal--date-field_current');- this.updateFlatpickrCalendar();- window.setTimeout(() => {- // For mobile, we have to make sure that the active field is scrolled into view after the keyboard is opened- field.scrollIntoView(true);- }, 300);- }-handleFlatpickrDatesChanged(event:CustomEvent<{ dates:Date[] }>) {const dates = event.detail.dates;if (dates.length === 1) {if ((this.highlightedField === this.finishDateTarget) || this.startDateTarget.disabled) {this.finishDateTarget.value = this.dateToIso(dates[0]);- if (this.startDateTarget.disabled) {- this.clearHighLight();+ if (!this.startDateTarget.value) {+ this.highlightField(this.startDateTarget);}} else {this.startDateTarget.value = this.dateToIso(dates[0]);+ this.finishDateTarget.value = '';+ this.highlightField(this.finishDateTarget);}} else {this.dateInputFields@@ -129,6 +117,7 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControll});this.clearHighLight();}+this.updateFlatpickrCalendar();this.previewForm();}@@ -156,6 +145,21 @@ export default class ProjectLifeCyclesFormController extends FormPreviewControllreturn field;}+ private highlightField(field:HTMLInputElement) {+ this.clearHighLight();++ if (field.disabled) {+ return;+ }++ field.classList.add('op-datepicker-modal--date-field_current');+ this.updateFlatpickrCalendar();+ window.setTimeout(() => {+ // For mobile, we have to make sure that the active field is scrolled into view after the keyboard is opened+ field.scrollIntoView(true);+ }, 300);+ }+private clearHighLight() {this.dateInputFields.forEach((el) => el.classList.remove('op-datepicker-modal--date-field_current'));