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

Load an empty request in the beginning to show the warning text

Oliver Güntherf7b24662af9d
diff --git a/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts b/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts
index a87559b585e..1fee6345fce 100644
--- a/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts
+++ b/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts
@@ -3,7 +3,7 @@ import {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {
catchError,
debounceTime,
- distinctUntilChanged, filter,
+ distinctUntilChanged, filter, share, shareReplay,
switchMap,
takeUntil,
tap
@@ -67,7 +67,8 @@ export class DebouncedRequestSwitchmap<T, R = HalResource> {
this.lastResult = results;
})
)
- )
+ ),
+ shareReplay(1)
)
);
}
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
index 6587c5c550a..c2d036cf6c7 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
@@ -102,6 +102,12 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
onAfterViewInit: (component:CreateAutocompleterComponent) => component.focusInputField()
};
+ /** The loaded available values */
+ availableValues:any;
+
+ /** Whether the no results warning is displayed */
+ showWarning:boolean = false;
+
constructor(readonly elementRef:ElementRef,
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
readonly cdRef:ChangeDetectorRef,
@@ -126,6 +132,25 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
.then((text) => {
this.warningText = text;
});
+
+ this
+ .requests
+ .output$
+ .pipe(
+ this.untilDestroyed()
+ )
+ .subscribe((values:unknown[]) => {
+ this.availableValues = values;
+
+ if (values.length === 0) {
+ this.showWarning = true;
+ }
+
+ this.cdRef.detectChanges();
+ });
+
+ // Request an empty value to load warning early on
+ this.requests.input$.next('');
}
onModelChange(element:HalResource) {
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html
index d756a09c029..cc091129e5d 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html
@@ -14,12 +14,19 @@
</div>
<div class="ngdialog-body op-modal--modal-body">
+ <div *ngIf="showWarning && warningText"
+ class="notification-box -warning">
+ <div class="notification-box--content">
+ <p [innerHTML]="warningText"></p>
+ </div>
+ </div>
+
<div class="form--field">
<div class="form--field-container">
<div class="form--select-container">
<label class="form--label" [textContent]="actionService.localizedName"></label>
<ndc-dynamic [ndcDynamicComponent]="autocompleterComponent()"
- [ndcDynamicInputs]="{ availableValues: requests.output$ | async,
+ [ndcDynamicInputs]="{ availableValues: availableValues,
typeahead: requests.input$,
appendTo: 'body',
model: '',
@@ -31,13 +38,6 @@
</div>
</div>
- <div *ngIf="!requests.hasResults && warningText"
- class="notification-box -warning">
- <div class="notification-box--content">
- <p [innerHTML]="warningText"></p>
- </div>
- </div>
-
</div>
<div class="op-modal--modal-footer">
<button class="button -highlight"