web: components: bump version
This commit is contained in:
parent
cdaf42ad6b
commit
7ef15cb51d
@ -1,48 +1,21 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { utils, TreeMenu, TreeNode, Icons, toastr } from "asc-web-components";
|
||||
import { utils } from "asc-web-components";
|
||||
import {
|
||||
selectFolder,
|
||||
fetchMyFolder,
|
||||
fetchSharedFolder,
|
||||
fetchCommonFolder,
|
||||
fetchProjectsFolder,
|
||||
fetchTrashFolder
|
||||
fetchTrashFolder,
|
||||
fetchFolder,
|
||||
setRootFolders,
|
||||
testUpdateMyFolder
|
||||
} from "../../../store/files/actions";
|
||||
import { getRootFolders } from "../../../store/files/selectors";
|
||||
import store from "../../../store/store";
|
||||
|
||||
const getItems = data => {
|
||||
return data.map(item => {
|
||||
if (item.children && item.children.length) {
|
||||
return (
|
||||
<TreeNode
|
||||
title={item.title}
|
||||
key={item.key}
|
||||
icon={
|
||||
item.root ? (
|
||||
<Icons.CatalogFolderIcon size="scale" isfill color="#657077" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
>
|
||||
{getItems(item.children)}
|
||||
</TreeNode>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<TreeNode
|
||||
key={item.key}
|
||||
title={item.title}
|
||||
icon={<Icons.CatalogFolderIcon size="scale" isfill color="#657077" />}
|
||||
/>
|
||||
);
|
||||
});
|
||||
};
|
||||
import TreeFolders from "./TreeFolders";
|
||||
|
||||
class ArticleBodyContent extends React.Component {
|
||||
shouldComponentUpdate(nextProps) {
|
||||
/*shouldComponentUpdate(nextProps) {
|
||||
const { selectedKeys, data } = this.props;
|
||||
if (!utils.array.isArrayEqual(nextProps.selectedKeys, selectedKeys)) {
|
||||
return true;
|
||||
@ -53,107 +26,57 @@ class ArticleBodyContent extends React.Component {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
onSelect = data => {
|
||||
console.log("onSelect document", data);
|
||||
|
||||
const currentModuleId = Number(data[0]);
|
||||
const { currentModule, rootFolders } = this.props;
|
||||
if (currentModule !== currentModuleId) {
|
||||
const { my, share, common, project, trash } = rootFolders;
|
||||
|
||||
switch (currentModuleId) {
|
||||
case my.id:
|
||||
fetchMyFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchMyFolder")
|
||||
);
|
||||
break;
|
||||
case share.id:
|
||||
fetchSharedFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchSharedFolder")
|
||||
);
|
||||
break;
|
||||
case common.id:
|
||||
fetchCommonFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchCommonFolder")
|
||||
);
|
||||
break;
|
||||
case project.id:
|
||||
fetchProjectsFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchProjectsFolder")
|
||||
);
|
||||
|
||||
break;
|
||||
case trash.id:
|
||||
fetchTrashFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchTrashFolder")
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//this.props.selectFolder(data && data.length === 1 && data[0] !== "root" ? data[0] : null);
|
||||
};
|
||||
|
||||
switcherIcon = obj => {
|
||||
if (obj.isLeaf) {
|
||||
return null;
|
||||
}
|
||||
if (obj.expanded) {
|
||||
return <Icons.ExpanderDownIcon size="scale" isfill color="dimgray" />;
|
||||
} else {
|
||||
return <Icons.ExpanderRightIcon size="scale" isfill color="dimgray" />;
|
||||
}
|
||||
};
|
||||
}*/
|
||||
|
||||
render() {
|
||||
const { data, selectedKeys, fakeNewDocuments } = this.props;
|
||||
const {
|
||||
data,
|
||||
selectedKeys,
|
||||
fakeNewDocuments,
|
||||
rootFolders,
|
||||
currentModule,
|
||||
filter
|
||||
} = this.props;
|
||||
|
||||
//console.log("FilesTreeMenu", this.props);
|
||||
|
||||
return data.map((item, index) => (
|
||||
<TreeMenu
|
||||
key={`TreeMenu_${index}`}
|
||||
className="files-tree-menu"
|
||||
checkable={false}
|
||||
draggable={false}
|
||||
disabled={false}
|
||||
multiple={false}
|
||||
showIcon
|
||||
defaultExpandAll
|
||||
switcherIcon={this.switcherIcon}
|
||||
onSelect={this.onSelect}
|
||||
return (
|
||||
<TreeFolders
|
||||
selectedKeys={selectedKeys}
|
||||
badgeLabel={fakeNewDocuments}
|
||||
onBadgeClick={() => console.log("onBadgeClick")}
|
||||
>
|
||||
{getItems(item)}
|
||||
</TreeMenu>
|
||||
));
|
||||
fakeNewDocuments={fakeNewDocuments}
|
||||
rootFolders={rootFolders}
|
||||
currentModule={currentModule}
|
||||
state={this.props.state}
|
||||
testUpdateMyFolder={this.props.testUpdateMyFolder}
|
||||
data={data}
|
||||
filter={filter}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const { rootFolders, selectedFolder } = state.files;
|
||||
const { rootFolders, selectedFolder, filter } = state.files;
|
||||
const currentFolderId = selectedFolder.id.toString();
|
||||
const fakeNewDocuments = 8;
|
||||
|
||||
return {
|
||||
data: getRootFolders(state.files),
|
||||
selectedKeys: state.files.selectedFolder ? [currentFolderId] : [""],
|
||||
data: getRootFolders(rootFolders),
|
||||
selectedKeys: selectedFolder ? [currentFolderId] : [""],
|
||||
fakeNewDocuments,
|
||||
currentModule: currentFolderId,
|
||||
rootFolders
|
||||
rootFolders,
|
||||
state,
|
||||
filter
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, {
|
||||
selectFolder,
|
||||
fetchMyFolder,
|
||||
fetchSharedFolder,
|
||||
fetchCommonFolder,
|
||||
fetchProjectsFolder,
|
||||
fetchTrashFolder
|
||||
fetchTrashFolder,
|
||||
fetchFolder,
|
||||
setRootFolders,
|
||||
testUpdateMyFolder
|
||||
})(ArticleBodyContent);
|
||||
|
@ -20,6 +20,7 @@ export const SET_SELECTED = "SET_SELECTED";
|
||||
export const SET_SELECTED_FOLDER = "SET_SELECTED_FOLDER";
|
||||
export const SET_ROOT_FOLDERS = "SET_ROOT_FOLDERS";
|
||||
export const SET_FILES_FILTER = "SET_FILES_FILTER";
|
||||
export const SET_FILTER = "SET_FILTER";
|
||||
|
||||
export function setFiles(files) {
|
||||
return {
|
||||
@ -70,6 +71,20 @@ export function setFilesFilter(filter) {
|
||||
filter
|
||||
};
|
||||
}
|
||||
export function setFilter(filter) {
|
||||
//setFilterUrl(filter);
|
||||
return {
|
||||
type: SET_FILTER,
|
||||
filter
|
||||
};
|
||||
}
|
||||
|
||||
// export function setFilesFilter(filter) {
|
||||
// return {
|
||||
// type: SET_FILES_FILTER,
|
||||
// filter
|
||||
// };
|
||||
// }
|
||||
|
||||
export function setFilterUrl(filter) {
|
||||
const defaultFilter = FilesFilter.getDefault();
|
||||
@ -157,7 +172,7 @@ export function fetchFolder(folderId, dispatch) {
|
||||
return files.getFolder(folderId).then(data => {
|
||||
dispatch(setFolders(data.folders));
|
||||
dispatch(setFiles(data.files));
|
||||
return dispatch(setSelectedFolder(data.current));
|
||||
return dispatch(setSelectedFolder({folders: data.folders, ...data.current}));
|
||||
})
|
||||
}
|
||||
|
||||
@ -213,15 +228,50 @@ export function fetchRootFolders(dispatch) {
|
||||
};
|
||||
|
||||
return files.getMyFolderList()
|
||||
.then(data => root.my = data.current)
|
||||
.then(data => root.my = { folders: data.folders, ...data.current})
|
||||
.then(() => files.getCommonFolderList()
|
||||
.then(data => root.common = data.current))
|
||||
.then(data => root.common = { folders: data.folders, ...data.current}))
|
||||
.then(() => files.getProjectsFolderList()
|
||||
.then(data => root.project = data.current))
|
||||
.then(data => root.project = { folders: data.folders, ...data.current}))
|
||||
.then(() => files.getTrashFolderList()
|
||||
.then(data => root.trash = data.current))
|
||||
.then(data => root.trash = { folders: data.folders, ...data.current}))
|
||||
.then(() => files.getSharedFolderList()
|
||||
.then(data => root.share = data.current))
|
||||
.then(data => root.share = { folders: data.folders, ...data.current}))
|
||||
.then(() => dispatch(setRootFolders(root)));
|
||||
}
|
||||
|
||||
export function testUpdateMyFolder(folders) {
|
||||
return (dispatch, getState) => {
|
||||
const { files } = getState();
|
||||
const { rootFolders } = files;
|
||||
|
||||
console.log("folders", folders);
|
||||
|
||||
const newRoot = rootFolders;
|
||||
newRoot.my.folders = folders;
|
||||
console.log("newRoot.my.folders", newRoot.my.folders);
|
||||
console.log("folders", folders);
|
||||
console.log("newRoot", newRoot);
|
||||
//dispatch(setRootFolders(null));
|
||||
dispatch(setRootFolders(newRoot));
|
||||
|
||||
}
|
||||
//setRootFolders
|
||||
}
|
||||
|
||||
/*export function deleteGroup(id) {
|
||||
return (dispatch, getState) => {
|
||||
const { people } = getState();
|
||||
const { groups, filter } = people;
|
||||
|
||||
return api.groups
|
||||
.deleteGroup(id)
|
||||
.then(res => {
|
||||
return dispatch(setGroups(groups.filter(g => g.id !== id)));
|
||||
})
|
||||
.then(() => {
|
||||
const newFilter = filter.clone(true);
|
||||
return fetchPeople(newFilter, dispatch);
|
||||
});
|
||||
};
|
||||
}*/
|
@ -1,4 +1,4 @@
|
||||
import { SET_FILES, SET_FOLDERS, SET_SELECTION, SET_SELECTED, SET_SELECTED_FOLDER, SET_ROOT_FOLDERS, SET_FILES_FILTER } from "./actions";
|
||||
import { SET_FILES, SET_FOLDERS, SET_SELECTION, SET_SELECTED, SET_SELECTED_FOLDER, SET_ROOT_FOLDERS, SET_FILES_FILTER, SET_FILTER } from "./actions";
|
||||
import { api } from "asc-web-common";
|
||||
const { FilesFilter } = api;
|
||||
|
||||
@ -38,6 +38,10 @@ const filesReducer = (state = initialState, action) => {
|
||||
return Object.assign({}, state, {
|
||||
rootFolders: action.rootFolders
|
||||
});
|
||||
case SET_FILTER:
|
||||
return Object.assign({}, state, {
|
||||
filter: action.filter
|
||||
});
|
||||
// case SET_FILES_FILTER:
|
||||
// return Object.assign({}, state, {
|
||||
// filter: action.filter
|
||||
|
@ -1,60 +1,62 @@
|
||||
const getTreeGroups = (groups, departments, key) => {
|
||||
const treeData = [
|
||||
{
|
||||
key: key,
|
||||
title: departments,
|
||||
root: true,
|
||||
children:
|
||||
groups.map(g => {
|
||||
return {
|
||||
key: g.id,
|
||||
title: g.title || g.name,
|
||||
root: false
|
||||
};
|
||||
}) || []
|
||||
}
|
||||
];
|
||||
|
||||
return treeData;
|
||||
const loop = (folders, index) => {
|
||||
let i = 0;
|
||||
let newFolders = folders.my;
|
||||
while (i !== index.length) {
|
||||
console.log("newFolders", newFolders);
|
||||
newFolders = newFolders.folders[index[i]];
|
||||
i++;
|
||||
}
|
||||
//console.log("newFolders", newFolders);
|
||||
};
|
||||
|
||||
const getFakeFolders = count =>
|
||||
Array.from(Array(count), (x, index) => {
|
||||
return {
|
||||
id: `00000000-0000-0000-0000-00000000000${index}`,
|
||||
name: `fakeFolder${index}`,
|
||||
manager: null
|
||||
};
|
||||
});
|
||||
|
||||
export const getRootFolders = files => {
|
||||
const { folders, rootFolders } = files;
|
||||
const { my, share, common, project, trash } = rootFolders;
|
||||
const { my, share, common, project, trash } = files;
|
||||
|
||||
const myDocumentsFolder = getTreeGroups(folders, my.title, my.id);
|
||||
const sharedWithMeFolder = getTreeGroups(
|
||||
getFakeFolders(share.foldersCount),
|
||||
share.title,
|
||||
share.id
|
||||
);
|
||||
const commonDocumentsFolder = getTreeGroups(
|
||||
getFakeFolders(common.foldersCount),
|
||||
common.title,
|
||||
common.id
|
||||
);
|
||||
const projectDocumentsFolder = getTreeGroups(
|
||||
getFakeFolders(project.foldersCount),
|
||||
project.title,
|
||||
project.id
|
||||
);
|
||||
const recycleBinFolder = getTreeGroups([], trash.title, trash.id);
|
||||
const myIsLeaf = my.folders.length > 0;
|
||||
const shareIsLeaf = share.folders.length > 0;
|
||||
const commonIsLeaf = common.folders.length > 0;
|
||||
const projectIsLeaf = project.folders.length > 0;
|
||||
|
||||
// my folder //path ["0", "14", "24"] - ID папок 1 значение рутовая папка
|
||||
// get index folder "0", "2", "0" - Index папок 1 значение рутовая папка
|
||||
// my.folders[14].folders[24];
|
||||
|
||||
//const index = ["0", "2", "0"];
|
||||
//loop(files, index);
|
||||
|
||||
const data = [
|
||||
myDocumentsFolder,
|
||||
sharedWithMeFolder,
|
||||
commonDocumentsFolder,
|
||||
projectDocumentsFolder,
|
||||
recycleBinFolder
|
||||
{
|
||||
//folders: my.folders,
|
||||
title: my.title,
|
||||
id: my.id,
|
||||
key: "0-0",
|
||||
isLeaf: !myIsLeaf
|
||||
},
|
||||
{
|
||||
//folders: share.folders,
|
||||
title: share.title,
|
||||
key: "0-1",
|
||||
isLeaf: !shareIsLeaf,
|
||||
id: share.id
|
||||
},
|
||||
{
|
||||
//folders: common.folders,
|
||||
title: common.title,
|
||||
key: "0-2",
|
||||
isLeaf: !commonIsLeaf,
|
||||
id: common.id
|
||||
},
|
||||
{
|
||||
//folders: project.folders,
|
||||
title: project.title,
|
||||
key: "0-3",
|
||||
isLeaf: !projectIsLeaf,
|
||||
id: project.id
|
||||
},
|
||||
{
|
||||
//folders: [],
|
||||
title: trash.title, id: trash.id, key: "0-4", isLeaf: true }
|
||||
];
|
||||
|
||||
return data;
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ const DEFAULT_SORT_ORDER = "ascending";
|
||||
const DEFAULT_FILTER_TYPE = FilterType.None;
|
||||
const DEFAULT_SEARCH_TYPE = false; //withSubfolders
|
||||
const DEFAULT_SEARCH = null;
|
||||
const DEFAULT_FOLDER_PATH = [];
|
||||
|
||||
// TODO: add next params
|
||||
// subjectGroup bool
|
||||
@ -29,6 +30,12 @@ class FilesFilter {
|
||||
filterType = DEFAULT_FILTER_TYPE,
|
||||
withSubfolders = DEFAULT_SEARCH_TYPE,
|
||||
search = DEFAULT_SEARCH,
|
||||
|
||||
myPath = DEFAULT_FOLDER_PATH,
|
||||
sharedPath = DEFAULT_FOLDER_PATH,
|
||||
commonPath = DEFAULT_FOLDER_PATH,
|
||||
projectPath = DEFAULT_FOLDER_PATH,
|
||||
recycleBinPath = DEFAULT_FOLDER_PATH,
|
||||
) {
|
||||
this.page = page;
|
||||
this.pageCount = pageCount;
|
||||
@ -38,6 +45,11 @@ class FilesFilter {
|
||||
this.withSubfolders = withSubfolders;
|
||||
this.search = search;
|
||||
this.total = total;
|
||||
this.myPath = myPath;
|
||||
this.sharedPath = sharedPath;
|
||||
this.commonPath = commonPath;
|
||||
this.projectPath = projectPath;
|
||||
this.recycleBinPath = recycleBinPath;
|
||||
}
|
||||
|
||||
getStartIndex = () => {
|
||||
@ -92,7 +104,13 @@ class FilesFilter {
|
||||
this.sortOrder,
|
||||
this.filterType,
|
||||
this.withSubfolders,
|
||||
this.search
|
||||
this.search,
|
||||
|
||||
this.myPath,
|
||||
this.sharedPath,
|
||||
this.commonPath,
|
||||
this.projectPath,
|
||||
this.recycleBinPath
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "asc-web-components",
|
||||
"version": "1.0.362",
|
||||
"version": "1.0.363",
|
||||
"description": "Ascensio System SIA component library",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "dist/asc-web-components.js",
|
||||
|
Loading…
Reference in New Issue
Block a user