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

#2324/ Admin UI should accept queryParam to route to details or list editor view #2327

Merged
merged 7 commits into from
Apr 2, 2024
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
10 changes: 9 additions & 1 deletion src/app/core/admin/admin-entity/admin-entity.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { FontAwesomeTestingModule } from "@fortawesome/angular-fontawesome/testi
import { EntityMapperService } from "../../entity/entity-mapper/entity-mapper.service";
import { EntityActionsService } from "../../entity/entity-actions/entity-actions.service";
import { EntitySchemaField } from "../../entity/schema/entity-schema-field";
import { ActivatedRoute } from "@angular/router";
import { of } from "rxjs";

describe("AdminEntityComponent", () => {
let component: AdminEntityComponent;
Expand Down Expand Up @@ -59,7 +61,9 @@ describe("AdminEntityComponent", () => {
[viewConfigId]: { component: "EntityDetails", config: viewConfig },
[entityConfigId]: {},
};

const mockActivatedRoute = {
queryParams: of({ mode: "list" }),
};
mockConfigService = jasmine.createSpyObj(["getConfig"]);
mockConfigService.getConfig.and.returnValue(config[viewConfigId]);

Expand Down Expand Up @@ -88,6 +92,10 @@ describe("AdminEntityComponent", () => {
provide: EntityActionsService,
useValue: jasmine.createSpyObj(["showSnackbarConfirmationWithUndo"]),
},
{
provide: ActivatedRoute,
useValue: mockActivatedRoute,
},
],
});
fixture = TestBed.createComponent(AdminEntityComponent);
Expand Down
10 changes: 9 additions & 1 deletion src/app/core/admin/admin-entity/admin-entity.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
MatSidenavContent,
} from "@angular/material/sidenav";
import { FaIconComponent } from "@fortawesome/angular-fontawesome";
import { RouterLink } from "@angular/router";
import { RouterLink, ActivatedRoute } from "@angular/router";
import { MatListItem, MatNavList } from "@angular/material/list";
import { AdminEntityDetailsComponent } from "../admin-entity-details/admin-entity-details/admin-entity-details.component";

Expand Down Expand Up @@ -72,10 +72,18 @@ export class AdminEntityComponent implements OnInit {
private location: Location,
private entityMapper: EntityMapperService,
private entityActionsService: EntityActionsService,
private routes: ActivatedRoute,
Abhinegi2 marked this conversation as resolved.
Show resolved Hide resolved
) {}

ngOnInit(): void {
this.init();
this.routes.queryParams.subscribe((params) => {
if (params.mode === "details") {
this.mode = "details";
} else if (params.mode === "list") {
this.mode = "list";
}
});
}

private init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<button
mat-menu-item
[routerLink]="['/admin/entity', record?.getType()]"
[queryParams]="{ mode: 'details' }"
queryParamsHandling="merge"
*ngIf="'update' | ablePure: 'Config' | async"
>
<fa-icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ <h2>{{ title }}</h2>
<button
mat-menu-item
[routerLink]="['/admin/entity', entityConstructor.ENTITY_TYPE]"
[queryParams]="{ mode: 'list' }"
queryParamsHandling="merge"
*ngIf="'update' | ablePure: 'Config' | async"
>
<fa-icon
Expand Down
Loading