mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
883 B
33 lines
883 B
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { Injectable } from '@angular/core';
|
|
import { map, Observable, of } from 'rxjs';
|
|
import { AutocompleteSource } from '@app/framework';
|
|
import { ContributorsState } from '@app/shared/internal';
|
|
|
|
@Injectable()
|
|
export class ContributorsDataSource implements AutocompleteSource {
|
|
constructor(
|
|
private readonly contributorsState: ContributorsState,
|
|
) {
|
|
}
|
|
|
|
public loadIfNotLoaded() {
|
|
this.contributorsState.loadIfNotLoaded();
|
|
}
|
|
|
|
public find(query: string): Observable<ReadonlyArray<any>> {
|
|
if (!query) {
|
|
return of([]);
|
|
}
|
|
|
|
return this.contributorsState.contributors.pipe(
|
|
map(contributors => contributors.filter(c => c.contributorEmail.indexOf(query) >= 0)),
|
|
);
|
|
}
|
|
}
|