TagSpaces is an offline, open source, document manager with tagging support
prev and next file button select file in the perspective
Ilian Sapundshiev78fd4d3c21cd
diff --git a/app/components/EntryContainer.js b/app/components/EntryContainer.jsindex b6fe4b8f8..cf5771e43 100644--- a/app/components/EntryContainer.js+++ b/app/components/EntryContainer.js@@ -167,13 +167,13 @@ type Props = {toggleEntryFullWidth: () => void,isReadOnlyMode: boolean,setEntryPropertiesSplitSize: (size: number) => void,- reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void+ reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void,+ setLastSelectedEntry: (path: string) => void};type State = {isPropertiesPanelVisible?: boolean,isFullscreen: boolean,- isPropertiesEditMode: boolean,currentEntry?: OpenedEntry | null,entryProps?: Object | null,editingSupported?: boolean,@@ -320,6 +320,7 @@ class EntryContainer extends React.Component<Props, State> {fileViewer;fileViewerContainer;+ isPropertiesEditMode = false;handleMessage = (msg: Object | string) => {let data;@@ -606,6 +607,7 @@ class EntryContainer extends React.Component<Props, State> {if (this.state.currentEntry && this.state.currentEntry.path) {const nextFile = this.props.getNextFile(this.state.currentEntry.path);this.props.openFile(nextFile);+ this.props.setLastSelectedEntry(nextFile);}};@@ -613,6 +615,7 @@ class EntryContainer extends React.Component<Props, State> {if (this.state.currentEntry && this.state.currentEntry.path) {const prevFile = this.props.getPrevFile(this.state.currentEntry.path);this.props.openFile(prevFile);+ this.props.setLastSelectedEntry(prevFile);}};@@ -801,10 +804,11 @@ class EntryContainer extends React.Component<Props, State> {};setPropertiesEditMode = (editMode: boolean) => {- this.setState({ isPropertiesEditMode: editMode });+ this.isPropertiesEditMode = editMode;}resetState = (key) => {+ // this.isPropertiesEditMode = false;this.setState({[key]: uuidv1()});@@ -864,8 +868,8 @@ class EntryContainer extends React.Component<Props, State> {saveDocument: this.startSavingFile,editDocument: this.editFile,reloadDocument: this.reloadDocument,- nextDocument: this.state.isPropertiesEditMode ? () => {} : this.openNextFile,- prevDocument: this.state.isPropertiesEditMode ? () => {} : this.openPrevFile+ nextDocument: this.isPropertiesEditMode ? () => {} : this.openNextFile,+ prevDocument: this.isPropertiesEditMode ? () => {} : this.openPrevFile}}><ConfirmDialog@@ -1149,6 +1153,7 @@ function mapActionCreatorsToProps(dispatch) {removeAllTags: TaggingActions.removeAllTags,editTagForEntry: TaggingActions.editTagForEntry,reflectUpdateSidecarMeta: AppActions.reflectUpdateSidecarMeta,+ setLastSelectedEntry: AppActions.setLastSelectedEntry,}, dispatch);}diff --git a/app/components/FolderContainer.js b/app/components/FolderContainer.jsindex e96347172..6dfe4c1db 100644--- a/app/components/FolderContainer.js+++ b/app/components/FolderContainer.js@@ -217,28 +217,12 @@ class FolderContainer extends React.Component<Props, State> {nextDocument: () => {const nextFilePath = this.props.getNextFile();if (nextFilePath) {- this.setState(- {- perspectiveCommand: { key: 'SELECT_FILE', value: nextFilePath }- },- () => {- this.setState({ perspectiveCommand: {} });- }- );this.props.setLastSelectedEntry(nextFilePath);}},prevDocument: () => {const prevFilePath = this.props.getPrevFile();if (prevFilePath) {- this.setState(- {- perspectiveCommand: { key: 'SELECT_FILE', value: prevFilePath }- },- () => {- this.setState({ perspectiveCommand: {} });- }- );this.props.setLastSelectedEntry(prevFilePath);}},@@ -353,24 +337,6 @@ class FolderContainer extends React.Component<Props, State> {);} else if (this.state.currentPerspective === 'filemanager') {return <div>Place for another perspective</div>;- /*- <FileManagerPerspective- directoryContent={this.props.directoryContent}- loadDirectoryContent={this.props.loadDirectoryContent}- openFile={this.props.openFile}- openFileNatively={this.props.openFileNatively}- deleteFile={this.props.deleteFile}- renameFile={this.props.renameFile}- openDirectory={this.props.openDirectory}- currentDirectoryPath={this.props.currentDirectoryPath}- setLastSelectedEntry={this.props.setLastSelectedEntry}- perspectiveCommand={this.state.perspectiveCommand}- deleteDirectory={this.props.deleteDirectory}- addTags={this.props.addTags}- removeTags={this.props.removeTags}- removeAllTags={this.props.removeAllTags}- />- */}return <WelcomePanel />;}diff --git a/app/perspectives/grid-perspective/src/index.js b/app/perspectives/grid-perspective/src/index.jsindex 77246d1a3..78abc9df1 100644--- a/app/perspectives/grid-perspective/src/index.js+++ b/app/perspectives/grid-perspective/src/index.js@@ -97,7 +97,8 @@ const settings = JSON.parse(localStorage.getItem('tsPerspectiveGrid')); // loaditype Props = {classes: Object,- currentDirectoryPath?: string,+ currentDirectoryPath: string,+ lastSelectedEntryPath: string | null,openFile: (path: string, isFile?: boolean) => void,deleteFile: (path: string) => void,deleteDirectory: (path: string) => void,@@ -177,32 +178,27 @@ class GridPerspective extends React.Component<Props, State> {selectedTag: null,selectedEntries: []};- // console.log('Sort by -->' + this.state.sortBy);}componentWillReceiveProps = (nextProps: Props) => {const cmd = nextProps.perspectiveCommand;- const { directoryContent } = nextProps;- if (cmd && cmd.key) {- if (- cmd.key === 'SELECT_FILE' &&- cmd.value.length > 0 &&- directoryContent &&- directoryContent.length > 0- ) {- this.setState(- {- selectedEntries: nextProps.directoryContent.filter(- fsEntry => fsEntry.path === cmd.value- )- },- () => {- this.computeFileOperationsEnabled();- // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling- }- );- }+ const { directoryContent, lastSelectedEntryPath } = nextProps;++ if (lastSelectedEntryPath !== null) {+ this.setState(+ {+ selectedEntries: directoryContent.filter(+ fsEntry => fsEntry.path === lastSelectedEntryPath+ )+ },+ () => {+ this.computeFileOperationsEnabled();+ // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling+ }+ );+ }+ if (cmd && cmd.key) {if (cmd.key === 'TOGGLE_SELECT_ALL') {this.toggleSelectAllFiles();}@@ -319,24 +315,30 @@ class GridPerspective extends React.Component<Props, State> {handleGridCellClick = (event, fsEntry: FileSystemEntry) => {const { selectedEntries } = this.state;- if (event.ctrlKey && event.shiftKey) {- const lastSelectedIndex = this.props.directoryContent.findIndex(entry => entry.path === this.props.lastSelectedEntry);+ if (event.shiftKey) {+ let lastSelectedIndex = this.props.directoryContent.findIndex(entry => entry.path === this.props.lastSelectedEntryPath);const currentSelectedIndex = this.props.directoryContent.findIndex(entry => entry.path === fsEntry.path);- let entriesToSelect;+ if (lastSelectedIndex < 0) {+ lastSelectedIndex = currentSelectedIndex;+ }+ let entriesToSelect;+ // console.log('lastSelectedIndex: ' + lastSelectedIndex + ' currentSelectedIndex: ' + currentSelectedIndex);if (currentSelectedIndex > lastSelectedIndex) {entriesToSelect = this.props.directoryContent.slice(lastSelectedIndex, currentSelectedIndex + 1);- } else {+ } else if (currentSelectedIndex < lastSelectedIndex) {entriesToSelect = this.props.directoryContent.slice(currentSelectedIndex, lastSelectedIndex + 1);+ } else if (currentSelectedIndex === lastSelectedIndex) {+ entriesToSelect = [fsEntry];+ this.props.setLastSelectedEntry(fsEntry.path);}this.setState({- selectedEntries: selectedEntries.concat(entriesToSelect)+ selectedEntries: entriesToSelect},this.computeFileOperationsEnabled);- this.props.setLastSelectedEntry(fsEntry.path);} else if (event.ctrlKey) {if (selectedEntries &&@@ -350,7 +352,7 @@ class GridPerspective extends React.Component<Props, State> {},this.computeFileOperationsEnabled);- this.props.setLastSelectedEntry(null);+ // this.props.setLastSelectedEntry(null);} else {this.setState({@@ -358,25 +360,8 @@ class GridPerspective extends React.Component<Props, State> {},this.computeFileOperationsEnabled);- this.props.setLastSelectedEntry(fsEntry.path);+ // this.props.setLastSelectedEntry(fsEntry.path);}- } else if (event.shiftKey) {- const lastSelectedIndex = this.props.directoryContent.findIndex(entry => entry.path === this.props.lastSelectedEntry);- const currentSelectedIndex = this.props.directoryContent.findIndex(entry => entry.path === fsEntry.path);- let entriesToSelect;-- if (currentSelectedIndex > lastSelectedIndex) {- entriesToSelect = this.props.directoryContent.slice(lastSelectedIndex, currentSelectedIndex + 1);- } else {- entriesToSelect = this.props.directoryContent.slice(currentSelectedIndex, lastSelectedIndex + 1);- }-- this.setState(- {- selectedEntries: entriesToSelect- },- this.computeFileOperationsEnabled- );} else {this.setState({@@ -413,11 +398,9 @@ class GridPerspective extends React.Component<Props, State> {this.clearSelection();} else {const selectedEntries = [];- let lastSelectedPath = null;this.props.directoryContent.map(entry => {if (entry.isFile) {selectedEntries.push(entry);- lastSelectedPath = entry.path;}return true;});@@ -428,7 +411,6 @@ class GridPerspective extends React.Component<Props, State> {},this.computeFileOperationsEnabled);- this.props.setLastSelectedEntry(lastSelectedPath);}};@@ -563,7 +545,7 @@ class GridPerspective extends React.Component<Props, State> {isAddRemoveTagsDialogOpened: false,isMoveCopyFilesDialogOpened: false});- this.clearSelection();+ // this.clearSelection();};openFileRenameDialog = () => {@@ -1224,7 +1206,7 @@ function mapActionCreatorsToProps(dispatch) {function mapStateToProps(state) {return {supportedFileTypes: getSupportedFileTypes(state),- lastSelectedEntry: getLastSelectedEntry(state),+ lastSelectedEntryPath: getLastSelectedEntry(state),};}