Skip to content

Commit

Permalink
Merge pull request #5353 from bcgov/test-rook-RQ-FOIMOD-3300
Browse files Browse the repository at this point in the history
Fix observation 16 and 34 on FOIMOD-3300
  • Loading branch information
richard-aot authored Aug 8, 2024
2 parents 9d5af82 + 6ee19f3 commit 8b9e3da
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions forms-flow-web/src/components/FOI/customComponents/Records/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,7 @@ export const RecordsLog = ({
isMCFPersonal={isMCFPersonal}
setEditTagModalOpen={setEditTagModalOpen}
setCurrentEditRecord={setCurrentEditRecord}
lockRecords={lockRecords}
/>
))
) : (
Expand Down Expand Up @@ -3442,36 +3443,39 @@ const AttachmentPopup = React.memo(
);
};

const DeleteMenu = () => {
return (
<MenuItem
style={ lockRecords ? { pointerEvents: "none" } : {} }
disabled={lockRecords}
onClick={() => {
handleDelete();
setPopoverOpen(false);
}}
>
Delete
</MenuItem>
);
};

const ActionsPopover = ({
RestrictViewInBrowser,
record,
setEditTagModalOpen,
isMCFPersonal,
isMinistryCoordinator
isMinistryCoordinator,
lockRecords
}) => {
const isUploadedByMinistryUser = (record) => {
return hasValidDivisions(record) && isMinistryCoordinator;
return hasValidDivisions(record);
};

const hasValidDivisions = (record) => {
return record.attributes.divisions.length > 0 && record.attributes.divisions[0].divisionname != "TBD"
};

const disableMinistryUser = isMCFPersonal && isMinistryCoordinator && !isUploadedByMinistryUser(record);

const DeleteMenu = () => {
return (
<MenuItem
style={ (lockRecords || disableMinistryUser) ? { pointerEvents: "none" } : {} }
disabled={lockRecords || disableMinistryUser}
onClick={() => {
handleDelete();
setPopoverOpen(false);
}}
>
Delete
</MenuItem>
);
};

return (
<Popover
anchorReference="anchorPosition"
Expand All @@ -3493,8 +3497,9 @@ const AttachmentPopup = React.memo(
onClose={() => setPopoverOpen(false)}
>
<MenuList>
{(isMCFPersonal && (!isMinistryCoordinator || isUploadedByMinistryUser(record))) && (
{isMCFPersonal && (
<MenuItem
disabled={lockRecords || disableMinistryUser}
onClick={() => {
setEditTagModalOpen(true);
setPopoverOpen(false);
Expand All @@ -3518,7 +3523,7 @@ const AttachmentPopup = React.memo(
{(!record.attributes?.isattachment ||
record.attributes?.isattachment === undefined) && (
<MenuItem
disabled={lockRecords}
disabled={lockRecords || disableMinistryUser}
onClick={() => {
handleReplace();
setPopoverOpen(false);
Expand All @@ -3529,7 +3534,7 @@ const AttachmentPopup = React.memo(
)}
{record.attributes?.isattachment && (
<MenuItem
disabled={lockRecords}
disabled={lockRecords || disableMinistryUser}
onClick={() => {
handleReplaceAttachment();
setPopoverOpen(false);
Expand Down Expand Up @@ -3621,6 +3626,7 @@ const AttachmentPopup = React.memo(
setEditTagModalOpen={setEditTagModalOpen}
isMCFPersonal={isMCFPersonal}
isMinistryCoordinator={isMinistryCoordinator}
lockRecords={lockRecords}
/>
</>
);
Expand Down

0 comments on commit 8b9e3da

Please sign in to comment.