From 630b3376bd4aa67af86c07b43b11cb6e3edac9d3 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Wed, 18 Oct 2023 15:16:00 -0400 Subject: [PATCH] Add productAreas fetch call to NewDoc screen --- web/app/routes/authenticated/new/doc.ts | 10 +++++++++- web/app/services/product-areas.ts | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/web/app/routes/authenticated/new/doc.ts b/web/app/routes/authenticated/new/doc.ts index 0a84dfdbd..13929e40c 100644 --- a/web/app/routes/authenticated/new/doc.ts +++ b/web/app/routes/authenticated/new/doc.ts @@ -1,17 +1,25 @@ import Route from "@ember/routing/route"; +import { inject as service } from "@ember/service"; +import ProductAreasService from "hermes/services/product-areas"; interface AuthenticatedNewDocRouteParams { docType: string; } export default class AuthenticatedNewDocRoute extends Route { + @service declare productAreas: ProductAreasService; + queryParams = { docType: { refreshModel: true, }, }; - model(params: AuthenticatedNewDocRouteParams) { + async model(params: AuthenticatedNewDocRouteParams) { + if (!this.productAreas.index) { + await this.productAreas.fetch.perform(); + } + return params.docType; } } diff --git a/web/app/services/product-areas.ts b/web/app/services/product-areas.ts index 875d75fc1..7730ad915 100644 --- a/web/app/services/product-areas.ts +++ b/web/app/services/product-areas.ts @@ -1,8 +1,6 @@ import Service, { inject as service } from "@ember/service"; import { tracked } from "@glimmer/tracking"; -import { action } from "@ember/object"; -import RouterService from "@ember/routing/router-service"; -import { task, timeout } from "ember-concurrency"; +import { task } from "ember-concurrency"; import FetchService from "./fetch"; export type ProductArea = {