Fixing back navigation to genre or studio

This commit is contained in:
Zoe Roux 2020-09-27 17:16:24 +02:00
parent ca0898c929
commit 97a57a500d
2 changed files with 11 additions and 8 deletions

View File

@ -34,16 +34,16 @@ const routes: Routes = [
resolve: {items: PageResolver.forResource<LibraryItem>("library/:slug/items", ItemsGridComponent.routeMapper)},
canLoad: [AuthGuard.forPermissions("read")],
canActivate: [AuthGuard.forPermissions("read")],
runGuardsAndResolvers: "always"
runGuardsAndResolvers: "always",
},
{path: "genre/:slug", component: ItemsGridComponent, pathMatch: "full",
{path: "genre/:slug", component: ItemsGridComponent,
resolve: {items: PageResolver.forResource<Show>("shows", ItemsGridComponent.routeMapper, "genres=ctn::slug")},
canLoad: [AuthGuard.forPermissions("read")],
canActivate: [AuthGuard.forPermissions("read")],
runGuardsAndResolvers: "always"
},
{path: "studio/:slug", component: ItemsGridComponent, pathMatch: "full",
{path: "studio/:slug", component: ItemsGridComponent,
resolve: {items: PageResolver.forResource<Show>("shows", ItemsGridComponent.routeMapper, "studio=:slug")},
canLoad: [AuthGuard.forPermissions("read")],
canActivate: [AuthGuard.forPermissions("read")],

View File

@ -51,7 +51,7 @@ export class ItemsGridComponent
let selectedGenres: string[] = [];
if (this.route.snapshot.queryParams.genres?.startsWith("ctn:"))
selectedGenres = this.route.snapshot.queryParams.genres.substr(4).split(',');
else if (this.route.snapshot.queryParams.genre != null)
else if (this.route.snapshot.queryParams.genres != null)
selectedGenres = this.route.snapshot.queryParams.genres.split(',');
if (this.router.url.startsWith("/genre"))
selectedGenres.push(this.route.snapshot.params.slug);
@ -62,12 +62,13 @@ export class ItemsGridComponent
{
this.studios = data;
this.filters.studio = this.studios.find(x => x.slug == this.route.snapshot.queryParams.studio
|| x.slug == this.route.snapshot.params.slug);
|| x.slug == this.route.snapshot.params.slug);
});
}
// TODO support dynamic switching between /genre & /browse & /whatever.
// TODO disable page refresh when swiching from /browse to /studio to /genre.
// TODO /collection & /people does not get refreshed data from the provider when using a new filter/sort.
// TODO add /people to the switch list.
/*
* /browse -> /api/items | /api/shows
@ -122,7 +123,7 @@ export class ItemsGridComponent
let param: string = null;
if (isArray && this.filters[category].length > 0)
param = `ctn:${this.filters[category].map(x => x.slug).join(',')}`;
param = `${this.filters[category].map(x => x.slug).join(',')}`;
else if (!isArray && this.filters[category] != null)
param = filter.slug;
@ -134,6 +135,7 @@ export class ItemsGridComponent
{
this.router.navigate(["genre", this.filters.genres[0].slug], {
replaceUrl: true,
queryParams: {[category]: null},
queryParamsHandling: "merge"
});
return;
@ -142,6 +144,7 @@ export class ItemsGridComponent
{
this.router.navigate(["studio", this.filters.studio.slug], {
replaceUrl: true,
queryParams: {[category]: null},
queryParamsHandling: "merge"
});
return;
@ -152,7 +155,7 @@ export class ItemsGridComponent
if (this.router.url.startsWith("/studio"))
params.studio = this.route.snapshot.params.slug;
if (this.router.url.startsWith("/genre") && category != "genres")
params.genres = `ctn:${this.route.snapshot.params.slug}`;
params.genres = `${this.route.snapshot.params.slug}`;
this.router.navigate(["/browse"], {
queryParams: params,