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
Instead of posting to the API with every search input, the projects are loaded initially, and then filtered in the frontend. This functionality is similar to the projectInclude component which is why I extracted it into a service.
Henriette Darge205f90e192a3
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex f4f382543bd..c1d461b367d 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -86,6 +86,7 @@ import { OpenProjectInAppNotificationsModule } from 'core-app/features/in-app-noimport { OpenProjectBackupService } from './core/backup/op-backup.service';import { OpenProjectDirectFileUploadService } from './core/file-upload/op-direct-file-upload.service';import { OpenProjectStateModule } from 'core-app/core/state/openproject-state.module';+import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';export function initializeServices(injector:Injector) {return () => {@@ -179,6 +180,9 @@ export function initializeServices(injector:Injector) {// NotificationsOpenProjectInAppNotificationsModule,++ // Loading+ OpenprojectContentLoaderModule,],providers: [{ provide: States, useValue: new States() },diff --git a/frontend/src/app/core/path-helper/path-helper.service.ts b/frontend/src/app/core/path-helper/path-helper.service.tsindex 06871d64b46..d27a7ac927d 100644--- a/frontend/src/app/core/path-helper/path-helper.service.ts+++ b/frontend/src/app/core/path-helper/path-helper.service.ts@@ -120,7 +120,7 @@ export class PathHelperService {return `${this.staticBase}/projects`;}- public projectsNewPath() {+ public projectsNewPath():string {return `${this.staticBase}/projects/new`;}diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/load-projects.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/load-projects.tsdeleted file mode 100644index 21f190b07f7..00000000000--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/load-projects.ts+++ /dev/null@@ -1,67 +0,0 @@-import {- IProjectAutocompleteItem,- IProjectAutocompleteItemTree,-} from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';-import { Observable } from 'rxjs';-import { getPaginatedResults } from 'core-app/core/apiv3/helpers/get-paginated-results';-import { IProject } from 'core-app/core/state/projects/project.model';-import {- ApiV3ListFilter,- listParamsString,-} from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';-import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';-import { map } from 'rxjs/operators';-import { buildTree } from 'core-app/shared/components/autocompleter/project-autocompleter/insert-in-list';-import { recursiveSort } from 'core-app/shared/components/autocompleter/project-autocompleter/recursive-sort';-import { HttpClient } from '@angular/common/http';--export const loadAvailableProjects = (- searchTerm:string,- apiFilters:ApiV3ListFilter[],- apiUrl:string,- mapResultsFn:(projects:IProjectAutocompleteItem[]) => IProjectAutocompleteItem[] = (projects) => projects,- http:HttpClient,-):Observable<IProjectAutocompleteItemTree[]> => {- return getPaginatedResults<IProject>(- (params) => {- const filters:ApiV3ListFilter[] = [...apiFilters];-- if (searchTerm.length) {- filters.push(['name_and_identifier', '~', [searchTerm]]);- }-- const url = new URL(apiUrl, window.location.origin);- const fullParams = {- filters,- select: [- 'elements/id',- 'elements/name',- 'elements/identifier',- 'elements/self',- 'elements/ancestors',- 'total',- 'count',- 'pageSize',- ],- ...params,- };- const collectionURL = `${listParamsString(fullParams)}&${url.searchParams.toString()}`;- url.searchParams.forEach((key) => url.searchParams.delete(key));- return http.get<IHALCollection<IProject>>(url.toString() + collectionURL);- },- )- .pipe(- map((projects) => projects.map((project) => ({- id: project.id,- href: project._links.self.href,- name: project.name,- disabled: false,- ancestors: project._links.ancestors,- children: [],- }))),- map(mapResultsFn),- map((projects) => projects.sort((a, b) => a.ancestors.length - b.ancestors.length)),- map((projects) => buildTree(projects)),- map((projects) => recursiveSort(projects)),- );-};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 f881b49f294..beee790804f 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@@ -52,12 +52,19 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.serviceimport { I18nService } from 'core-app/core/i18n/i18n.service';import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';+import {+ ApiV3ListFilter,+ listParamsString,+} from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';import { IProjectAutocompleteItem } from './project-autocomplete-item';import { flattenProjectTree } from './flatten-project-tree';-import { loadAvailableProjects } from 'core-app/shared/components/autocompleter/project-autocompleter/load-projects';+import { getPaginatedResults } from 'core-app/core/apiv3/helpers/get-paginated-results';+import { IProject } from 'core-app/core/state/projects/project.model';+import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';+import { buildTree } from 'core-app/shared/components/autocompleter/project-autocompleter/insert-in-list';+import { recursiveSort } from 'core-app/shared/components/autocompleter/project-autocompleter/recursive-sort';export const projectsAutocompleterSelector = 'op-project-autocompleter';@@ -147,15 +154,49 @@ export class ProjectAutocompleterComponent implements ControlValueAccessor {}public getAvailableProjects(searchTerm:string):Observable<IProjectAutocompleteItem[]> {- return loadAvailableProjects(- searchTerm,- this.apiFilters,- this.url,- this.mapResultsFn,- this.http,- ).pipe(- map((projectTreeItems) => flattenProjectTree(projectTreeItems)),- );+ return getPaginatedResults<IProject>(+ (params) => {+ const filters:ApiV3ListFilter[] = [...this.apiFilters];++ if (searchTerm.length) {+ filters.push(['name_and_identifier', '~', [searchTerm]]);+ }++ const url = new URL(this.url, window.location.origin);+ const fullParams = {+ filters,+ select: [+ 'elements/id',+ 'elements/name',+ 'elements/identifier',+ 'elements/self',+ 'elements/ancestors',+ 'total',+ 'count',+ 'pageSize',+ ],+ ...params,+ };+ const collectionURL = `${listParamsString(fullParams)}&${url.searchParams.toString()}`;+ url.searchParams.forEach((key) => url.searchParams.delete(key));+ return this.http.get<IHALCollection<IProject>>(url.toString() + collectionURL);+ },+ )+ .pipe(+ map((projects) => projects.map((project) => ({+ id: project.id,+ href: project._links.self.href,+ name: project.name,+ disabled: false,+ ancestors: project._links.ancestors,+ children: [],+ }))),+ map(this.mapResultsFn),+ map((projects) => projects.sort((a, b) => a.ancestors.length - b.ancestors.length)),+ map((projects) => buildTree(projects)),+ map((projects) => recursiveSort(projects)),+ map((projectTreeItems) => flattenProjectTree(projectTreeItems)),+ );}writeValue(value:IProjectAutocompleterData|null):void {diff --git a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.component.ts b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.component.tsindex 3a6441b55d8..30c44fa28f3 100644--- a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.component.ts+++ b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.component.ts@@ -28,24 +28,22 @@import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { HttpClient } from '@angular/common/http';import {ChangeDetectionStrategy,Component,- OnInit,} from '@angular/core';import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-import { BehaviorSubject } from 'rxjs';+import { combineLatest } from 'rxjs';import {debounceTime,map,shareReplay,- switchMap,} from 'rxjs/operators';-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import { loadAvailableProjects } from 'core-app/shared/components/autocompleter/project-autocompleter/load-projects';-import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';-import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';+import { IProject } from 'core-app/core/state/projects/project.model';+import { insertInList } from 'core-app/shared/components/project-include/insert-in-list';+import { IProjectData } from 'core-app/shared/components/project-list/project-data';+import { recursiveSort } from 'core-app/shared/components/project-include/recursive-sort';+import { SearchableProjectListService } from 'core-app/shared/components/searchable-project-list/searchable-project-list.service';export const projectMenuAutocompleteSelector = 'project-menu-autocomplete';@@ -53,30 +51,45 @@ export const projectMenuAutocompleteSelector = 'project-menu-autocomplete';templateUrl: './project-menu-autocomplete.template.html',changeDetection: ChangeDetectionStrategy.OnPush,selector: projectMenuAutocompleteSelector,+ providers: [+ SearchableProjectListService,+ ],})-export class ProjectMenuAutocompleteComponent implements OnInit {+export class ProjectMenuAutocompleteComponent {dropModalOpen = false;- private _searchText = '';-- public get searchText():string {- return this._searchText;- }-- public set searchText(val:string) {- this._searchText = val;- this.searchText$.next(val);- }-- public searchText$ = new BehaviorSubject('');-- projects$ = this- .searchText$- .pipe(- debounceTime(200),- switchMap((term) => this.loadProjects(term)),- shareReplay(),- );+ projects$ = combineLatest([+ this.searchableProjectListService.allProjects$,+ this.searchableProjectListService.searchText$.pipe(debounceTime(200)),+ ]).pipe(+ map(+ ([projects, searchText]:[IProject[], string]) => projects+ .filter(+ (project) => {+ if (searchText.length) {+ const matches = project.name.toLowerCase().includes(searchText.toLowerCase()) || project.identifier.toLowerCase().includes(searchText.toLowerCase());++ if (!matches) {+ return false;+ }+ }++ return true;+ },+ )+ .sort((a, b) => a._links.ancestors.length - b._links.ancestors.length)+ .reduce(+ (list, project) => {+ const { ancestors } = project._links;++ return insertInList(projects, project, list, ancestors);+ },+ [] as IProjectData[],+ ),+ ),+ map((projects) => recursiveSort(projects)),+ shareReplay(),+ );public text = {project: {@@ -88,22 +101,29 @@ export class ProjectMenuAutocompleteComponent implements OnInit {search_placeholder: this.I18n.t('js.include_projects.search_placeholder'),};+ public loading$ = combineLatest([+ this.searchableProjectListService.fetchingProjects$,+ this.projects$,+ ]).pipe(+ map(([isFetching, projects]) => isFetching || projects.length === 0),+ );+constructor(protected pathHelper:PathHelperService,protected I18n:I18nService,protected currentProject:CurrentProjectService,- protected apiV3Service:ApiV3Service,- protected http:HttpClient,+ readonly searchableProjectListService:SearchableProjectListService,) {}- ngOnInit():void {- }-toggleDropModal():void {this.dropModalOpen = !this.dropModalOpen;+ if (this.dropModalOpen) {+ this.searchableProjectListService.loadAllProjects();+ }}close():void {+ this.searchableProjectListService.searchText = '';this.dropModalOpen = false;}@@ -123,29 +143,4 @@ export class ProjectMenuAutocompleteComponent implements OnInit {const parentParam = this.currentProject.id ? `?parent_id=${this.currentProject.id}` : '';return `${this.pathHelper.projectsNewPath()}${parentParam}`;}-- private loadProjects(searchString:string) {- const apiFilters:ApiV3ListFilter[] = [];- const apiUrl = this.apiV3Service.projects.path;- const mapResultsFn = (projects:IProjectAutocompleteItem[]) => projects;-- return loadAvailableProjects(- searchString,- apiFilters,- apiUrl,- mapResultsFn,- this.http,- )- .pipe(- map((projects) => {- return projects.map((project) => ({- id: project.id,- href: project.href,- name: project.name,- found: true,- children: project.children,- }));- }),- );- }}diff --git a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.htmlindex 2a1d6c93c40..8cb0e70356f 100644--- a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html+++ b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html@@ -29,8 +29,9 @@class="op-project-list-modal--body spot-container"><spot-text-field+ [disabled]="(loading$ | async)"[placeholder]="text.search_placeholder"- [(ngModel)]="searchText"+ [(ngModel)]="searchableProjectListService.searchText"[ngModelOptions]="{standalone: true}"><span@@ -39,12 +40,14 @@></span></spot-text-field>- <ul- op-project-list- [projects]="projects$ | async"- [searchText]="searchText"- [multiSelect]="false"- ></ul>+ <ng-container *ngIf="(loading$ | async) === false; else loadingTemplate">+ <ul+ op-project-list+ [projects]="projects$ | async"+ [searchText]="searchableProjectListService.searchText"+ [multiSelect]="false"+ ></ul>+ </ng-container><div class="spot-action-bar"><div class="spot-action-bar--right">@@ -72,8 +75,34 @@</div></div></ng-container>++ <ng-template #loadingTemplate>+ <op-content-loader+ class="op-project-list-modal--loading"+ viewBox="0 0 200 140"+ >+ <svg:rect x="0" width="100%" height="12" rx="1" />++ <svg:rect x="10" y="16" width="100%" height="12" rx="1" />++ <svg:rect x="10" y="32" width="100%" height="12" rx="1" />++ <svg:rect x="20" y="48" width="100%" height="12" rx="1" />++ <svg:rect x="20" y="64" width="100%" height="12" rx="1" />++ <svg:rect x="0" y="80" width="100%" height="12" rx="1" />++ <svg:rect x="10" y="96" width="100%" height="12" rx="1" />++ <svg:rect x="10" y="112" width="100%" height="12" rx="1" />++ <svg:rect x="0" y="128" width="100%" height="12" rx="1" />+ </op-content-loader>+ </ng-template></spot-drop-modal>+<!--<divclass="dropdown dropdown-relative project-search-results"id="project_autocompletion_wrapper"diff --git a/frontend/src/app/shared/components/project-include/project-include.component.html b/frontend/src/app/shared/components/project-include/project-include.component.htmlindex 90bae8b4ad7..c181a6ea6f9 100644--- a/frontend/src/app/shared/components/project-include/project-include.component.html+++ b/frontend/src/app/shared/components/project-include/project-include.component.html@@ -36,7 +36,7 @@[disabled]="(loading$ | async)"[placeholder]="text.search_placeholder"name="project-include-search"- [(ngModel)]="searchText"+ [(ngModel)]="searchableProjectListService.searchText"[ngModelOptions]="{standalone: true}"data-qa-selector="project-include-search">@@ -53,7 +53,7 @@[projects]="projects$ | async"[selected]="selectedProjects"[includeSubprojects]="includeSubprojects$ | async"- [searchText]="searchText"+ [searchText]="searchableProjectListService.searchText"[root]="true"(update)="selectedProjects = $event"data-qa-selector="project-include-list"@@ -90,39 +90,39 @@</div></form></ng-container>-</spot-drop-modal>-<ng-template #loadingTemplate>- <op-content-loader- class="op-project-include--loading"- data-qa-selector="op-project-include--loading"- viewBox="0 0 200 140"- >- <svg:rect x="0" width="12" height="12" rx="1" />- <svg:rect x="15" width="100%" height="12" rx="1" />+ <ng-template #loadingTemplate>+ <op-content-loader+ class="op-project-list-modal--loading"+ data-qa-selector="op-project-include--loading"+ viewBox="0 0 200 140"+ >+ <svg:rect x="0" width="12" height="12" rx="1" />+ <svg:rect x="15" width="100%" height="12" rx="1" />- <svg:rect x="10" y="16" width="12" height="12" rx="1" />- <svg:rect x="25" y="16" width="100%" height="12" rx="1" />+ <svg:rect x="10" y="16" width="12" height="12" rx="1" />+ <svg:rect x="25" y="16" width="100%" height="12" rx="1" />- <svg:rect x="10" y="32" width="12" height="12" rx="1" />- <svg:rect x="25" y="32" width="100%" height="12" rx="1" />+ <svg:rect x="10" y="32" width="12" height="12" rx="1" />+ <svg:rect x="25" y="32" width="100%" height="12" rx="1" />- <svg:rect x="20" y="48" width="12" height="12" rx="1" />- <svg:rect x="35" y="48" width="100%" height="12" rx="1" />+ <svg:rect x="20" y="48" width="12" height="12" rx="1" />+ <svg:rect x="35" y="48" width="100%" height="12" rx="1" />- <svg:rect x="20" y="64" width="12" height="12" rx="1" />- <svg:rect x="35" y="64" width="100%" height="12" rx="1" />+ <svg:rect x="20" y="64" width="12" height="12" rx="1" />+ <svg:rect x="35" y="64" width="100%" height="12" rx="1" />- <svg:rect x="0" y="80" width="12" height="12" rx="1" />- <svg:rect x="15" y="80" width="100%" height="12" rx="1" />+ <svg:rect x="0" y="80" width="12" height="12" rx="1" />+ <svg:rect x="15" y="80" width="100%" height="12" rx="1" />- <svg:rect x="10" y="96" width="12" height="12" rx="1" />- <svg:rect x="25" y="96" width="100%" height="12" rx="1" />+ <svg:rect x="10" y="96" width="12" height="12" rx="1" />+ <svg:rect x="25" y="96" width="100%" height="12" rx="1" />- <svg:rect x="10" y="112" width="12" height="12" rx="1" />- <svg:rect x="25" y="112" width="100%" height="12" rx="1" />+ <svg:rect x="10" y="112" width="12" height="12" rx="1" />+ <svg:rect x="25" y="112" width="100%" height="12" rx="1" />- <svg:rect x="0" y="128" width="12" height="12" rx="1" />- <svg:rect x="15" y="128" width="100%" height="12" rx="1" />- </op-content-loader>-</ng-template>+ <svg:rect x="0" y="128" width="12" height="12" rx="1" />+ <svg:rect x="15" y="128" width="100%" height="12" rx="1" />+ </op-content-loader>+ </ng-template>+</spot-drop-modal>diff --git a/frontend/src/app/shared/components/project-include/project-include.component.sass b/frontend/src/app/shared/components/project-include/project-include.component.sassindex d055a7c360c..d9abf1aaf7d 100644--- a/frontend/src/app/shared/components/project-include/project-include.component.sass+++ b/frontend/src/app/shared/components/project-include/project-include.component.sass@@ -1,9 +1,6 @@@import '../../../spot/styles/sass/variables'.op-project-include- &--loading- padding: $spot-spacing-1-&--include-alldisplay: flexalign-items: centerdiff --git a/frontend/src/app/shared/components/project-include/project-include.component.ts b/frontend/src/app/shared/components/project-include/project-include.component.tsindex 027636061fd..eaf4b67f81d 100644--- a/frontend/src/app/shared/components/project-include/project-include.component.ts+++ b/frontend/src/app/shared/components/project-include/project-include.component.ts@@ -13,7 +13,6 @@ import {import {debounceTime,distinctUntilChanged,- finalize,map,mergeMap,shareReplay,@@ -21,17 +20,11 @@ import {} from 'rxjs/operators';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import {- ApiV3ListFilter,- ApiV3ListParameters,- listParamsString,-} from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { WorkPackageViewFiltersService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';import { WorkPackageViewIncludeSubprojectsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-include-subprojects.service';import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';-import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';import { IProject } from 'core-app/core/state/projects/project.model';@@ -39,13 +32,16 @@ import { IProject } from 'core-app/core/state/projects/project.model';import { IProjectData } from '../project-list/project-data';import { insertInList } from './insert-in-list';import { recursiveSort } from './recursive-sort';-import { getPaginatedResults } from 'core-app/core/apiv3/helpers/get-paginated-results';+import { SearchableProjectListService } from 'core-app/shared/components/searchable-project-list/searchable-project-list.service';@Component({selector: 'op-project-include',changeDetection: ChangeDetectionStrategy.OnPush,templateUrl: './project-include.component.html',styleUrls: ['./project-include.component.sass'],+ providers: [+ SearchableProjectListService,+ ],})export class OpProjectIncludeComponent extends UntilDestroyedMixin implements OnInit {@HostBinding('class.op-project-include') className = true;@@ -83,19 +79,6 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements Onpublic displayMode$ = new BehaviorSubject('all');- private _searchText = '';-- public get searchText():string {- return this._searchText;- }-- public set searchText(val:string) {- this._searchText = val;- this.searchText$.next(val);- }-- public searchText$ = new BehaviorSubject('');-private _includeSubprojects = true;public get includeSubprojects():boolean {@@ -143,13 +126,11 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements Onpublic numberOfProjectsInFilter$ = this.projectsInFilter$.pipe(map((selected) => selected.length));- public allProjects$ = new BehaviorSubject<IProject[]>([]);-public projects$ = combineLatest([- this.allProjects$,+ this.searchableProjectListService.allProjects$,this.displayMode$.pipe(distinctUntilChanged()),this.includeSubprojects$,- this.searchText$.pipe(debounceTime(200)),+ this.searchableProjectListService.searchText$.pipe(debounceTime(200)),]).pipe(debounceTime(50),@@ -203,43 +184,20 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements OnshareReplay(),);- public fetchingProjects$ = new BehaviorSubject(false);public loading$ = combineLatest([- this.fetchingProjects$,+ this.searchableProjectListService.fetchingProjects$,this.projects$,]).pipe(map(([isFetching, projects]) => isFetching || projects.length === 0));- public get params():ApiV3ListParameters {- const filters:ApiV3ListFilter[] = [- ['active', '=', ['t']],- ];-- return {- filters,- pageSize: -1,- select: [- 'elements/id',- 'elements/name',- 'elements/identifier',- 'elements/self',- 'elements/ancestors',- 'total',- 'count',- 'pageSize',- ],- };- }-constructor(- readonly apiV3Service:ApiV3Service,readonly I18n:I18nService,- readonly http:HttpClient,readonly wpTableFilters:WorkPackageViewFiltersService,readonly wpIncludeSubprojects:WorkPackageViewIncludeSubprojectsService,readonly halResourceService:HalResourceService,readonly currentProjectService:CurrentProjectService,+ readonly searchableProjectListService:SearchableProjectListService,) {super();}@@ -263,36 +221,19 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements Onthis.opened = !this.opened;if (this.opened) {- this.loadAllProjects();+ this.searchableProjectListService.loadAllProjects();this.projectsInFilter$.pipe(take(1),).subscribe((selectedProjects) => {this.displayMode = 'all';- this.searchText = '';+ this.searchableProjectListService.searchText = '';this.selectedProjects = selectedProjects as string[];});}}- public loadAllProjects():void {- this.fetchingProjects$.next(true);-- getPaginatedResults<IProject>(- (params) => {- const collectionURL = listParamsString({ ...this.params, ...params });- return this.http.get<IHALCollection<IProject>>(this.apiV3Service.projects.path + collectionURL);- },- )- .pipe(- finalize(() => this.fetchingProjects$.next(false)),- )- .subscribe((projects) => {- this.allProjects$.next(projects);- });- }-public clearSelection():void {this.selectedProjects = [this.currentProjectService.apiv3Path || ''];}diff --git a/frontend/src/app/shared/components/searchable-project-list/searchable-project-list.service.ts b/frontend/src/app/shared/components/searchable-project-list/searchable-project-list.service.tsnew file mode 100644index 00000000000..796d36015a2--- /dev/null+++ b/frontend/src/app/shared/components/searchable-project-list/searchable-project-list.service.ts@@ -0,0 +1,76 @@+import { Injectable } from '@angular/core';+import {+ ApiV3ListFilter,+ ApiV3ListParameters,+ listParamsString,+} from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';+import { BehaviorSubject } from 'rxjs';+import { IProject } from 'core-app/core/state/projects/project.model';+import { getPaginatedResults } from 'core-app/core/apiv3/helpers/get-paginated-results';+import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';+import { finalize } from 'rxjs/operators';+import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';+import { HttpClient } from '@angular/common/http';++@Injectable()+export class SearchableProjectListService {+ private _searchText = '';++ get searchText():string {+ return this._searchText;+ }++ set searchText(val:string) {+ this._searchText = val;+ this.searchText$.next(val);+ }++ searchText$ = new BehaviorSubject('');++ allProjects$ = new BehaviorSubject<IProject[]>([]);++ fetchingProjects$ = new BehaviorSubject(false);++ constructor(+ readonly http:HttpClient,+ readonly apiV3Service:ApiV3Service,+ ) { }++ public loadAllProjects():void {+ this.fetchingProjects$.next(true);++ getPaginatedResults<IProject>(+ (params) => {+ const collectionURL = listParamsString({ ...this.params, ...params });+ return this.http.get<IHALCollection<IProject>>(this.apiV3Service.projects.path + collectionURL);+ },+ )+ .pipe(+ finalize(() => this.fetchingProjects$.next(false)),+ )+ .subscribe((projects) => {+ this.allProjects$.next(projects);+ });+ }++ public get params():ApiV3ListParameters {+ const filters:ApiV3ListFilter[] = [+ ['active', '=', ['t']],+ ];++ return {+ filters,+ pageSize: -1,+ select: [+ 'elements/id',+ 'elements/name',+ 'elements/identifier',+ 'elements/self',+ 'elements/ancestors',+ 'total',+ 'count',+ 'pageSize',+ ],+ };+ }+}diff --git a/frontend/src/global_styles/content/_project_list_modal.sass b/frontend/src/global_styles/content/_project_list_modal.sassindex fb25abbb548..f47ba71c402 100644--- a/frontend/src/global_styles/content/_project_list_modal.sass+++ b/frontend/src/global_styles/content/_project_list_modal.sass@@ -18,3 +18,6 @@@media screen and #{$spot-mq-drop-modal-in-context}width: 460pxmax-height: 70vh++ &--loading+ padding: $spot-spacing-1