Web: Files: fix context menu action
This commit is contained in:
parent
c6a462168c
commit
4bfcf39410
@ -21,6 +21,7 @@ const FileTile = (props) => {
|
||||
getContextOptions,
|
||||
checked,
|
||||
selectRowAction,
|
||||
onSelectItem,
|
||||
} = props;
|
||||
const {
|
||||
id,
|
||||
@ -62,6 +63,10 @@ const FileTile = (props) => {
|
||||
selectRowAction(checked, file);
|
||||
};
|
||||
|
||||
const rowContextClick = () => {
|
||||
onSelectItem(item);
|
||||
};
|
||||
|
||||
let classNameProp =
|
||||
isFolder && access < 2 && !props.isRecycleBin
|
||||
? { className: " dropable" }
|
||||
@ -103,6 +108,7 @@ const FileTile = (props) => {
|
||||
isFolder={isFolder}
|
||||
element={element}
|
||||
onSelect={onContentRowSelect}
|
||||
rowContextClick={rowContextClick}
|
||||
//editing={editingId}
|
||||
//viewAs={viewAs}
|
||||
{...checkedProps}
|
||||
@ -135,7 +141,7 @@ export default inject(
|
||||
const { dragging, setDragging } = initFilesStore;
|
||||
const { getContextOptions } = contextOptionsStore;
|
||||
|
||||
const { selectRowAction } = filesActionsStore;
|
||||
const { selectRowAction, onSelectItem } = filesActionsStore;
|
||||
|
||||
const { selection } = filesStore;
|
||||
|
||||
@ -147,6 +153,7 @@ export default inject(
|
||||
getContextOptions,
|
||||
checked: selection.some((el) => el.id === item.id),
|
||||
selectRowAction,
|
||||
onSelectItem,
|
||||
};
|
||||
}
|
||||
)(withTranslation("Home")(observer(withRouter(FileTile))));
|
||||
|
@ -102,9 +102,9 @@ class FilesTileContent extends React.PureComponent {
|
||||
};
|
||||
}
|
||||
|
||||
completeAction = (e) => {
|
||||
//this.setState({ loading: false }, () =>)
|
||||
this.props.onEditComplete(e);
|
||||
completeAction = (id) => {
|
||||
console.log(id);
|
||||
this.props.editCompleteAction(id, this.props.item);
|
||||
};
|
||||
|
||||
updateItem = (e) => {
|
||||
@ -114,20 +114,21 @@ class FilesTileContent extends React.PureComponent {
|
||||
renameFolder,
|
||||
item,
|
||||
setIsLoading,
|
||||
fileActionId,
|
||||
} = this.props;
|
||||
|
||||
const { itemTitle } = this.state;
|
||||
const originalTitle = getTitleWithoutExst(item);
|
||||
|
||||
setIsLoading(true);
|
||||
if (originalTitle === itemTitle) return this.completeAction(e);
|
||||
if (originalTitle === itemTitle) return this.completeAction(fileActionId);
|
||||
|
||||
item.fileExst
|
||||
? updateFile(fileAction.id, itemTitle)
|
||||
.then(() => this.completeAction(e))
|
||||
.then(() => this.completeAction(fileActionId))
|
||||
.finally(() => setIsLoading(false))
|
||||
: renameFolder(fileAction.id, itemTitle)
|
||||
.then(() => this.completeAction(e))
|
||||
.then(() => this.completeAction(fileActionId))
|
||||
.finally(() => setIsLoading(false));
|
||||
};
|
||||
|
||||
@ -135,13 +136,15 @@ class FilesTileContent extends React.PureComponent {
|
||||
const { createFile, item, setIsLoading, createFolder } = this.props;
|
||||
const { itemTitle } = this.state;
|
||||
|
||||
const itemId = e.currentTarget.dataset.itemid;
|
||||
|
||||
setIsLoading(true);
|
||||
|
||||
if (itemTitle.trim() === "") return this.completeAction();
|
||||
if (itemTitle.trim() === "") return this.completeAction(itemId);
|
||||
|
||||
!item.fileExst
|
||||
? createFolder(item.parentId, itemTitle)
|
||||
.then(() => this.completeAction(e))
|
||||
.then(() => this.completeAction(itemId))
|
||||
.finally(() => {
|
||||
toastr.success(
|
||||
<Trans i18nKey="FolderCreated" ns="Home">
|
||||
@ -151,7 +154,7 @@ class FilesTileContent extends React.PureComponent {
|
||||
return setIsLoading(false);
|
||||
})
|
||||
: createFile(item.parentId, `${itemTitle}.${item.fileExst}`)
|
||||
.then(() => this.completeAction(e))
|
||||
.then(() => this.completeAction(itemId))
|
||||
.finally(() => {
|
||||
const exst = item.fileExst;
|
||||
toastr.success(
|
||||
@ -434,6 +437,7 @@ export default inject(
|
||||
formatsStore,
|
||||
treeFoldersStore,
|
||||
selectedFolderStore,
|
||||
filesActionsStore,
|
||||
},
|
||||
{ item }
|
||||
) => {
|
||||
@ -472,6 +476,8 @@ export default inject(
|
||||
const isImage = iconFormatsStore.isImage(item.fileExst);
|
||||
const isSound = iconFormatsStore.isSound(item.fileExst);
|
||||
|
||||
const { editCompleteAction } = filesActionsStore;
|
||||
|
||||
return {
|
||||
culture,
|
||||
homepage: config.homepage,
|
||||
@ -502,6 +508,8 @@ export default inject(
|
||||
updateFile,
|
||||
renameFolder,
|
||||
addExpandedKeys,
|
||||
|
||||
editCompleteAction,
|
||||
};
|
||||
}
|
||||
)(withRouter(withTranslation("Home")(observer(FilesTileContent))));
|
||||
|
@ -127,6 +127,7 @@ class Tile extends React.Component {
|
||||
indeterminate,
|
||||
onSelect,
|
||||
isFolder,
|
||||
rowContextClick,
|
||||
} = this.props;
|
||||
|
||||
console.log(isFolder, "tile");
|
||||
@ -149,7 +150,10 @@ class Tile extends React.Component {
|
||||
onSelect && onSelect(e.target.checked, item);
|
||||
};
|
||||
|
||||
const getOptions = () => contextOptions;
|
||||
const getOptions = () => {
|
||||
rowContextClick && rowContextClick();
|
||||
return contextOptions;
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledTile {...this.props}>
|
||||
@ -243,6 +247,7 @@ Tile.propTypes = {
|
||||
onSelect: PropTypes.func,
|
||||
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
||||
viewAs: PropTypes.string,
|
||||
rowContextClick: PropTypes.func,
|
||||
};
|
||||
|
||||
Tile.defaultProps = {
|
||||
|
Loading…
Reference in New Issue
Block a user