Web: Files: added onExpand to TreeFolders, removed setFilter from FilesRowContent

This commit is contained in:
Nikita Gopienko 2020-03-13 19:02:32 +03:00
parent 8119d2884e
commit 6dcca4c0e1
2 changed files with 12 additions and 17 deletions

View File

@ -11,7 +11,7 @@ class TreeFolders extends React.Component {
const treeData = props.data;
this.state = { treeData };
this.state = { treeData, expandedKeys: this.props.expandedKeys };
this.ref = React.createRef();
}
@ -160,9 +160,13 @@ class TreeFolders extends React.Component {
});
};
onExpand = data => {
this.setState({expandedKeys: data})
}
render() {
const { selectedKeys, fakeNewDocuments, expandedKeys } = this.props;
const { treeData } = this.state;
const { selectedKeys, fakeNewDocuments } = this.props;
const { treeData, expandedKeys } = this.state;
//console.log("TreeFolders render", this.props);
return (
@ -181,6 +185,7 @@ class TreeFolders extends React.Component {
onBadgeClick={() => console.log("onBadgeClick")}
loadData={this.onLoadData}
expandedKeys={expandedKeys}
onExpand={this.onExpand}
>
{this.getItems(treeData)}
</TreeMenu>

View File

@ -98,7 +98,7 @@ class FilesRowContent extends React.PureComponent {
onFilesClick = () => {
const { id, fileExst } = this.props.item;
const { filter, setFilter } = this.props;
const { filter } = this.props;
if (!fileExst) {
const a =
history.location.search !== ""
@ -107,19 +107,9 @@ class FilesRowContent extends React.PureComponent {
const url = `${history.location.pathname}${a}`;
history.push(`${url}#${id}`);
fetchFiles(id, filter, store.dispatch).then(data => {
const newFilter = filter.clone();
if (
newFilter.treeFolders.indexOf(
data.selectedFolder.parentId.toString()
) === -1
) {
newFilter.treeFolders.push(data.selectedFolder.parentId.toString());
}
newFilter.treeFolders.push(id.toString());
setFilter(newFilter);
});
const newFilter = filter.clone();
newFilter.treeFolders.push(id.toString());
fetchFiles(id, newFilter, store.dispatch);
}
};