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

Convert "Create new" routes/controllers to TS #334

Merged
merged 4 commits into from
Sep 18, 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
11 changes: 0 additions & 11 deletions web/app/controllers/authenticated/new/doc.js

This file was deleted.

9 changes: 9 additions & 0 deletions web/app/controllers/authenticated/new/doc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Controller from "@ember/controller";
import AuthenticatedNewDocRoute from "hermes/routes/authenticated/new/doc";
import { ModelFrom } from "hermes/types/route-models";

export default class AuthenticatedNewDocController extends Controller {
queryParams = ["docType"];

declare model: ModelFrom<AuthenticatedNewDocRoute>;
}
3 changes: 3 additions & 0 deletions web/app/routes/authenticated/new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from "@ember/routing/route";

export default class AuthenticatedNewRoute extends Route {}
21 changes: 0 additions & 21 deletions web/app/routes/authenticated/new/doc.js

This file was deleted.

17 changes: 17 additions & 0 deletions web/app/routes/authenticated/new/doc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Route from "@ember/routing/route";

interface AuthenticatedNewDocRouteParams {
docType: string;
}

export default class AuthenticatedNewDocRoute extends Route {
queryParams = {
docType: {
refreshModel: true,
},
};

model(params: AuthenticatedNewDocRouteParams) {
return params.docType;
}
}
12 changes: 0 additions & 12 deletions web/app/routes/authenticated/new/index.js

This file was deleted.

14 changes: 14 additions & 0 deletions web/app/routes/authenticated/new/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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 {
@service("fetch") declare fetchSvc: FetchService;

async model() {
return (await this.fetchSvc
.fetch("/api/v1/document-types")
.then((r) => r?.json())) as HermesDocumentType[];
}
}
1 change: 0 additions & 1 deletion web/app/templates/authenticated/new.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-nocheck: not typesafe yet }}
<Header />
<section>
<div class="x-container">
Expand Down
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.docType)}}
{{page-title (concat "Create Your " @model)}}

<New::DocForm @docType={{@model.docType}} />
<New::DocForm @docType={{@model}} />
10 changes: 4 additions & 6 deletions web/app/templates/authenticated/new/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
{{#each @model as |docType|}}
<li class="relative">
<LinkTo
class="w-full h-full no-underline"
class="h-full w-full no-underline"
@route="authenticated.new.doc"
@query={{hash docType=docType.name}}
>
<Hds::Card::Container
@level="mid"
@levelHover="high"
@hasBorder="true"
@hasBorder={{true}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small Glint fix

class="template-card
{{if docType.moreInfoLink 'template-card--with-link'}}"
>
<div>
<p class="text-display-200 text-color-foreground-primary mb-1">
<p class="mb-1 text-display-200 text-color-foreground-primary">
{{docType.name}}
</p>
<h2
Expand All @@ -38,12 +38,10 @@
@href={{docType.moreInfoLink.url}}
@icon="external-link"
@iconPosition="trailing"
class="small-external-link absolute bottom-6 left-5 whitespace-nowrap z-10"
class="small-external-link absolute bottom-6 left-5 z-10 whitespace-nowrap"
@text={{docType.moreInfoLink.text}}
/>
{{/if}}
</li>

{{/each}}

</ol>