-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of DocType icons (#481)
* Create DocumentTypes service * Update tests
- Loading branch information
Showing
12 changed files
with
82 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
import DocumentTypesService from "hermes/services/document-types"; | ||
|
||
export default class AuthenticatedNewRoute extends Route {} | ||
export default class AuthenticatedNewRoute extends Route { | ||
@service declare documentTypes: DocumentTypesService; | ||
|
||
async model() { | ||
if (!this.documentTypes.index) { | ||
await this.documentTypes.fetch.perform(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
import ConfigService from "hermes/services/config"; | ||
import FetchService from "hermes/services/fetch"; | ||
import { HermesDocumentType } from "hermes/types/document-type"; | ||
|
||
export default class AuthenticatedNewIndexRoute extends Route { | ||
@service("config") declare configSvc: ConfigService; | ||
@service("fetch") declare fetchSvc: FetchService; | ||
|
||
async model() { | ||
return (await this.fetchSvc | ||
.fetch(`/api/${this.configSvc.config.api_version}/document-types`) | ||
.then((r) => r?.json())) as HermesDocumentType[]; | ||
} | ||
} | ||
export default class AuthenticatedNewIndexRoute extends Route {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Service, { inject as service } from "@ember/service"; | ||
import { tracked } from "@glimmer/tracking"; | ||
import { task } from "ember-concurrency"; | ||
import ConfigService from "hermes/services/config"; | ||
import FetchService from "./fetch"; | ||
import { HermesDocumentType } from "hermes/types/document-type"; | ||
|
||
export default class DocumentTypesService extends Service { | ||
@service("config") declare configSvc: ConfigService; | ||
@service("fetch") declare fetchSvc: FetchService; | ||
|
||
@tracked index: HermesDocumentType[] | null = null; | ||
|
||
fetch = task(async () => { | ||
this.index = (await this.fetchSvc | ||
.fetch(`/api/${this.configSvc.config.api_version}/document-types`) | ||
.then((r) => r?.json())) as HermesDocumentType[]; | ||
}); | ||
|
||
getFlightIcon(type: string): string | undefined { | ||
const docType = this.index?.find((t) => t.name === type); | ||
|
||
if (!docType) { | ||
return; | ||
} | ||
|
||
return docType.flightIcon; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{{page-title "Choose a template"}} | ||
|
||
<New::DocumentTemplateList @docTypes={{this.model}} /> | ||
<New::DocumentTemplateList /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.