Skip to content

Commit

Permalink
Revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Sep 8, 2023
1 parent 8365699 commit fc04604
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 38 deletions.
4 changes: 0 additions & 4 deletions web/app/controllers/authenticated/new/doc.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Controller from "@ember/controller";
import { inject as service } from "@ember/service";
import RouterService from "@ember/routing/router-service";
import AuthenticatedNewDocRoute from "hermes/routes/authenticated/new/doc";
import { ModelFrom } from "hermes/types/route-models";

export default class AuthenticatedNewDocController extends Controller {
@service declare router: RouterService;

queryParams = ["docType"];

declare model: ModelFrom<AuthenticatedNewDocRoute>;
Expand Down
13 changes: 1 addition & 12 deletions web/app/routes/authenticated/new.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import FetchService from "hermes/services/fetch";
import { HermesDocumentType } from "hermes/types/document-type";

export default class AuthenticatedNewRoute extends Route {
@service("fetch") declare fetchSvc: FetchService;

async model() {
return (await this.fetchSvc
.fetch("/api/v1/document-types")
.then((r) => r?.json())) as HermesDocumentType[];
}
}
export default class AuthenticatedNewRoute extends Route {}
18 changes: 1 addition & 17 deletions web/app/routes/authenticated/new/doc.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import FetchService from "hermes/services/fetch";
import FlashMessageService from "ember-cli-flash/services/flash-messages";
import RouterService from "@ember/routing/router-service";
import { HermesDocumentType } from "hermes/types/document-type";
import { assert } from "@ember/debug";

interface AuthenticatedNewDocRouteParams {
docType: string;
}

export default class AuthenticatedNewDocRoute extends Route {
@service("fetch") declare fetchSvc: FetchService;
@service declare flashMessages: FlashMessageService;
@service declare router: RouterService;

queryParams = {
docType: {
refreshModel: true,
},
};

model(params: AuthenticatedNewDocRouteParams) {
const docTypes = this.modelFor("authenticated.new") as HermesDocumentType[];
const docType = docTypes.find(
(_docType) => _docType.name === params.docType
);

assert("docType must exist", docType);
return docType;
return params.docType;
}
}
11 changes: 8 additions & 3 deletions web/app/routes/authenticated/new/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import FetchService from "hermes/services/fetch";
import { HermesDocumentType } from "hermes/types/document-type";

export default class AuthenticatedNewIndexRoute extends Route {
model() {
return this.modelFor("authenticated.new") as HermesDocumentType[];
}
@service("fetch") declare fetchSvc: FetchService;

async model() {
return (await this.fetchSvc
.fetch("/api/v1/document-types")
.then((r) => r?.json())) as HermesDocumentType[];
}
4 changes: 2 additions & 2 deletions web/app/templates/authenticated/new/doc.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{page-title (concat "Create Your " @model.name)}}
{{page-title (concat "Create Your " @model)}}

<New::DocForm @docType={{@model.name}} />
<New::DocForm @docType={{@model}} />

0 comments on commit fc04604

Please sign in to comment.