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
Fix move work package page reload on project select
Benjamin Bädorf25ca938fbc40
diff --git a/app/views/work_packages/moves/new.html.erb b/app/views/work_packages/moves/new.html.erbindex 986cb16a1fd..cec5a3b1aac 100644--- a/app/views/work_packages/moves/new.html.erb+++ b/app/views/work_packages/moves/new.html.erb@@ -44,7 +44,7 @@ See COPYRIGHT and LICENSE files for more details.<%= styled_form_tag({action: 'create'},id: 'move_form',- data: { 'refresh-url': url_for(action: 'new'), 'input-selector': '#new_project_id' },+ data: { 'refresh-url': url_for(action: 'new'), 'input-selector': '[name="new_project_id"]' },class: '-wide-labels augment--refresh-on-form-changes') do %><% @work_packages.each do |wp| %><%= hidden_field_tag 'ids[]', wp.id %>@@ -62,6 +62,7 @@ See COPYRIGHT and LICENSE files for more details.inputs: {apiFilters: [['user_action', '=', ['work_packages/move']]],name: 'new_project_id',+ value: @target_project,},id: 'new_project_id',class: 'remote-field--input',@@ -92,7 +93,7 @@ See COPYRIGHT and LICENSE files for more details.<div class="form--field-container"><%= styled_select_tag('version_id',content_tag('option', t(:label_no_change_option), value: '') +- version_options_for_select(@available_versions)) %>+ version_options_for_select(@available_versions)) %></div></div><div class="form--field">diff --git a/frontend/src/app/core/setup/globals/global-listeners/refresh-on-form-changes.ts b/frontend/src/app/core/setup/globals/global-listeners/refresh-on-form-changes.tsindex f995adebe94..5c64d2f9337 100644--- a/frontend/src/app/core/setup/globals/global-listeners/refresh-on-form-changes.ts+++ b/frontend/src/app/core/setup/globals/global-listeners/refresh-on-form-changes.ts@@ -35,10 +35,15 @@ export function refreshOnFormChanges() {const url = form.data('refreshUrl');const inputId = form.data('inputSelector');- form- .find(inputId)- .on('change', () => {- window.location.href = `${url}?${form.serialize()}`;- });+ // TODO: Not all elements are available when we run here. The angular dynamic+ // components have to be instantiated first. This race condition should be removed+ // by changing how we refresh on form changes altogether.+ setTimeout(() => {+ form+ .find(inputId)+ .on('change', () => {+ window.location.href = `${url}?${form.serialize()}`;+ });+ }, 100);}}diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.html b/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.htmlindex c5191a3dabd..fe59a250f52 100644--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.html+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.html@@ -38,6 +38,7 @@</op-autocompleter><input+ #hiddenInput[name]="name"type="hidden"[value]="plainValue"diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.tsindex 10b21c34bbb..ff9669f3655 100644--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts@@ -37,6 +37,7 @@ import {HostBinding,ViewEncapsulation,ChangeDetectionStrategy,+ ViewChild,} from '@angular/core';import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';import { HttpClient } from '@angular/common/http';@@ -116,6 +117,9 @@ export class ProjectAutocompleterComponent implements ControlValueAccessor {this.onChange(value);this.valueChange.emit(value);this.onTouched(value);+ setTimeout(() => {+ this.hiddenInput.nativeElement?.dispatchEvent(new Event('change'));+ }, 100);}get plainValue():ID|ID[] {@@ -124,6 +128,8 @@ export class ProjectAutocompleterComponent implements ControlValueAccessor {@Output('valueChange') valueChange = new EventEmitter<IProjectAutocompleterData|IProjectAutocompleterData[]|null>();+ @ViewChild('hiddenInput') hiddenInput: ElementRef;+constructor(public elementRef:ElementRef,protected halResourceService:HalResourceService,