Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditional ProductAreas fetch call to new/doc route #373

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion web/app/routes/authenticated/new/doc.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 1 addition & 3 deletions web/app/services/product-areas.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down