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

UIF-526 Implement action for download allocation worksheet #842

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 7.1.0 (IN PROGRESS)

* Replace deprecated transaction API. Refs UIF-519.
* Implement action for download allocation worksheet. Refs UIF-526.

## 7.0.1 (IN PROGRESS)

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/finance",
"version": "7.0.0",
"version": "8.0.0",
"description": "Description for ui-finance",
"main": "src/index.js",
"repository": "",
Expand All @@ -22,6 +22,7 @@
"configuration": "2.0",
"finance.budgets": "1.3 2.0",
"finance.expense-classes": "2.0 3.0",
"finance.finance-data": "1.0",
"finance.fiscal-years": "1.0 2.0",
"finance.fund-types": "1.0 2.0",
"finance.funds": "3.0",
Expand Down Expand Up @@ -162,6 +163,7 @@
"module.finance.enabled",
"acquisitions-units.units.collection.get",
"finance.budgets.collection.get",
"finance.finance-data.collection.get",
"finance.funds.collection.get",
"finance.group-fiscal-year-summaries.collection.get",
"finance.group-fund-fiscal-years.collection.get",
Expand Down Expand Up @@ -227,6 +229,7 @@
"module.finance.enabled",
"acquisitions-units.units.collection.get",
"finance.budgets.collection.get",
"finance.finance-data.collection.get",
"finance.fiscal-years.collection.get",
"finance.funds.collection.get",
"finance.group-fiscal-year-summaries.collection.get",
Expand Down
58 changes: 43 additions & 15 deletions src/Groups/GroupDetails/GroupDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import {
DetailsRemoveAction,
} from '../../common/DetailsActions';
import FinancialSummary from '../../common/FinancialSummary';
import {
AllocationToolsMenuSection,
DownloadAllocationWorksheetModal,
} from '../../common/components';
import { GROUPS_ROUTE } from '../../common/const';
import {
GROUP_ACCORDION,
Expand All @@ -58,6 +62,7 @@ const GroupDetails = ({
onRemoveFundFromGroup,
}) => {
const [isRemoveConfirmation, toggleRemoveConfirmation] = useModalToggle();
const [isDownloadAllocationWorksheetModalOpen, toggleDownloadAllocationWorksheetModal] = useModalToggle();
const accordionStatusRef = useRef();
const history = useHistory();
const stripes = useStripes();
Expand All @@ -72,25 +77,38 @@ const GroupDetails = ({
const renderActionMenu = useCallback(
({ onToggle }) => {
return (
<MenuSection id="group-details-actions">
<DetailsEditAction
perm="finance.groups.item.put"
onEdit={editGroup}
toggleActionMenu={onToggle}
disabled={isRestrictionsLoading || restrictions.protectUpdate}
/>
<DetailsRemoveAction
perm="finance.groups.item.delete"
toggleActionMenu={onToggle}
onRemove={toggleRemoveConfirmation}
disabled={isRestrictionsLoading || restrictions.protectDelete}
<>
<MenuSection id="group-details-actions">
<DetailsEditAction
perm="finance.groups.item.put"
onEdit={editGroup}
toggleActionMenu={onToggle}
disabled={isRestrictionsLoading || restrictions.protectUpdate}
/>
<DetailsRemoveAction
perm="finance.groups.item.delete"
toggleActionMenu={onToggle}
onRemove={toggleRemoveConfirmation}
disabled={isRestrictionsLoading || restrictions.protectDelete}
/>
</MenuSection>

<AllocationToolsMenuSection
onDownloadAllocationWorksheet={() => {
onToggle();
toggleDownloadAllocationWorksheetModal();
}}
/>
</MenuSection>
</>
);
},
[
editGroup, toggleRemoveConfirmation, isRestrictionsLoading,
restrictions.protectDelete, restrictions.protectUpdate,
editGroup,
isRestrictionsLoading,
restrictions.protectUpdate,
restrictions.protectDelete,
toggleRemoveConfirmation,
toggleDownloadAllocationWorksheetModal,
],
);

Expand Down Expand Up @@ -227,6 +245,16 @@ const GroupDetails = ({
open
/>
)}

{
isDownloadAllocationWorksheetModalOpen && (
<DownloadAllocationWorksheetModal
open
groupId={group.id}
toggle={toggleDownloadAllocationWorksheetModal}
/>
)
}
</Pane>
</HasCommand>
);
Expand Down
116 changes: 70 additions & 46 deletions src/Ledger/LedgerDetails/LedgerDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ import {
DetailsRemoveAction,
} from '../../common/DetailsActions';
import FinancialSummary from '../../common/FinancialSummary';
import {
AllocationToolsMenuSection,
DownloadAllocationWorksheetModal,
} from '../../common/components';
import { LEDGERS_ROUTE } from '../../common/const';
import {
LEDGER_ACCORDION,
Expand All @@ -63,6 +67,7 @@ const LedgerDetails = ({
}) => {
const [isExportConfirmation, toggleExportConfirmation] = useModalToggle();
const [isRemoveConfirmation, toggleRemoveConfirmation] = useModalToggle();
const [isDownloadAllocationWorksheetModalOpen, toggleDownloadAllocationWorksheetModal] = useModalToggle();
const accordionStatusRef = useRef();
const history = useHistory();
const stripes = useStripes();
Expand All @@ -75,55 +80,64 @@ const LedgerDetails = ({
const renderActionMenu = useCallback(
({ onToggle }) => {
return (
<MenuSection id="ledger-details-actions">
<DetailsEditAction
perm="finance.ledgers.item.put"
onEdit={onEdit}
toggleActionMenu={onToggle}
disabled={isRestrictionsLoading || restrictions.protectUpdate}
/>
<DetailsExportAction
perm="ui-finance.exportCSV"
onExportCSV={toggleExportConfirmation}
toggleActionMenu={onToggle}
/>
<DetailsRemoveAction
perm="finance.ledgers.item.delete"
toggleActionMenu={onToggle}
onRemove={toggleRemoveConfirmation}
disabled={isRestrictionsLoading || restrictions.protectDelete}
/>
<IfPermission perm="ui-finance.ledger.rollover.execute">
<Button
buttonStyle="dropdownItem"
data-test-ledger-rollover-action
onClick={() => {
onRollover();
onToggle();
}}
>
<Icon
size="small"
icon="calendar"
<>
<MenuSection id="ledger-details-actions">
<DetailsEditAction
perm="finance.ledgers.item.put"
onEdit={onEdit}
toggleActionMenu={onToggle}
disabled={isRestrictionsLoading || restrictions.protectUpdate}
/>
<DetailsExportAction
perm="ui-finance.exportCSV"
onExportCSV={toggleExportConfirmation}
toggleActionMenu={onToggle}
/>
<DetailsRemoveAction
perm="finance.ledgers.item.delete"
toggleActionMenu={onToggle}
onRemove={toggleRemoveConfirmation}
disabled={isRestrictionsLoading || restrictions.protectDelete}
/>
<IfPermission perm="ui-finance.ledger.rollover.execute">
<Button
buttonStyle="dropdownItem"
data-test-ledger-rollover-action
onClick={() => {
onRollover();
onToggle();
}}
>
<FormattedMessage id="ui-finance.actions.rollover" />
</Icon>
</Button>
<Icon
size="small"
icon="calendar"
>
<FormattedMessage id="ui-finance.actions.rollover" />
</Icon>
</Button>

<Button
data-testid="action-rollover-logs"
buttonStyle="dropdownItem"
onClick={onRolloverLogs}
>
<Icon
size="small"
icon="calendar"
<Button
data-testid="action-rollover-logs"
buttonStyle="dropdownItem"
onClick={onRolloverLogs}
>
<FormattedMessage id="ui-finance.actions.rolloverLogs" />
</Icon>
</Button>
</IfPermission>
</MenuSection>
<Icon
size="small"
icon="calendar"
>
<FormattedMessage id="ui-finance.actions.rolloverLogs" />
</Icon>
</Button>
</IfPermission>
</MenuSection>

<AllocationToolsMenuSection
onDownloadAllocationWorksheet={() => {
onToggle();
toggleDownloadAllocationWorksheetModal();
}}
/>
</>
);
},
[
Expand All @@ -133,6 +147,7 @@ const LedgerDetails = ({
onRolloverLogs,
restrictions,
toggleExportConfirmation,
toggleDownloadAllocationWorksheetModal,
toggleRemoveConfirmation,
],
);
Expand Down Expand Up @@ -281,6 +296,15 @@ const LedgerDetails = ({
/>
)}

{
isDownloadAllocationWorksheetModalOpen && (
<DownloadAllocationWorksheetModal
open
ledgerId={ledger?.id}
toggle={toggleDownloadAllocationWorksheetModal}
/>
)
}
</Pane>
</HasCommand>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import PropTypes from 'prop-types';
import {
FormattedMessage,
useIntl,
} from 'react-intl';

import { IfPermission } from '@folio/stripes/core';
import {
Button,
Icon,
MenuSection,
} from '@folio/stripes/components';

export const AllocationToolsMenuSection = ({
disabled,
onDownloadAllocationWorksheet,
}) => {
const intl = useIntl();

return (
<MenuSection
id="allocation-tools-menu-section"
label={intl.formatMessage({ id: 'ui-finance.menuSection.allocationTools' })}
>
<IfPermission perm="finance.finance-data.collection.get">
<Button
buttonStyle="dropdownItem"
onClick={onDownloadAllocationWorksheet}
disabled={disabled}
>
<Icon
size="small"
icon="download"
>
<FormattedMessage id="ui-finance.actions.downloadAllocationWorksheet" />
</Icon>
</Button>
</IfPermission>
</MenuSection>
);
};

AllocationToolsMenuSection.propTypes = {
disabled: PropTypes.bool,
onDownloadAllocationWorksheet: PropTypes.func.isRequired,
};
1 change: 1 addition & 0 deletions src/common/components/AllocationToolsMenuSection/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AllocationToolsMenuSection } from './AllocationToolsMenuSection';
Loading
Loading