Web: Files: added onSelect function for selectbox

This commit is contained in:
Nikita Gopienko 2021-06-17 18:46:22 +03:00
parent df70473ce5
commit 249af955d1
4 changed files with 39 additions and 37 deletions

View File

@ -162,14 +162,11 @@ class PageLayout extends React.Component {
isMobile && this.props.setArticleVisibleOnUnpin(true);
};
// duringSelection = (duringItems) => {
// if (!this.props.uploadFiles || isMobile) return;
// const items = [];
// for (let item of duringItems) {
// items.push(item.props.item);
// }
// this.props.setSelections(items);
// };
onSelect = (e) => {
if (!e.selected.length || this.props.dragging) return;
const items = e.selected;
this.props.setSelections(items);
};
render() {
const {
@ -194,6 +191,7 @@ class PageLayout extends React.Component {
isTabletView,
firstLoad,
isLoading,
dragging,
} = this.props;
let articleHeaderContent = null;
@ -426,27 +424,21 @@ class PageLayout extends React.Component {
return (
<>
{renderPageLayout()}
<Selecto
dragContainer={".main"}
selectableTargets={[".files-row"]}
hitRate={0}
selectByClick={true}
selectFromInside={true}
ratio={0}
onSelect={(e) => {
console.log("onSelect", e);
}}
/>
{!isMobile && uploadFiles && !dragging && (
<Selecto
//container={document.body} // The container to add a selection element
dragContainer={".main"}
selectableTargets={[".files-row"]}
hitRate={1}
selectByClick={false}
selectFromInside={true}
ratio={0}
continueSelect={false}
onSelect={this.onSelect}
/>
)}
</>
);
// return isMobile || !uploadFiles ? (
// renderPageLayout()
// ) : (
// <StyledSelectableGroup>
// {renderPageLayout()}
// </StyledSelectableGroup>
// );
}
}

View File

@ -101,7 +101,6 @@ class SectionBody extends React.Component {
children,
onDrop,
pinned,
setSelections,
uploadFiles,
viewAs,
withScroll,
@ -194,7 +193,6 @@ SectionBody.propTypes = {
autoFocus: PropTypes.bool,
pinned: PropTypes.bool,
onDrop: PropTypes.func,
setSelections: PropTypes.func,
uploadFiles: PropTypes.bool,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),

View File

@ -500,7 +500,7 @@ class FilesActionStore {
selectRowAction = (checked, file) => {
const { selected, setSelected, selectFile, deselectFile } = this.filesStore;
selected === "close" && setSelected("none");
//selected === "close" && setSelected("none");
if (checked) {
selectFile(file);
} else {

View File

@ -1194,14 +1194,26 @@ class FilesStore {
setSelections = (items) => {
if (!items.length && !this.selection.length) return;
if (items.length !== this.selection.length) {
this.setSelection(items);
} else if (items.length === 0) {
const item = this.selection.find(
(x) => x.id === item[0].id && x.fileExst === item.fileExst
);
if (!item) this.setSelection(items);
//if (items.length !== this.selection.length) {
const newSelection = [];
for (let item of items) {
const value = item.getAttribute("value");
const splitValue = value && value.split("_");
const fileType = splitValue[0];
//const id = splitValue.slice(1).join("_");
const id = splitValue[1];
if (fileType === "file") {
newSelection.push(this.files.find((f) => f.id == id && f.fileExst));
} else {
newSelection.push(this.folders.find((f) => f.id == id && !f.fileExst));
}
}
this.setSelection(newSelection);
//}
};
getShareUsers(folderIds, fileIds) {