From aae1d1edecd835e0b26ea10c56d21c739a9af96b Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Fri, 8 Sep 2023 16:39:35 -0400 Subject: [PATCH 1/4] New document / doctype cleanup --- web/app/controllers/authenticated/new/doc.js | 11 ------- web/app/controllers/authenticated/new/doc.ts | 13 ++++++++ web/app/routes/authenticated/new.ts | 14 ++++++++ web/app/routes/authenticated/new/doc.js | 21 ------------ web/app/routes/authenticated/new/doc.ts | 33 +++++++++++++++++++ web/app/routes/authenticated/new/index.js | 12 ------- web/app/templates/authenticated/new.hbs | 1 - web/app/templates/authenticated/new/doc.hbs | 4 +-- .../{new/index-test.ts => new-test.ts} | 0 9 files changed, 62 insertions(+), 47 deletions(-) delete mode 100644 web/app/controllers/authenticated/new/doc.js create mode 100644 web/app/controllers/authenticated/new/doc.ts create mode 100644 web/app/routes/authenticated/new.ts delete mode 100644 web/app/routes/authenticated/new/doc.js create mode 100644 web/app/routes/authenticated/new/doc.ts delete mode 100644 web/app/routes/authenticated/new/index.js rename web/tests/acceptance/authenticated/{new/index-test.ts => new-test.ts} (100%) diff --git a/web/app/controllers/authenticated/new/doc.js b/web/app/controllers/authenticated/new/doc.js deleted file mode 100644 index 180a7e5b4..000000000 --- a/web/app/controllers/authenticated/new/doc.js +++ /dev/null @@ -1,11 +0,0 @@ -import Controller from "@ember/controller"; -import { inject as service } from "@ember/service"; -import { action } from "@ember/object"; - -export default class AuthenticatedNewDocController extends Controller { - @service router; - - queryParams = ["docType"]; - - -} diff --git a/web/app/controllers/authenticated/new/doc.ts b/web/app/controllers/authenticated/new/doc.ts new file mode 100644 index 000000000..fefcbd95d --- /dev/null +++ b/web/app/controllers/authenticated/new/doc.ts @@ -0,0 +1,13 @@ +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; +} diff --git a/web/app/routes/authenticated/new.ts b/web/app/routes/authenticated/new.ts new file mode 100644 index 000000000..c0794d404 --- /dev/null +++ b/web/app/routes/authenticated/new.ts @@ -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 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[]; + } +} diff --git a/web/app/routes/authenticated/new/doc.js b/web/app/routes/authenticated/new/doc.js deleted file mode 100644 index bfcefae3d..000000000 --- a/web/app/routes/authenticated/new/doc.js +++ /dev/null @@ -1,21 +0,0 @@ -import Route from "@ember/routing/route"; -import RSVP from "rsvp"; -import { inject as service } from "@ember/service"; - -export default class AuthenticatedNewDocRoute extends Route { - @service("fetch") fetchSvc; - @service flashMessages; - @service router; - - queryParams = { - docType: { - refreshModel: true, - }, - }; - - async model(params) { - return RSVP.hash({ - docType: params?.docType, - }); - } -} diff --git a/web/app/routes/authenticated/new/doc.ts b/web/app/routes/authenticated/new/doc.ts new file mode 100644 index 000000000..eec1cd1b5 --- /dev/null +++ b/web/app/routes/authenticated/new/doc.ts @@ -0,0 +1,33 @@ +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; + } +} diff --git a/web/app/routes/authenticated/new/index.js b/web/app/routes/authenticated/new/index.js deleted file mode 100644 index 0893fb0e6..000000000 --- a/web/app/routes/authenticated/new/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import Route from "@ember/routing/route"; -import { inject as service } from "@ember/service"; - -export default class AuthenticatedNewIndexRoute extends Route { - @service("fetch") fetchSvc; - - async model() { - return await this.fetchSvc - .fetch("/api/v1/document-types") - .then((r) => r.json()); - } -} diff --git a/web/app/templates/authenticated/new.hbs b/web/app/templates/authenticated/new.hbs index 981f098fc..59395665c 100644 --- a/web/app/templates/authenticated/new.hbs +++ b/web/app/templates/authenticated/new.hbs @@ -1,4 +1,3 @@ -{{! @glint-nocheck: not typesafe yet }}
diff --git a/web/app/templates/authenticated/new/doc.hbs b/web/app/templates/authenticated/new/doc.hbs index 1a49077a6..7f78cbe90 100644 --- a/web/app/templates/authenticated/new/doc.hbs +++ b/web/app/templates/authenticated/new/doc.hbs @@ -1,3 +1,3 @@ -{{page-title (concat "Create Your " @model.docType)}} +{{page-title (concat "Create Your " @model.name)}} - + diff --git a/web/tests/acceptance/authenticated/new/index-test.ts b/web/tests/acceptance/authenticated/new-test.ts similarity index 100% rename from web/tests/acceptance/authenticated/new/index-test.ts rename to web/tests/acceptance/authenticated/new-test.ts From e7b0e7d8bfbdcd26e51efbaca5b4b4a3c4aafe03 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Fri, 8 Sep 2023 16:49:28 -0400 Subject: [PATCH 2/4] Rework index route --- web/app/routes/authenticated/new/index.ts | 8 ++++++++ web/app/templates/authenticated/new.hbs | 2 ++ web/app/templates/authenticated/new/index.hbs | 12 ++++-------- 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 web/app/routes/authenticated/new/index.ts diff --git a/web/app/routes/authenticated/new/index.ts b/web/app/routes/authenticated/new/index.ts new file mode 100644 index 000000000..0a86662da --- /dev/null +++ b/web/app/routes/authenticated/new/index.ts @@ -0,0 +1,8 @@ +import Route from "@ember/routing/route"; +import { HermesDocumentType } from "hermes/types/document-type"; + +export default class AuthenticatedNewIndexRoute extends Route { + model() { + return this.modelFor("authenticated.new") as HermesDocumentType[]; + } +} diff --git a/web/app/templates/authenticated/new.hbs b/web/app/templates/authenticated/new.hbs index 59395665c..c00fd7d2a 100644 --- a/web/app/templates/authenticated/new.hbs +++ b/web/app/templates/authenticated/new.hbs @@ -1,3 +1,5 @@ +{{page-title "Create a doc"}} +
diff --git a/web/app/templates/authenticated/new/index.hbs b/web/app/templates/authenticated/new/index.hbs index 4e924cbc2..88590c5e8 100644 --- a/web/app/templates/authenticated/new/index.hbs +++ b/web/app/templates/authenticated/new/index.hbs @@ -1,24 +1,22 @@ -{{page-title "New Doc"}} -

Choose a template

Start by choosing the document type you choose to create.

    {{#each @model as |docType|}}
  1. -

    +

    {{docType.name}}

  2. - {{/each}} -
From 83656992f5238b8394936c16e8d46c4ccafc3523 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Fri, 8 Sep 2023 17:00:51 -0400 Subject: [PATCH 3/4] Revert title changes --- web/app/templates/authenticated/new.hbs | 2 -- web/app/templates/authenticated/new/index.hbs | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/app/templates/authenticated/new.hbs b/web/app/templates/authenticated/new.hbs index c00fd7d2a..59395665c 100644 --- a/web/app/templates/authenticated/new.hbs +++ b/web/app/templates/authenticated/new.hbs @@ -1,5 +1,3 @@ -{{page-title "Create a doc"}} -
diff --git a/web/app/templates/authenticated/new/index.hbs b/web/app/templates/authenticated/new/index.hbs index 88590c5e8..b1da15804 100644 --- a/web/app/templates/authenticated/new/index.hbs +++ b/web/app/templates/authenticated/new/index.hbs @@ -1,3 +1,5 @@ +{{page-title "New Doc"}} +

Choose a template

Start by choosing the document type you choose to create.

    From 6e66de8c3d9f1f48b80604772a2709dc8d019f9c Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Fri, 8 Sep 2023 17:10:03 -0400 Subject: [PATCH 4/4] Revert unnecessary changes --- web/app/controllers/authenticated/new/doc.ts | 4 ---- web/app/routes/authenticated/new.ts | 13 +------------ web/app/routes/authenticated/new/doc.ts | 18 +----------------- web/app/routes/authenticated/new/index.ts | 10 ++++++++-- web/app/templates/authenticated/new/doc.hbs | 4 ++-- 5 files changed, 12 insertions(+), 37 deletions(-) diff --git a/web/app/controllers/authenticated/new/doc.ts b/web/app/controllers/authenticated/new/doc.ts index fefcbd95d..8cecbd5c8 100644 --- a/web/app/controllers/authenticated/new/doc.ts +++ b/web/app/controllers/authenticated/new/doc.ts @@ -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; diff --git a/web/app/routes/authenticated/new.ts b/web/app/routes/authenticated/new.ts index c0794d404..986d7d189 100644 --- a/web/app/routes/authenticated/new.ts +++ b/web/app/routes/authenticated/new.ts @@ -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 {} diff --git a/web/app/routes/authenticated/new/doc.ts b/web/app/routes/authenticated/new/doc.ts index eec1cd1b5..0a84dfdbd 100644 --- a/web/app/routes/authenticated/new/doc.ts +++ b/web/app/routes/authenticated/new/doc.ts @@ -1,20 +1,10 @@ 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, @@ -22,12 +12,6 @@ export default class AuthenticatedNewDocRoute extends Route { }; 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; } } diff --git a/web/app/routes/authenticated/new/index.ts b/web/app/routes/authenticated/new/index.ts index 0a86662da..46f2f6548 100644 --- a/web/app/routes/authenticated/new/index.ts +++ b/web/app/routes/authenticated/new/index.ts @@ -1,8 +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 { - 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[]; } } diff --git a/web/app/templates/authenticated/new/doc.hbs b/web/app/templates/authenticated/new/doc.hbs index 7f78cbe90..d7c8beab5 100644 --- a/web/app/templates/authenticated/new/doc.hbs +++ b/web/app/templates/authenticated/new/doc.hbs @@ -1,3 +1,3 @@ -{{page-title (concat "Create Your " @model.name)}} +{{page-title (concat "Create Your " @model)}} - +