Skip to content

Commit

Permalink
Merge pull request #1062 from bcgov/test-rook-AS-CFD-fixes
Browse files Browse the repository at this point in the history
FOIMOD-3300 -Fix for Observation # 3 - Left Hand Pane Not Expanding
  • Loading branch information
aparna-aot authored Jul 24, 2024
2 parents 23c5dd8 + dda45fb commit 2b76ea2
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 37 deletions.
8 changes: 2 additions & 6 deletions web/src/components/FOI/Home/CustomTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const CustomTreeView = React.memo(React.forwardRef(({

useImperativeHandle(ref, () => ({
async scrollToPage(event: any, newExpandedItems: string[], pageId: string) {

setExpandedItems([...new Set(expandedItems.concat(newExpandedItems))]);
await new Promise(resolve => setTimeout(resolve, 400)); // wait for expand animation to finish
apiRef.current?.focusItem(event, pageId)
Expand All @@ -73,10 +72,9 @@ const CustomTreeView = React.memo(React.forwardRef(({
scrollLeftPanelPosition(event: any)
{
let _lastselected = localStorage.getItem("lastselected")

if(_lastselected)
{
let _docid = JSON.parse(_lastselected)?.docid
let _docid = JSON.parse(_lastselected)?.docid
let docidstring = ''
if(_lastselected.indexOf('division')>-1)
{
Expand Down Expand Up @@ -126,7 +124,6 @@ const CustomTreeView = React.memo(React.forwardRef(({
let selectedNodes = [];
for (let nodeId of nodeIds) {
nodeId = nodeId.replace(/undefined/g, "null");
console.log("nodeId:",nodeId)
let node = JSON.parse(nodeId);
selectedNodes.push(node);
if (node.page) {
Expand Down Expand Up @@ -180,6 +177,7 @@ const CustomTreeView = React.memo(React.forwardRef(({

// props.itemId = props?.itemId?.replaceAll("undefined", "\"\"");
// let itemid = JSON.parse(props?.itemId);
//console.log("CustomTreeItem-",props)
const derivedItemId = props.itemId?.replaceAll("undefined", "\"\"") ?? "";
// Parse the derived itemId
let itemid:any;
Expand Down Expand Up @@ -211,7 +209,6 @@ const CustomTreeView = React.memo(React.forwardRef(({

const openContextMenu = (e: any, props: any) => {
if (props.children && requestInfo.bcgovcode !== "MCF" && requestInfo.requesttype !== "personal") return
// console.log("contextmenu")
e.preventDefault();
let nodeId: string = e.target.parentElement.parentElement.id;
if (nodeId === "") {
Expand All @@ -227,7 +224,6 @@ const CustomTreeView = React.memo(React.forwardRef(({
return f.documentid === nodeIdJson.docid;
});
setCurrentEditRecord(currentFiles[0]);
// console.log("selected file: ", currentFiles[0]);

setActiveNode(nodeIdJson);
} else { //mcf personal level 1 tree item
Expand Down
104 changes: 73 additions & 31 deletions web/src/components/FOI/Home/DocumentSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,24 @@ const DocumentSelector = React.memo(
(f: any) => f.documentid === lookup.docid
);
let pageId, newExpandedItems;
if (organizeBy === "lastmodified") {
if(requestInfo.bcgovcode === "MCF" && requestInfo.requesttype === "personal"){
let label = file.attributes.personalattributes.person + ' - ' + file.attributes.personalattributes.filetype;
if (file.attributes.personalattributes.trackingid) {
label += ' - ' + file.attributes.personalattributes.trackingid;
}
if (file.attributes.personalattributes.volume) {
label += ' - ' + file.attributes.personalattributes.volume;
}
pageId = `{"filevolume": "${label}", "docid": ${file.documentid}, "page": ${
lookup.page
}, "flagid": [${getPageFlagIds(file.pageFlag, lookup.page)}], "title": "${getFlagName(file, lookup.page)}"}`;

newExpandedItems = [
'{"filevolume": "' + label + '"}',
'{"filevolume": "' + label + '", "docid": ' + lookup.docid + '}'
];
}
else if (organizeBy === "lastmodified") {
pageId = `{"docid": ${file.documentid}, "page": ${
lookup.page
}, "flagid": [${getPageFlagIds(
Expand All @@ -106,7 +123,6 @@ const DocumentSelector = React.memo(
"}",
];
}

treeRef?.current?.scrollToPage(event, newExpandedItems, pageId);

},
Expand Down Expand Up @@ -598,7 +614,20 @@ const DocumentSelector = React.memo(
});
}
});
if (organizeBy === "lastmodified") {
if (requestInfo.bcgovcode === "MCF" && requestInfo.requesttype === "personal") {
return filteredpages.pages.map((p: any) => {
return {
id: `{"filevolume": ${division}, "docid": ${
file.documentid
}, "page": ${p}, "flagid": [${getPageFlagIds(
file.pageFlag,
p
)}], "title": "${getFlagName(file, p)}"}`,
label: getPageLabel(file, p),
};
});
}
else if (organizeBy === "lastmodified") {
return filteredpages.map((p: any) => {
return {
id: `{"docid": ${
Expand Down Expand Up @@ -635,33 +664,46 @@ const DocumentSelector = React.memo(
// }
// }
} else {
if (organizeBy === "lastmodified") {
return file.pages.map((p: any) => {
return {
id: `{"docid": ${
file.documentid
}, "page": ${p}, "flagid": [${getPageFlagIds(
file.pageFlag,
p
)}], "title": "${getFlagName(file, p)}"}`,
label: getPageLabel(file, p),
};
});
} else {
return file.pages.map((p: any) => {
return {
id: `{"division": ${division?.divisionid}, "docid": ${
file.documentid
}, "page": ${p}, "flagid": [${getPageFlagIds(
file.pageFlag,
p
)}], "title": "${getFlagName(file, p)}"}`,
label: getPageLabel(file, p),
};
});
}
if (requestInfo.bcgovcode === "MCF" && requestInfo.requesttype === "personal") {
return file.pages.map((p: any) => {
return {
id: `{"filevolume": "${division}", "docid": ${
file.documentid
}, "page": ${p}, "flagid": [${getPageFlagIds(
file.pageFlag,
p
)}], "title": "${getFlagName(file, p)}"}`,
label: getPageLabel(file, p),
};
});
}
else if (organizeBy === "lastmodified") {
return file.pages.map((p: any) => {
return {
id: `{"docid": ${
file.documentid
}, "page": ${p}, "flagid": [${getPageFlagIds(
file.pageFlag,
p
)}], "title": "${getFlagName(file, p)}"}`,
label: getPageLabel(file, p),
};
});
} else {
return file.pages.map((p: any) => {
return {
id: `{"division": ${division?.divisionid}, "docid": ${
file.documentid
}, "page": ${p}, "flagid": [${getPageFlagIds(
file.pageFlag,
p
)}], "title": "${getFlagName(file, p)}"}`,
label: getPageLabel(file, p),
};
});
}
}
}
}

const getTreeItems = () => {
if (pageFlags) {
Expand All @@ -686,9 +728,9 @@ const DocumentSelector = React.memo(
index = tree.length - 1
}
tree[index].children.push({
id: `{"docid": ${file.documentid}}`,
id: `{"filevolume": "${label}", "docid": ${file.documentid}}`,
label: (file.attributes.personalattributes.personaltag || 'TBD') + ' (' + file.pages.length + ')',
children: getFilePages(file)
children: getFilePages(file, label)
})
}
return tree;
Expand Down

0 comments on commit 2b76ea2

Please sign in to comment.