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

5137.3 Requisition line edit + UI updates to line columns #5308

Merged
merged 37 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9237b1f
Add onBlur prop to reason options search input
roxy-dao Nov 3, 2024
4883c67
Add requisition number to requisition line node
roxy-dao Nov 3, 2024
497c8e3
Basic list options component
roxy-dao Nov 3, 2024
7ed5c46
Basic list items component
roxy-dao Nov 3, 2024
e4b4264
Pass in route to list item component
roxy-dao Nov 3, 2024
1f63ef5
Add route to requisition line
roxy-dao Nov 3, 2024
70d2bdc
App bar buttons of requisition detail view
roxy-dao Nov 3, 2024
ea39dbb
Export reason option component
roxy-dao Nov 4, 2024
56ecd01
Removed toggle
roxy-dao Nov 4, 2024
a884b6b
Show end icon based on current id
roxy-dao Nov 4, 2024
05bba09
Only input req_id, id and item_id for requisition line insert
roxy-dao Nov 4, 2024
1ec5867
Show start icon based on entered ids
roxy-dao Nov 4, 2024
8d84927
Use check icon for start icon and pass in entered line ids
roxy-dao Nov 4, 2024
42fe9b2
Insert response requisition line hook
roxy-dao Nov 4, 2024
1934f51
Nothing here add item linkage
roxy-dao Nov 4, 2024
266df44
Navigate away if row is clicked + add item modal
roxy-dao Nov 4, 2024
920175e
Response requisition line edit component
roxy-dao Nov 4, 2024
bc610df
Response line edit page
roxy-dao Nov 4, 2024
4d9f5b0
Add previous option to dialog option
roxy-dao Nov 4, 2024
593eaf5
Next and ok & next dialog buttons
roxy-dao Nov 4, 2024
d164bc6
Rename next -> next-and-ok for dialog button
roxy-dao Nov 4, 2024
c459e4d
Find both previous + next response lines
roxy-dao Nov 4, 2024
79be92a
Footer for response edit page
roxy-dao Nov 4, 2024
52a8dd3
Add footer to edit response line page
roxy-dao Nov 4, 2024
eba331a
Sort lines
roxy-dao Nov 4, 2024
a6ce13d
Don't pass in icons as props
roxy-dao Nov 4, 2024
9f2a975
Merge branch '5137.2-Requisition-line-edit-+-UI-updates-to-line-colum…
roxy-dao Nov 4, 2024
e1f4e0b
Sort translation
roxy-dao Nov 4, 2024
29029b6
Use correct field to get available
roxy-dao Nov 4, 2024
54ff080
Change footer button to next
roxy-dao Nov 4, 2024
8af9e35
Show available stock on hand if not program instead of initial stock …
roxy-dao Nov 5, 2024
ae32c65
Merge branch 'develop' into 5137.3
roxy-dao Nov 5, 2024
c0972f1
Fix merge issues
roxy-dao Nov 5, 2024
63c3405
Disable input if linked requisition
roxy-dao Nov 5, 2024
25d0378
Merge branch '5137.2-Requisition-line-edit-+-UI-updates-to-line-colum…
roxy-dao Nov 5, 2024
a5bebb2
Merge branch 'develop' into 5137.3
roxy-dao Nov 7, 2024
474db73
ternary operator to show/hide icons
roxy-dao Nov 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const UpdateStatusButtonComponent = ({
nextButton={
currentTab === Tabs.Status ? (
<DialogButton
variant="next"
variant="next-and-ok"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renaming of the next button so I can create an actual 'next' button not 'ok & next'

onClick={onNext}
disabled={isInvalid()}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const EquipmentImportModal: FC<EquipmentImportModalProps> = ({
<Modal
okButton={
<DialogButton
variant="next"
variant="next-and-ok"
disabled={importNotReady}
onClick={importAction}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Template: StoryFn = () => {
<Modal
title="Add Item"
cancelButton={<DialogButton variant="cancel" onClick={onCancel} />}
nextButton={<DialogButton variant="next" onClick={onOkNext} />}
nextButton={<DialogButton variant="next-and-ok" onClick={onOkNext} />}
okButton={<DialogButton variant="ok" onClick={onOk} />}
>
<div>This is an example dialog. There&apos;s nothing much to see</div>
Expand Down
6 changes: 4 additions & 2 deletions client/packages/common/src/intl/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
"button.new-return": "New Return",
"button.new-shipment": "New Shipment",
"button.new-stock": "New Stock",
"button.next": "Next",
"button.next-step": "Next step",
"button.ok": "OK",
"button.ok-and-next": "OK & Next",
"button.open-the-menu": "Open the menu",
"button.order-more": "Order more",
"button.previous": "Previous",
Copy link
Contributor

Choose a reason for hiding this comment

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

Other than this and Next the rest of this is just your editor alphabetically sorting aye?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct~

"button.print": "Print",
"button.print-qr": "Print QR code",
"button.reduce-lines-to-zero": "Reduce lines to 0",
Expand Down Expand Up @@ -142,6 +144,7 @@
"customers": "Customers",
"dashboard": "Dashboard",
"description.already-issued": "Quantity already issued in shipments.",
"description.available-stock": "The customer's initial stock on hand + incoming stock +/- inventory adjustments - outgoing stock",
"description.average-monthly-consumption": "Average Monthly Consumption",
"description.breach-type": "Ongoing breach type",
"description.counted-num-of-packs": "Counted # of Packs",
Expand All @@ -155,7 +158,6 @@
"description.fc-sell-price": "Foreign currency sell price per pack",
"description.forecast-quantity": "Forecast Quantity to Reach Target",
"description.initial-stock-on-hand": "Stock on hand on the first day of the program period",
"description.available-stock": "The customer's initial stock on hand + incoming stock +/- inventory adjustments - outgoing stock",
"description.invoice-number": "Shipment number",
"description.last-reading-datetime": "Date and time of the last reading",
"description.max-min-temperature": "Maximum or minimum temperature reading",
Expand Down Expand Up @@ -732,11 +734,11 @@
"label.invoice-number": "Number",
"label.is-vaccine": "Vaccine",
"label.issue": "Issue",
"label.item-variant": "Item Variant",
"label.item_few": "Items",
"label.item_many": "Items",
"label.item_one": "Item",
"label.item_other": "Items",
"label.item-variant": "Item Variant",
"label.items-expiring-before": "Items expiring before",
"label.items-no-stock_few": "Items with no stock",
"label.items-no-stock_many": "Items with no stock",
Expand Down
13 changes: 1 addition & 12 deletions client/packages/common/src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2934,21 +2934,9 @@ export type InsertResponseRequisitionLineErrorInterface = {
};

export type InsertResponseRequisitionLineInput = {
additionInUnits?: InputMaybe<Scalars['Float']['input']>;
averageMonthlyConsumption?: InputMaybe<Scalars['Float']['input']>;
comment?: InputMaybe<Scalars['String']['input']>;
daysOutOfStock?: InputMaybe<Scalars['Float']['input']>;
expiringUnits?: InputMaybe<Scalars['Float']['input']>;
Comment on lines -2972 to -2976
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't need all these fields on insert. We will do everything on update as everything is saved on blur except for the actual line creation itself

id: Scalars['String']['input'];
incomingUnits?: InputMaybe<Scalars['Float']['input']>;
itemId: Scalars['String']['input'];
lossInUnits?: InputMaybe<Scalars['Float']['input']>;
optionId?: InputMaybe<Scalars['String']['input']>;
outgoingUnits?: InputMaybe<Scalars['Float']['input']>;
requestedQuantity?: InputMaybe<Scalars['Float']['input']>;
requisitionId: Scalars['String']['input'];
stockOnHand?: InputMaybe<Scalars['Float']['input']>;
supplyQuantity?: InputMaybe<Scalars['Float']['input']>;
};

export type InsertResponseRequisitionLineResponse = InsertResponseRequisitionLineError | RequisitionLineNode;
Expand Down Expand Up @@ -6469,6 +6457,7 @@ export type RequisitionLineNode = {
remainingQuantityToSupply: Scalars['Float']['output'];
/** Quantity requested */
requestedQuantity: Scalars['Float']['output'];
requisitionNumber: Scalars['Int']['output'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed for navigation

/**
* Calculated quantity
* When months_of_stock < requisition.min_months_of_stock, calculated = average_monthly_consumption * requisition.max_months_of_stock - months_of_stock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ const Template: StoryFn<{ color: 'primary' | 'secondary' }> = ({ color }) => {
</Wrapper>

<Wrapper text="Dialog OK & Next button">
<DialogButton variant="next" onClick={getOnClick('OK & Next!')} />
<DialogButton
variant="next-and-ok"
onClick={getOnClick('OK & Next!')}
roxy-dao marked this conversation as resolved.
Show resolved Hide resolved
/>
</Wrapper>

<Wrapper text="Dialog cancel button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { ButtonWithIcon } from './ButtonWithIcon';
type DialogButtonVariant =
| 'cancel'
| 'back'
| 'previous'
| 'next-and-ok'
| 'next'
| 'ok'
| 'save'
Expand Down Expand Up @@ -63,12 +65,18 @@ const getButtonProps = (
labelKey: 'button.ok',
variant: 'contained',
};
case 'next':
case 'next-and-ok':
return {
icon: <ArrowRightIcon />,
labelKey: 'button.ok-and-next',
variant: 'contained',
};
case 'next':
return {
icon: <ArrowRightIcon />,
labelKey: 'button.next',
variant: 'contained',
};
case 'save':
return {
icon: <SaveIcon />,
Expand Down Expand Up @@ -99,6 +107,12 @@ const getButtonProps = (
labelKey: 'button.close',
variant: 'outlined',
};
case 'previous':
return {
icon: <ArrowLeftIcon />,
labelKey: 'button.previous',
variant: 'outlined',
};
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { CheckIcon, ChevronDownIcon } from '@common/icons';
import {
List,
ListItemIcon,
ListItem,
ListItemText,
Divider,
Box,
} from '@mui/material';
import React from 'react';

export type ListOptionValues = {
id: string;
value: string;
};

interface ListProps {
onClick: (id: string) => void;
options: ListOptionValues[];
currentId?: string;
enteredLineIds?: string[];
}

export const ListOptions = ({
onClick,
options,
currentId,
enteredLineIds,
}: ListProps) => {
const startIcon = (
<CheckIcon
style={{
backgroundColor: '#33A901',
borderRadius: '50%',
padding: '2px',
color: 'white',
height: 18,
width: 18,
}}
/>
);

const endIcon = (
<ChevronDownIcon
style={{ width: 17, height: 17, transform: 'rotate(-90deg)' }}
/>
);
Comment on lines +30 to +47
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had them passed in as props at first since we might use different icons for different use cases, but can't think of them right now for what we will use it for. Easy to refactor later on if needed


return (
<List sx={{ padding: 0 }}>
{options?.map((option, _) => (
<React.Fragment key={option.id}>
<ListItem
sx={{ padding: '5px 0px' }}
onClick={() => onClick(option.id)}
>
<ListItemIcon sx={{ padding: 0, minWidth: 25 }}>
{enteredLineIds?.includes(option.id) ? (
startIcon
) : (
<Box style={{ visibility: 'hidden' }}>{startIcon}</Box>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is quite funky - behind the scenes it appears to still be rendering the icon it's just invisible. But if you remove the icon JSX from here it renders the same anyway, just shadow dom doing less work?

</ListItemIcon>
<ListItemText
primary={option.value}
sx={{ margin: 0, padding: 0 }}
/>
<ListItemIcon sx={{ padding: 0, minWidth: 15 }}>
{option.id === currentId ? (
endIcon
) : (
<Box style={{ visibility: 'hidden' }}>{endIcon}</Box>
)}
</ListItemIcon>
</ListItem>
<Divider component="li" />
</React.Fragment>
))}
</List>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ListOptions';
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './AppNavSection';
export * from './Breadcrumbs';
export * from './ExternalNavLink';
export * from './Tabs';
export * from './ListOptions';
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const StocktakeLineEditModal: FC<
cancelButton={<DialogButton variant="cancel" onClick={onCancel} />}
nextButton={
<DialogButton
variant="next"
variant="next-and-ok"
onClick={onNext}
disabled={(!hasNext && mode === ModalMode.Update) || !isValid}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const InboundLineEdit: FC<InboundLineEditProps> = ({
cancelButton={<DialogButton variant="cancel" onClick={onClose} />}
nextButton={
<DialogButton
variant="next"
variant="next-and-ok"
disabled={okNextDisabled || zeroNumberOfPacks}
onClick={async () => {
await saveLines();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const OutboundLineEdit: React.FC<ItemDetailsModalProps> = ({
nextButton={
<DialogButton
disabled={okNextDisabled}
variant="next"
variant="next-and-ok"
onClick={onNext}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const PrescriptionLineEdit: React.FC<PrescriptionLineEditModalProps> = ({
nextButton={
<DialogButton
disabled={okNextDisabled}
variant="next"
variant="next-and-ok"
onClick={onNext}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const CustomerReturnEditModal = ({
const NextStepButton = (
<DialogButton
onClick={handleNextStep}
variant="next"
variant="next-and-ok"
disabled={!lines.length}
customLabel={t('button.next-step')}
/>
Expand All @@ -129,7 +129,7 @@ export const CustomerReturnEditModal = ({
const OkAndNextButton = (
<DialogButton
onClick={handleNextItem}
variant="next"
variant="next-and-ok"
disabled={
currentTab !== Tabs.Reason ||
(isDisabled && !hasNextItem) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const SupplierReturnEditModal = ({
const NextStepButton = (
<DialogButton
onClick={handleNextStep}
variant="next"
variant="next-and-ok"
disabled={!lines.length}
customLabel={t('button.next-step')}
/>
Expand All @@ -127,7 +127,7 @@ export const SupplierReturnEditModal = ({
const OkAndNextButton = (
<DialogButton
onClick={handleNextItem}
variant="next"
variant="next-and-ok"
roxy-dao marked this conversation as resolved.
Show resolved Hide resolved
disabled={
currentTab !== Tabs.Reason ||
(isDisabled && !hasNextItem) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const RequestLineEdit = ({
nextButton={
<DialogButton
disabled={nextDisabled}
variant="next"
variant="next-and-ok"
onClick={async () => {
await save();
setPreviousItemLineId(null);
Expand Down
12 changes: 12 additions & 0 deletions client/packages/requisitions/src/RequisitionService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {
ListView as ResponseRequisitionListView,
DetailView as ResponseRequisitionDetailView,
ResponseLineEditPage,
} from './ResponseRequisition';
import { RouteBuilder, Routes, Route } from '@openmsupply-client/common';
import { AppRoute } from '@openmsupply-client/config';
Expand All @@ -21,6 +22,13 @@ const customerRequisitionRoute = RouteBuilder.create(
.addPart(':requisitionNumber')
.build();

const customerRequisitionLineRoute = RouteBuilder.create(
AppRoute.CustomerRequisition
)
.addPart(':requisitionNumber')
.addPart(':itemId')
.build();

const internalOrdersRoute = RouteBuilder.create(AppRoute.InternalOrder).build();
const internalOrderRoute = RouteBuilder.create(AppRoute.InternalOrder)
.addPart(':requisitionNumber')
Expand All @@ -43,6 +51,10 @@ export const RequisitionService: FC = () => {
path={customerRequisitionRoute}
element={<ResponseRequisitionDetailView />}
/>
<Route
path={customerRequisitionLineRoute}
element={<ResponseLineEditPage />}
/>
<Route
path={internalOrdersRoute}
element={<RequestRequisitionListView />}
Expand Down
Loading
Loading