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

Fix observations on FOIMOD-2975 & FOIMOD-2976 #5326

Merged
merged 6 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion forms-flow-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ARG REACT_APP_RECORD_DOWNLOAD_LIMIT
ARG REACT_APP_RECORD_DOWNLOAD_SIZE_LIMIT

ENV NODE_ENV ${NODE_ENV}
ENV GENERATE_SOURCEMAP false
ENV GENERATE_SOURCEMAP ${GENERATE_SOURCEMAP}
ENV REACT_APP_API_SERVER_URL ${REACT_APP_API_SERVER_URL}
ENV REACT_APP_API_PROJECT_URL ${REACT_APP_API_PROJECT_URL}
ENV REACT_APP_KEYCLOAK_CLIENT ${REACT_APP_KEYCLOAK_CLIENT}
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-web/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
dockerfile: Dockerfile
args:
- NODE_ENV=${NODE_ENV:-development}
- GENERATE_SOURCEMAP=false
- GENERATE_SOURCEMAP=${GENERATE_SOURCEMAP}
- REACT_APP_CLIENT_ROLE=${CLIENT_ROLE:-formsflow-client}
- REACT_APP_STAFF_REVIEWER_ROLE=${REVIEWER_ROLE:-formsflow-reviewer}
- REACT_APP_STAFF_DESIGNER_ROLE=${DESIGNER_ROLE:-formsflow-designer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ export default function AttachmentModal({
replacementfiletypes = [],
totalUploadedRecordSize = 0,
requestType = FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_GENERAL,
isScanningTeamMember = false
isScanningTeamMember = false,
curPersonalAttributes = {
person: "",
filetype: "",
volume: "",
trackingid: "",
personaltag: "TBD"
}
}) {
let tagList = [];
if (uploadFor === "attachment") {
Expand All @@ -90,6 +97,13 @@ export default function AttachmentModal({
});
}

const MCFSections = useSelector(
(state) => state.foiRequests.foiPersonalSections
);
const MSDSections = useSelector(
(state) => state.foiRequests.foiPersonalDivisionsAndSections
);

const recordFormats = useSelector((state) => state.foiRequests.recordFormats);
useEffect(() => {
setMimeTypes(
Expand Down Expand Up @@ -293,23 +307,52 @@ export default function AttachmentModal({
if (modalFor.toLowerCase() === "delete") {
handleModal(true, null, null);
} else {
let _tagValue = tagValue;
let fileInfoList = [];

let fileStatusTransition = "";
let personalAttributes = {};
if (modalFor === "replace" || modalFor === "replaceattachment") {
fileStatusTransition = attachment?.category;
if (
bcgovcode == "MCF" &&
requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL
) {
if(tagValue === "") {
fileStatusTransition = "TBD";
_tagValue = 0;
} else {
fileStatusTransition =
divisions.find((division) => division.divisionid === tagValue)
?.divisionname ||
MCFSections?.sections?.find(
(division) => division.divisionid === tagValue
)?.name;
}
personalAttributes = {
person: curPersonalAttributes.person,
filetype: curPersonalAttributes.filetype,
volume: curPersonalAttributes.volume,
trackingid: curPersonalAttributes.trackingid,
personaltag: curPersonalAttributes.personaltag
}
}
} else if (uploadFor === "record") {
if (
bcgovcode == "MCF" &&
requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL
) {
fileStatusTransition =
divisions.find((division) => division.divisionid === tagValue)
?.divisionname ||
MCFSections?.sections?.find(
(division) => division.divisionid === tagValue
)?.name;
if(tagValue === "") {
fileStatusTransition = "TBD";
_tagValue = 0;
} else {
fileStatusTransition =
divisions.find((division) => division.divisionid === tagValue)
?.divisionname ||
MCFSections?.sections?.find(
(division) => division.divisionid === tagValue
)?.name;
}
personalAttributes = {
person: person.name,
filetype: fileType.name,
Expand Down Expand Up @@ -340,7 +383,7 @@ export default function AttachmentModal({
filename: file.filename ? file.filename : file.name,
filesize: file.size,
personalattributes: personalAttributes,
...(uploadFor === "record" && { divisionid: tagValue }),
...(uploadFor === "record" && { divisionid: _tagValue }),
};
});

Expand Down Expand Up @@ -528,19 +571,16 @@ export default function AttachmentModal({
} else if (files.length === 0 && existingDocuments.length === 0) {
return true;
} else if (modalFor === "add") {
return tagValue === "";
if(requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL && bcgovcode == "MCF") {
return person === "" || fileType === "" || trackingID === "";
} else {
return tagValue === "";
}
} else if (modalFor === "replace" || modalFor === "replaceattachment") {
return false;
}
};

const MCFSections = useSelector(
(state) => state.foiRequests.foiPersonalSections
);
const MSDSections = useSelector(
(state) => state.foiRequests.foiPersonalDivisionsAndSections
);

return (
<div className="state-change-dialog">
<Dialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ const FileUploadForMCFPersonal = ({
}

React.useEffect(() => {
setIsPersonSelected(Object.keys(person).length !== 0);
},[person])
setIsPersonSelected(Object.keys(person).length !== 0 && Object.keys(fileType).length !== 0);
},[person, fileType])

React.useEffect(() => {
setAdditionalTagList(searchSections(otherTagList, searchValue, tagValue));
Expand Down Expand Up @@ -405,10 +405,10 @@ const FileUploadForMCFPersonal = ({
size="small"
onClick={()=>{handleVolumeChange(v)}}
clicked={volume?.name === v.name}
disabled={!isPersonSelected}
// disabled={!isPersonSelected}
/>
)}
{!showAllVolumes && isPersonSelected && (<AddCircleIcon
{!showAllVolumes && (<AddCircleIcon
id={`showallvolumeTag`}
key={`showallvolume-tag`}
color="primary"
Expand All @@ -432,7 +432,7 @@ const FileUploadForMCFPersonal = ({
size="small"
onClick={()=>{handleFileTypeChange(f)}}
clicked={fileType?.name === f.name}
disabled={!isPersonSelected}
// disabled={!isPersonSelected}
/>
)}
</div>
Expand Down Expand Up @@ -495,7 +495,7 @@ const FileUploadForMCFPersonal = ({
</InputAdornment>
}
fullWidth
disabled={!isPersonSelected}
// disabled={!isPersonSelected}
/>
</Grid>
</Paper>
Expand Down Expand Up @@ -707,12 +707,12 @@ const FileUploadForMCFPersonal = ({
value=""
multiple={multipleFiles}
accept={mimeTypes}
disabled={!isPersonSelected}
disabled={modalFor === "add" && !isPersonSelected}
/>
</div>
<div className="file-upload-column file-upload-column-3">
{(Object.entries(files).length === 0 && !multipleFiles) || multipleFiles ?
<button className="btn-add-files" type="button" onClick={handleUploadBtnClick} disabled={!isPersonSelected}>
<button className="btn-add-files" type="button" onClick={handleUploadBtnClick} disabled={modalFor === "add" && !isPersonSelected}>
Add Files
</button> : null}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const MCFPersonal = ({
useEffect(() => {
if(MCFVolumes?.volumes) {
setAllVolumes(MCFVolumes.volumes);
if(MCFFiletypes.filetypes.length > 5) {
if(MCFVolumes.volumes?.length > 5) {
setVolumes(MCFVolumes.volumes.slice(0, 5));
} else {
setVolumes(MCFVolumes.volumes);
Expand All @@ -107,7 +107,7 @@ const MCFPersonal = ({

useEffect(() => {
if(MCFFiletypes?.filetypes) {
if(MCFFiletypes.filetypes.length > 6) {
if(MCFFiletypes.filetypes?.length > 6) {
setFileTypes(MCFFiletypes.filetypes.slice(0, 6));
setOtherFileTypes(MCFFiletypes.filetypes.slice(6, MCFFiletypes.filetypes.length))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ export const RecordsLog = ({
requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL
);

const MCFSections = useSelector(
(state) => state.foiRequests.foiPersonalSections
);

useEffect(() => {
setRecords(recordsObj?.records);
let nonDuplicateRecords = recordsObj?.records?.filter(
Expand Down Expand Up @@ -703,6 +699,7 @@ export const RecordsLog = ({
? _file.lastModifiedDate
: new Date(_file.lastModified),
filesize: _file.size,
personalattributes: _fileInfo.personalattributes,
},
replacementof:
replaceRecord["replacementof"] == null ||
Expand Down Expand Up @@ -2562,6 +2559,7 @@ export const RecordsLog = ({
replacementfiletypes={getreplacementfiletypes()}
requestType={requestType}
isScanningTeamMember={isScanningTeamMember}
curPersonalAttributes={curPersonalAttributes}
/>
<div className="state-change-dialog">
<Dialog
Expand Down Expand Up @@ -2864,9 +2862,9 @@ const Attachment = React.memo(
const classes = useStyles();
const [disabled, setDisabled] = useState(false);
const [isRetry, setRetry] = useState(false);
const removePersonalTagsFromDivisions = record.attributes?.divisions.filter(
const removeInValidTagsFromDivisions = record.attributes?.divisions.filter(
(division) => {
return !record.attributes?.personalattributes?.personaltag || (record.attributes?.personalattributes?.personaltag && division.divisionname != record.attributes?.personalattributes?.personaltag);
return division.divisionid != 0;
});

// useEffect(() => {
Expand Down Expand Up @@ -3065,7 +3063,7 @@ const Attachment = React.memo(
alignItems="flex-start"
>
<Grid item xs={6}>
{removePersonalTagsFromDivisions.map((division, i) => (
{removeInValidTagsFromDivisions.map((division, i) => (
<Chip
item
key={i}
Expand Down Expand Up @@ -3093,9 +3091,9 @@ const Attachment = React.memo(
style={{
backgroundColor: "#003366",
margin:
record.isattachment && removePersonalTagsFromDivisions.length === 0
record.isattachment && removeInValidTagsFromDivisions.length === 0
? "4px 4px 4px 95px"
: removePersonalTagsFromDivisions.length === 0
: removeInValidTagsFromDivisions.length === 0
? "4px 4px 4px 35px"
: "4px",
}}
Expand Down
4 changes: 3 additions & 1 deletion request-management-api/request_api/schemas/foirecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Meta: # pylint: disable=too-few-public-methods
incompatible = fields.Boolean(required=True,allow_none=False)
extension = fields.Str(validate=validate.Length(min=1, max=10), required=True,allow_none=False)
isattachment = fields.Boolean(required=False,allow_none=False)
personalattributes = fields.Nested(PersonalAttributesSchema,required=False,allow_none=True)

class ReplaceRecordAttributeSchema(Schema):
class Meta: # pylint: disable=too-few-public-methods
Expand All @@ -86,7 +87,8 @@ class Meta: # pylint: disable=too-few-public-methods
incompatible = fields.Boolean(required=True,allow_none=False)
extension = fields.Str(validate=validate.Length(min=1, max=10), required=True,allow_none=False)
isattachment = fields.Boolean(required=False,allow_none=False)
hasfilereplaced = fields.Boolean(required=False,allow_none=False)
hasfilereplaced = fields.Boolean(required=False,allow_none=False)
personalattributes = fields.Nested(PersonalAttributesSchema,required=False,allow_none=True)

class FOIRequestRetryRecordSchema(Schema):
class Meta: # pylint: disable=too-few-public-methods
Expand Down
4 changes: 2 additions & 2 deletions request-management-api/request_api/services/recordservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ def replace(self, _requestid, ministryrequestid, recordid, recordschema, userid)
_record['attributes']['extension'] = extension
_record['attributes']['incompatible'] = extension.lower() in NONREDACTABLE_FILE_TYPES
record.__dict__.update(_record)
recordlist.append(record)
recordlist.append(record)
dbresponse = FOIRequestRecord.replace(recordid,recordlist)
if (dbresponse.success):
processingrecords = [{**record, **{"recordid": dbresponse.args[0][record['s3uripath']]['recordid']}} for record in records]
processingrecords = [{**record, **{"recordid": dbresponse.args[0][record['s3uripath']]['recordid']}} for record in records]
# record all jobs before sending first redis stream message to avoid race condition
jobids, err = self.makedocreviewerrequest('POST', '/api/jobstatus', {
'records': processingrecords,
Expand Down
Loading