-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set up nested /all route * Update tests and hrefs * Remove console logs * Remove console.log * Remove "all" * Add "all" as a redirect route; update URLs * Cleanup and revert out-of-scope change * Fix merge errors * Add redirect test * Add note to All controller
- Loading branch information
Showing
20 changed files
with
226 additions
and
180 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Controller from "@ember/controller"; | ||
import { SortByValue } from "hermes/components/header/toolbar"; | ||
import { SortDirection } from "hermes/components/table/sortable-header"; | ||
import AuthenticatedDocumentsRoute from "hermes/routes/authenticated/documents"; | ||
import { ModelFrom } from "hermes/types/route-models"; | ||
|
||
export default class AuthenticatedDocumentsController extends Controller { | ||
queryParams = ["docType", "owners", "page", "product", "sortBy", "status"]; | ||
docType = []; | ||
owners = []; | ||
page = 1; | ||
product = []; | ||
sortBy = "dateDesc"; | ||
status = []; | ||
|
||
declare model: ModelFrom<AuthenticatedDocumentsRoute>; | ||
|
||
get sortDirection() { | ||
switch (this.model.sortedBy) { | ||
case SortByValue.DateAsc: | ||
return SortDirection.Asc; | ||
default: | ||
return SortDirection.Desc; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,11 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
import ConfigService from "hermes/services/config"; | ||
import AlgoliaService from "hermes/services/algolia"; | ||
import { DocumentsRouteParams } from "hermes/types/document-routes"; | ||
import ActiveFiltersService from "hermes/services/active-filters"; | ||
import { SortByValue } from "hermes/components/header/toolbar"; | ||
import RouterService from "@ember/routing/router-service"; | ||
|
||
export default class AuthenticatedAllRoute extends Route { | ||
@service("config") declare configSvc: ConfigService; | ||
@service declare algolia: AlgoliaService; | ||
@service declare activeFilters: ActiveFiltersService; | ||
export default class AuthenticatedDocumentsRoute extends Route { | ||
@service declare router: RouterService; | ||
|
||
queryParams = { | ||
docType: { | ||
refreshModel: true, | ||
}, | ||
owners: { | ||
refreshModel: true, | ||
}, | ||
page: { | ||
refreshModel: true, | ||
}, | ||
product: { | ||
refreshModel: true, | ||
}, | ||
sortBy: { | ||
refreshModel: true, | ||
}, | ||
status: { | ||
refreshModel: true, | ||
}, | ||
}; | ||
|
||
async model(params: DocumentsRouteParams) { | ||
const sortedBy = (params.sortBy as SortByValue) ?? SortByValue.DateDesc; | ||
const searchIndex = | ||
params.sortBy === SortByValue.DateAsc | ||
? this.configSvc.config.algolia_docs_index_name + "_createdTime_asc" | ||
: this.configSvc.config.algolia_docs_index_name + "_createdTime_desc"; | ||
|
||
let [facets, results] = await Promise.all([ | ||
this.algolia.getFacets.perform(searchIndex, params), | ||
this.algolia.getDocResults.perform(searchIndex, params), | ||
]); | ||
|
||
this.activeFilters.update(params); | ||
|
||
return { facets, results, sortedBy }; | ||
beforeModel() { | ||
this.router.transitionTo("authenticated.documents"); | ||
} | ||
} |
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,52 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
import ConfigService from "hermes/services/config"; | ||
import AlgoliaService from "hermes/services/algolia"; | ||
import { DocumentsRouteParams } from "hermes/types/document-routes"; | ||
import ActiveFiltersService from "hermes/services/active-filters"; | ||
import { SortByValue } from "hermes/components/header/toolbar"; | ||
|
||
export default class AuthenticatedDocumentsRoute extends Route { | ||
@service("config") declare configSvc: ConfigService; | ||
@service declare algolia: AlgoliaService; | ||
@service declare activeFilters: ActiveFiltersService; | ||
|
||
queryParams = { | ||
docType: { | ||
refreshModel: true, | ||
}, | ||
owners: { | ||
refreshModel: true, | ||
}, | ||
page: { | ||
refreshModel: true, | ||
}, | ||
product: { | ||
refreshModel: true, | ||
}, | ||
sortBy: { | ||
refreshModel: true, | ||
}, | ||
status: { | ||
refreshModel: true, | ||
}, | ||
}; | ||
|
||
async model(params: DocumentsRouteParams) { | ||
const sortedBy = params.sortBy ?? SortByValue.DateDesc; | ||
|
||
const searchIndex = | ||
params.sortBy === "dateAsc" | ||
? this.configSvc.config.algolia_docs_index_name + "_createdTime_asc" | ||
: this.configSvc.config.algolia_docs_index_name + "_createdTime_desc"; | ||
|
||
let [facets, results] = await Promise.all([ | ||
this.algolia.getFacets.perform(searchIndex, params), | ||
this.algolia.getDocResults.perform(searchIndex, params), | ||
]); | ||
|
||
this.activeFilters.update(params); | ||
|
||
return { facets, results, sortedBy }; | ||
} | ||
} |
File renamed without changes.
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
Oops, something went wrong.