diff --git a/web/app/components/projects/add-to-or-create.ts b/web/app/components/projects/add-to-or-create.ts index 8c3d80308..1d651826c 100644 --- a/web/app/components/projects/add-to-or-create.ts +++ b/web/app/components/projects/add-to-or-create.ts @@ -31,7 +31,7 @@ export default class ProjectsAddToOrCreate extends Component { return ( - project.status === ProjectStatus.Active && !this.args.document.projects?.includes(parseInt(project.id)) && project.title.toLowerCase().includes(this.query.toLowerCase()) ); @@ -89,8 +88,10 @@ export default class ProjectsAddToOrCreate extends Component { this.dd = dd; - this.allProjects = await this.fetchSvc - .fetch(`/api/${this.configSvc.config.api_version}/projects`) + this.activeProjects = await this.fetchSvc + .fetch( + `/api/${this.configSvc.config.api_version}/projects?status=${ProjectStatus.Active}`, + ) .then((response) => response?.json()); next(() => { diff --git a/web/app/components/projects/index.hbs b/web/app/components/projects/index.hbs index b553058b7..91d099f4b 100644 --- a/web/app/components/projects/index.hbs +++ b/web/app/components/projects/index.hbs @@ -17,9 +17,9 @@ -{{#if this.shownProjects.length}} +{{#if @projects.length}}
    - {{#each this.shownProjects as |project|}} + {{#each @projects as |project|}}
  1. diff --git a/web/app/components/projects/index.ts b/web/app/components/projects/index.ts index 6a1f63954..dcc23c32f 100644 --- a/web/app/components/projects/index.ts +++ b/web/app/components/projects/index.ts @@ -33,12 +33,6 @@ export default class ProjectsIndexComponent extends Component project.status === this.args.status, - ); - } } declare module "@glint/environment-ember-loose/registry" { diff --git a/web/app/routes/authenticated/projects/index.ts b/web/app/routes/authenticated/projects/index.ts index bee868778..384e6a616 100644 --- a/web/app/routes/authenticated/projects/index.ts +++ b/web/app/routes/authenticated/projects/index.ts @@ -17,12 +17,11 @@ export default class AuthenticatedProjectsIndexRoute extends Route { async model(params: { status: string }) { const projects = await this.fetchSvc - .fetch(`/api/${this.configSvc.config.api_version}/projects`) + .fetch( + `/api/${this.configSvc.config.api_version}/projects?status=${params.status}`, + ) .then((response) => response?.json()); - // We'll eventually use the status param in the query; - // for now, we pass it to the component for local filtering - return { projects, status: params.status as ProjectStatus }; } } diff --git a/web/mirage/config.ts b/web/mirage/config.ts index 926998028..b900441e0 100644 --- a/web/mirage/config.ts +++ b/web/mirage/config.ts @@ -412,8 +412,17 @@ export default function (mirageConfig) { }); // Fetch a list of projects. - this.get("/projects", () => { - const projects = this.schema.projects.all().models; + // If a status is provided, filter by it. + this.get("/projects", (schema, request) => { + const { status } = request.queryParams; + + let projects; + + if (status) { + projects = schema.projects.where({ status }).models; + } else { + projects = schema.projects.all().models; + } return new Response( 200, {},