bcgov / cas-registration

A web app for Registration in OBPS under the Clean Growth branch
Apache License 2.0
1 stars 1 forks source link

Admin\Facilities - External User can edit a facility #1608

Closed zoeyli-46 closed 1 month ago

zoeyli-46 commented 6 months ago

Description:

As an External User, I can edit my facility details Figma link

Acceptance Criteria:

Given I am an authenticated user with the industry-user or industry-user-admin role, When I am on the facilities page Then I can click view details, for each row of facilities

Given that I am in the facilities details page, When I click edit Then the fields turn editable

Given that I am in edit mode When I click submit Then I get a confirmation that the edits have been made successfully

Development Checklist:

Refactor shared route component:

Refactor ActionCellFactory. to handle dynamic href property

const ActionCellFactory = ({ getHref, replace, className, cellText, }: { getHref: (params: GridRenderCellParams) => string; replace: boolean; className: string; cellText: string; }) => { return (params: GridRenderCellParams) => { const href = getHref(params); return (

{cellText}
);

}; };

export default ActionCellFactory;

- [x] In `bciers/apps/administration/app/components/facilities/FacilityDataGrid.tsx`  change to

"use client";

import { useMemo, useState } from "react"; import DataGrid from "@bciers/components/datagrid/DataGrid"; import facilityColumns from "../datagrid/models/facilities/facilityColumns"; import facilityGroupColumns from "../datagrid/models/facilities/facilityGroupColumns"; import { FacilityRow } from "./types"; import createFetchFacilitiesPageData from "./createFetchFacilitiesPageData"; import HeaderSearchCell from "@bciers/components/datagrid/cells/HeaderSearchCell"; import ActionCellFactory from "@bciers/components/datagrid/cells/ActionCellFactory";

const FacilityDataGrid = ({ operationId, initialData, }: { operationId: string; initialData: { rows: FacilityRow[]; row_count: number; }; }) => { const createFacilitiesActionCell = () => ActionCellFactory({ getHref: (params) => /operations/${operationId}/facilities/${params.row.id}?title=${params.row.name}, replace: true, className: "no-underline text-bc-link-blue whitespace-normal", cellText: "View Details", });

const ActionCell = useMemo(() => createFacilitiesActionCell(), []); const [lastFocusedField, setLastFocusedField] = useState<string | null>(null);

const SearchCell = useMemo( () => HeaderSearchCell({ lastFocusedField, setLastFocusedField }), [lastFocusedField, setLastFocusedField], );

const columns = useMemo(() => facilityColumns(ActionCell), [ActionCell]);

const columnGroup = useMemo( () => facilityGroupColumns(SearchCell), [SearchCell], );

return ( <DataGrid columns={columns} columnGroupModel={columnGroup} fetchPageData={createFetchFacilitiesPageData(operationId)} paginationMode="server" initialData={initialData} /> ); };

export default FacilityDataGrid;


- [x] In bciers/apps/administration/app/components/facilities/FacilitiesForm.tsx` remove isCreating as param to SingleStepTaskListForm`
- [x] Create API service in `bc_obps/service/facility_service.py`
- [x] Create API data access service in `bc_obps/service/data_access_service/facility_service.py`
- [x] Create API endpoint in `bc_obps/registration/api/v1/_facilities/facility_id.py`
- [x] Create API test of service in `bc_obps/service/tests/test_facility_service.py`
- [x] Create API test of endpoint in `bc_obps/registration/tests/endpoints/v1/_facilities/test_facility_id.py`
- [x] Run python tests `cd bc_obps && make pythontests`
- [x] Run vitests `cd bciers &&yarn admin:test`

**Definition of Ready** (Note: If any of these points are not applicable, mark N/A)

- [ ] User story is included
- [ ] User role and type are identified
- [ ] Acceptance criteria are included
- [ ] Wireframes are included (if required)
- [ ] Design / Solution is accepted by Product Owner
- [ ] Dependencies are identified (technical, business, regulatory/policy)
- [ ] Story has been estimated (under 13 pts)

·**Definition of Done** (Note: If any of these points are not applicable, mark N/A)

- [ ] Acceptance criteria are tested by the CI pipeline
- [ ] UI meets accessibility requirements
- [ ] Configuration changes are documented, documentation and designs are updated
- [ ] Passes code peer-review
- [ ] Passes QA of Acceptance Criteria with verification in Dev and Test
- [ ] Ticket is ready to be merged to main branch
- [ ] Can be demoed in Sprint Review
- [ ] Bugs or future work cards are identified and created
- [ ] Reviewed and approved by Product Owner

#### Notes:

#### Dependencies
Blocked by #1361 
shon-button commented 1 month ago

@patriciarussellCAS

Reachable at: https://cas-bciers-frontend-dev.apps.silver.devops.gov.bc.ca/administration/operations/002d5a9e-32a6-4191-938c-2c02bfec592d/facilities/f486f2fb-62ed-438d-bb3e-0819b51e3aeb?operations_title=Operation%202&facilities_title=Facility%201

patriciarussellCAS commented 1 month ago

Review notes: