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

5162 response requisition indicator UI #5523

Merged
merged 49 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
894ebc7
indicators gql generate
Chris-Petty Nov 17, 2024
d34945c
queries
Chris-Petty Nov 18, 2024
077e646
stuff
Chris-Petty Nov 20, 2024
48159aa
Fix infinite fetching
roxy-dao Nov 20, 2024
e06fb0f
Fix route for indicator page
roxy-dao Nov 20, 2024
48c3c31
Use fragments
roxy-dao Nov 20, 2024
1eaa4b6
Move page layout to common
roxy-dao Nov 20, 2024
26cf0de
Fix route + pass in indicators to tab
roxy-dao Nov 20, 2024
9b4a6ad
List Indicators
roxy-dao Nov 20, 2024
40868c6
Update tab buttons
roxy-dao Nov 20, 2024
65869c8
Detail view with list of indicators
roxy-dao Nov 20, 2024
dd587b6
App bar buttons for Indicator page
roxy-dao Nov 20, 2024
1931780
Custom breadcrumb + remove entered line ids
roxy-dao Nov 20, 2024
8858995
Fix imports
roxy-dao Nov 20, 2024
25c76e6
Fragments for column and value
roxy-dao Nov 20, 2024
cf56818
Merge branch 'v2.4.0' into 5162-response-requisition-indicator-ui
roxy-dao Nov 20, 2024
d0bf66a
Separate onclick redirection for indicator buttons
roxy-dao Nov 20, 2024
babb20c
Hook to update indicator value
roxy-dao Nov 21, 2024
e0fa5d2
Hook to get previous and next indicator line row
roxy-dao Nov 21, 2024
93a14ef
Implement footer for indicator line page with previous and next buttons
roxy-dao Nov 21, 2024
62f8486
Change return
roxy-dao Nov 21, 2024
4bd972b
Sort indicator lines to dsplay
roxy-dao Nov 21, 2024
3ee7376
value input wipi
Chris-Petty Nov 21, 2024
66eda41
Make list sizing smaller
roxy-dao Nov 21, 2024
84be792
Small fixes
roxy-dao Nov 21, 2024
1e9f628
Updating indicator values and value type error handling
Chris-Petty Nov 22, 2024
e75041c
remove unused draft hook
Chris-Petty Nov 24, 2024
fb32148
Merge branch 'v2.4.0' into 5162-response-requisition-indicator-ui
Chris-Petty Nov 25, 2024
288b2e7
translate indicators breadcrumbs
Chris-Petty Nov 25, 2024
a8a5525
Revert "remove unused draft hook"
Chris-Petty Nov 25, 2024
c5e1a68
index.js
Chris-Petty Nov 25, 2024
0ae3de4
translate
Chris-Petty Nov 25, 2024
b2bb406
add AppRoute.Indicators
Chris-Petty Nov 25, 2024
84f493f
translate
Chris-Petty Nov 25, 2024
387ce3c
hide/show indicator buttons as required
Chris-Petty Nov 25, 2024
64cf13d
remove broken tooltip
Chris-Petty Nov 26, 2024
3e116e7
fix routing regression
Chris-Petty Nov 26, 2024
02e36c1
indicators use draft state
Chris-Petty Nov 26, 2024
205b170
remove fe logging
Chris-Petty Nov 26, 2024
1d47a7d
filter requisitions program indicators correctly
Chris-Petty Nov 26, 2024
32ba994
hide indicator buttons fixed
Chris-Petty Nov 26, 2024
561e33a
Merge branch 'v2.4.0' into 5162-response-requisition-indicator-ui
Chris-Petty Nov 26, 2024
6f3a96e
maybe less loading jank?
Chris-Petty Nov 26, 2024
12e83ca
make sure first indicator line is selected
Chris-Petty Nov 27, 2024
01a6800
Hide unnecessary columns and rows
Chris-Petty Nov 27, 2024
9e50d76
Merge branch 'v2.4.0' into 5162-response-requisition-indicator-ui
Chris-Petty Nov 27, 2024
c7cbeb9
hide regimen indicators button if no values
lache-melvin Nov 27, 2024
95e4f8f
hide hiv indicators button if no values
lache-melvin Nov 27, 2024
f6ee45f
Merge branch 'v2.4.0' into 5162-response-requisition-indicator-ui
Chris-Petty Nov 27, 2024
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
23 changes: 14 additions & 9 deletions client/packages/common/src/intl/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"button.close": "Close",
"button.close-the-menu": "Close the menu",
"button.create": "Create",
"button.create-new": "Create new",
"button.create-a-new-one": "Create a new one",
"button.create-log-reason": "Create log reason",
"button.create-new": "Create new",
"button.create-shipment": "Create Shipment",
"button.dashboard": "Dashboard",
"button.delete": "Delete",
Expand All @@ -49,6 +49,7 @@
"button.edit": "Edit",
"button.edit-linked-patient": "Edit Linked Patient",
"button.export": "Export",
"button.hiv": "HIV",
"button.import": "Import",
"button.import-fridge-tag": "Import Fridge-tag",
"button.import-properties": "Import Properties",
Expand Down Expand Up @@ -79,6 +80,7 @@
"button.print-qr": "Print QR code",
"button.reduce-lines-to-zero": "Reduce lines to 0",
"button.refresh": "Refresh",
"button.regimen": "Regimen",
"button.remove-file": "Remove file",
"button.repack": "Repack",
"button.replenishment-return-lines": "Return selected lines",
Expand All @@ -102,8 +104,8 @@
"button.view": "View",
"button.view-all-breaches": "View all breaches",
"button.view-details": "View Details",
"button.view-prescription": "View prescription",
"button.view-patient": "View patient",
"button.view-prescription": "View prescription",
"button.zero-line-quantity": "Set quantities to 0",
"catalogue": "Catalogue",
"cmdk.drawer-toggle": "Toggle Menu",
Expand Down Expand Up @@ -278,6 +280,7 @@
"error.no-immunisation-programs": "No Immunization programs found",
"error.no-inbound-items": "No items have been added to this shipment.",
"error.no-inbound-shipments": "There are no Inbound Shipments to display.",
"error.no-indicators": "There are no indicators for this requisition",
"error.no-internal-orders": "No internal orders to display.",
"error.no-items": "No items",
"error.no-items-filter-on": "No items to display. Try changing the filter criteria.",
Expand Down Expand Up @@ -379,6 +382,7 @@
"error.v6-server-not-configured": "V6 central server not configured",
"error.v6-server-not-configured-hint": "Check the central server URL",
"error.vaccine-course-update-failed": "Vaccine course failed to save",
"error.value-type-not-correct": "Value type not correct",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User probably won't understand what this means... since we're only checking if Number is the correct type, maybe we can change the error message to be friendlier

"facilities": "Facilities",
"filename.asset-categories": "asset-categories",
"filename.asset-import-example": "Example Asset Item Import",
Expand Down Expand Up @@ -419,9 +423,9 @@
"heading.configuration": "Configuration",
"heading.confirm-finalise": "Are you sure you want to finalise?",
"heading.consumption-history": "Consumption History (monthly)",
"heading.create-new-asset": "Create new asset",
"heading.create-outbound-shipment": "Create Outbound Shipment",
"heading.create-vaccine-course": "Create vaccine course",
"heading.create-new-asset": "Create new asset",
"heading.custom": "Custom",
"heading.custom-logo": "Custom logo",
"heading.custom-logo-info": "Replaces the default \"mSupply man\". The logo has to be in svg format, e.g. <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>...<svg...>",
Expand Down Expand Up @@ -737,6 +741,7 @@
"label.incoming": "Incoming",
"label.incoming-stock": "Stock arriving",
"label.increase-qty": "Increase quantity",
"label.indicators": "Indicators",
"label.initial-stock-on-hand": "Initial SOH",
"label.initialise-store-properties": "Initialise store properties for GAPS",
"label.initialised": "Initialised",
Expand Down Expand Up @@ -882,10 +887,10 @@
"label.phone": "Phone",
"label.picked": "Picked",
"label.placeholder": "Placeholder",
"label.prescription-date": "Prescription Date",
"label.previous-encounters": "Previous Encounters",
"label.pricing": "Pricing",
"label.primary": "Primary",
"label.prescription-date": "Prescription Date",
"label.program": "Program",
"label.program-enrolment": "Program Enrolment",
"label.program-enrolments": "Program Enrolments",
Expand Down Expand Up @@ -1151,7 +1156,10 @@
"messages.bundled-item-saved": "Bundled item saved successfully",
"messages.by-user": "by {{username}}",
"messages.cannot-bundle": "You can't bundle other item variants with this one, as this variant is already bundled with other items",
"messages.cannot-delete-finalised-requisition": "Cannot delete finalised requisition",
"messages.cannot-delete-multiple-lines": "One or more lines cannot be deleted",
"messages.cannot-delete-requisition-with-shipment": "Cannot delete requisition linked to a shipment",
"messages.cannot-delete-transfer-requisition": "Cannot delete transfer requisition",
"messages.cannot-view-vaccine-card": "You cannot view this patient's Vaccination Card from this store, because they were enrolled in the {{ programName }} by another store",
"messages.cant-delete-generic": "You cannot delete one or more of the selected items",
"messages.cant-delete-requisitions": "Can only delete requisitions with a status of 'Draft'",
Expand Down Expand Up @@ -1269,11 +1277,11 @@
"messages.confirm-zero-shipment-lines_other": "This will set the quantity of {{count}} lines to 0",
"messages.connected-to-printer": "Connected successfully to printer!",
"messages.could-not-save": "Could not Save",
"messages.create-new-asset-confirmation": "The asset you scanned is not currently in the system, but has provided appropriate GS1 data. Would you like to create a new asset with this data?",
"messages.create-outbound-from-requisition": "Are you sure you want to create an Outbound Shipment from this Customer Requisition?",
"messages.create-stocktake-1": "You can create a stocktake based on items currently assigned to a location, items that you currently have in stock, items assigned to a master list, or items expiring before a particular date.",
"messages.create-stocktake-2": "To create an empty stocktake, simply click OK to continue.",
"messages.created-new-vaccine-course": "Successfully created vaccine course",
"messages.create-new-asset-confirmation": "The asset you scanned is not currently in the system, but has provided appropriate GS1 data. Would you like to create a new asset with this data?",
"messages.customer-requisition-created-on": "Customer requisition created on {{date}}",
"messages.delete-this-line": "Delete this line",
"messages.deleted-assets_one": "Deleted {{count}} asset",
Expand Down Expand Up @@ -1429,6 +1437,7 @@
"messages.prescription-saved": "Prescription saved πŸ₯³",
"messages.properties-download-example": "Download a template CSV",
"messages.properties-template-download-text": " with the facilities' current properties ",
"messages.record-not-found": "Record not found",
"messages.recorded-on": "Recorded on {{datetime}}",
"messages.reduced-to-zero_one": "Reduced 1 line to quantity of 0",
"messages.reduced-to-zero_other": "Reduced {{ count }} lines to quantity of 0",
Expand Down Expand Up @@ -1478,10 +1487,6 @@
"messages.zero-line-quantities_one": "The quantity of 1 line has been set to 0",
"messages.zero-line-quantities_other": "The quantity of {{count}} lines has been set to 0",
"messages.zero-return-quantity-will-delete-lines": "There are no return quantities specified. Click OK again to confirm and remove these lines from the return.",
"messages.cannot-delete-finalised-requisition": "Cannot delete finalised requisition",
"messages.record-not-found": "Record not found",
"messages.cannot-delete-requisition-with-shipment": "Cannot delete requisition linked to a shipment",
"messages.cannot-delete-transfer-requisition": "Cannot delete transfer requisition",
"monitoring": "Monitoring",
"multiple": "[multiple]",
"outbound-shipment": "Outbound Shipments",
Expand Down
8 changes: 8 additions & 0 deletions client/packages/common/src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,7 @@ export type IndicatorLineNode = {
export type IndicatorLineRowNode = {
__typename: 'IndicatorLineRowNode';
code: Scalars['String']['output'];
id: Scalars['String']['output'];
lineNumber: Scalars['Int']['output'];
name: Scalars['String']['output'];
valueType?: Maybe<IndicatorValueTypeNode>;
Expand Down Expand Up @@ -6717,6 +6718,8 @@ export type RequisitionNode = {
otherPartyId: Scalars['String']['output'];
otherPartyName: Scalars['String']['output'];
period?: Maybe<PeriodNode>;
program?: Maybe<ProgramNode>;
/** @deprecated use `program.name` instead. */
programName?: Maybe<Scalars['String']['output']>;
requisitionNumber: Scalars['Int']['output'];
/** Applicable to request requisition only */
Expand Down Expand Up @@ -8929,6 +8932,11 @@ export type VaccineCourseSortInput = {

export type VaccineCoursesResponse = VaccineCourseConnector;

export type ValueTypeNotCorrect = UpdateIndicatorValueErrorInterface & {
__typename: 'ValueTypeNotCorrect';
description: Scalars['String']['output'];
};

export enum VenCategoryType {
E = 'E',
N = 'N',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ListOptions = ({
);

return (
<List sx={{ padding: 0, maxHeight: height * 0.8, overflow: 'auto' }}>
<List sx={{ padding: 0, maxHeight: height * 0.7, overflow: 'auto' }}>
{options?.map((option, _) => (
<React.Fragment key={option.id}>
<ListItem
Expand Down
1 change: 1 addition & 0 deletions client/packages/config/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum AppRoute {
Locations = 'locations',
MasterLists = 'master-lists',
IndicatorsDemographics = 'indicators-demographics',
Indicators = 'indicators',

Manage = 'manage',
Programs = 'programs',
Expand Down
4 changes: 2 additions & 2 deletions client/packages/reports/src/ListView/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
import { AppBarButtons } from './AppBarButton';
import { SidePanel } from './SidePanel';
import { ReportWidget } from '../components';
import { JsonData } from 'packages/programs/src';
import { AppRoute } from 'packages/config/src';
import { JsonData } from '@openmsupply-client/programs';
import { AppRoute } from '@openmsupply-client/config';

export const ListView = () => {
const t = useTranslation();
Expand Down
9 changes: 9 additions & 0 deletions client/packages/requisitions/src/RequisitionService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ListView as ResponseRequisitionListView,
DetailView as ResponseRequisitionDetailView,
ResponseLineEditPage,
IndicatorEditPage,
} from './ResponseRequisition';
import { RouteBuilder, Routes, Route } from '@openmsupply-client/common';
import { AppRoute } from '@openmsupply-client/config';
Expand All @@ -29,6 +30,13 @@ const customerRequisitionLineRoute = RouteBuilder.create(
.addPart(':itemId')
.build();

const indicatorLineRoute = RouteBuilder.create(AppRoute.CustomerRequisition)
.addPart(':requisitionNumber')
.addPart(AppRoute.Indicators)
.addPart(':programIndicatorCode')
.addPart(':programIndicatorLineId')
.build();

const internalOrdersRoute = RouteBuilder.create(AppRoute.InternalOrder).build();
const internalOrderRoute = RouteBuilder.create(AppRoute.InternalOrder)
.addPart(':requisitionNumber')
Expand All @@ -55,6 +63,7 @@ export const RequisitionService: FC = () => {
path={customerRequisitionLineRoute}
element={<ResponseLineEditPage />}
/>
<Route path={indicatorLineRoute} element={<IndicatorEditPage />} />
<Route
path={internalOrdersRoute}
element={<RequestRequisitionListView />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
BasicModal,
Box,
FnUtils,
IndicatorLineRowNode,
} from '@openmsupply-client/common';
import { AppRoute } from '@openmsupply-client/config';
import {
Expand All @@ -25,7 +26,13 @@ import { Footer } from './Footer';
import { AppBarButtons } from './AppBarButtons';
import { SidePanel } from './SidePanel';
import { ContentArea } from './ContentArea';
import { useResponse, ResponseLineFragment } from '../api';
import {
useResponse,
ResponseLineFragment,
ResponseFragment,
ProgramIndicatorFragment,
} from '../api';
import { IndicatorsTab } from './IndicatorsTab';
import { ResponseRequisitionLineErrorProvider } from '../context';

export const DetailView: FC = () => {
Expand All @@ -35,6 +42,13 @@ export const DetailView: FC = () => {
const isDisabled = useResponse.utils.isDisabled();
const { onOpen, isOpen, onClose } = useEditModal<ItemRowFragment>();
const { mutateAsync } = useResponse.line.insert();
const { data: programIndicators, isLoading: isProgramIndicatorsLoading } =
useResponse.document.indicators(
data?.otherPartyId ?? '',
data?.period?.id ?? '',
data?.program?.id ?? '',
!!data
);

const onRowClick = useCallback((line: ResponseLineFragment) => {
navigate(
Expand All @@ -46,6 +60,27 @@ export const DetailView: FC = () => {
);
}, []);

const onProgramIndicatorClick = useCallback(
(
programIndicator?: ProgramIndicatorFragment,
indicatorLine?: IndicatorLineRowNode,
response?: ResponseFragment
) => {
// TODO: Snack?
if (!response || !indicatorLine) return;
Comment on lines +69 to +70
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanna add a snack to let the users know why they can't click the button if they happen to click is and there's nothing there? or remove this and disable the buttons down below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe please 😁

navigate(
RouteBuilder.create(AppRoute.Distribution)
.addPart(AppRoute.CustomerRequisition)
.addPart(String(response.requisitionNumber))
.addPart(AppRoute.Indicators)
.addPart(String(programIndicator?.code))
.addPart(String(indicatorLine.id))
.build()
);
},
[]
);

if (isLoading) return <DetailViewSkeleton />;

const tabs = [
Expand All @@ -67,6 +102,20 @@ export const DetailView: FC = () => {
},
];

if (data?.programName && !!data?.otherParty.store) {
tabs.push({
Component: (
<IndicatorsTab
onClick={onProgramIndicatorClick}
isLoading={isLoading || isProgramIndicatorsLoading}
response={data}
indicators={programIndicators?.nodes}
/>
),
value: t('label.indicators'),
});
}

return !!data ? (
<ResponseRequisitionLineErrorProvider>
<TableProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React, { FC } from 'react';
import {
Box,
AppFooterPortal,
DialogButton,
RouteBuilder,
useNavigate,
useParams,
} from '@openmsupply-client/common';
import { AppRoute } from '@openmsupply-client/config';
import { IndicatorLineRowFragment } from '../../api';

interface FooterProps {
hasNext: boolean;
next: IndicatorLineRowFragment | null;
hasPrevious: boolean;
previous: IndicatorLineRowFragment | null;
requisitionNumber?: number;
}

export const Footer: FC<FooterProps> = ({
hasNext,
next,
hasPrevious,
previous,
requisitionNumber,
}) => {
const navigate = useNavigate();
const { programIndicatorCode } = useParams();

return (
<AppFooterPortal
Content={
<Box
gap={2}
display="flex"
flexDirection="row"
alignItems="center"
height={64}
>
<Box
flex={1}
display="flex"
justifyContent="flex-end"
gap={2}
marginLeft="auto"
>
<DialogButton
variant="previous"
disabled={!hasPrevious}
onClick={() =>
navigate(
RouteBuilder.create(AppRoute.Distribution)
.addPart(AppRoute.CustomerRequisition)
.addPart(String(requisitionNumber))
.addPart(AppRoute.Indicators)
.addPart(String(programIndicatorCode))
.addPart(String(previous?.id))
.build()
)
}
/>
<DialogButton
variant="next"
disabled={!hasNext}
onClick={() =>
navigate(
RouteBuilder.create(AppRoute.Distribution)
.addPart(AppRoute.CustomerRequisition)
.addPart(String(requisitionNumber))
.addPart(AppRoute.Indicators)
.addPart(String(programIndicatorCode))
.addPart(String(next?.id))
.build()
)
}
/>
</Box>
</Box>
}
/>
);
};
Loading
Loading