TagSpaces is an offline, open source, document manager with tagging support
Kanban - fix saving order of the folder and files in the folders
sytolkc83bef3966c7
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsxindex 2c712a978..9df05766d 100644--- a/app/components/FolderContainer.tsx+++ b/app/components/FolderContainer.tsx@@ -50,7 +50,8 @@ import {OpenedEntry,getSelectedEntries,getProgress,- getCurrentDirectoryFiles+ getCurrentDirectoryFiles,+ getCurrentDirectoryDirs} from '../reducers/app';import TaggingActions from '../reducers/tagging-actions';import LoadingLazy from '../components/LoadingLazy';@@ -185,6 +186,7 @@ interface Props {windowWidth: number;directoryContent: Array<Object>;currentDirectoryFiles: Array<any>;+ currentDirectoryDirs: Array<any>;currentDirectoryPath: string | null;searchResultCount: number;addTags: () => void;@@ -326,6 +328,7 @@ const FolderContainer = (props: Props) => {<KanBanPerspectiveAsyncdirectoryContent={props.directoryContent}currentDirectoryFiles={props.currentDirectoryFiles}+ currentDirectoryDirs={props.currentDirectoryDirs}loadDirectoryContent={props.loadDirectoryContent}openFsEntry={props.openFsEntry}openRenameEntryDialog={() => setIsRenameEntryDialogOpened(true)}@@ -457,7 +460,6 @@ const FolderContainer = (props: Props) => {perspectiveId === PerspectiveIDs.LIST) {props.setCurrentDirectoryPerspective(perspectiveId);- return;} else if (perspectiveId === PerspectiveIDs.GALLERY) {const openPersDocs = window.confirm(i18n.t('perspectiveInPro'));if (openPersDocs) {@@ -676,18 +678,10 @@ const FolderContainer = (props: Props) => {}}><div className="lds-ellipsis">- <div- style={{ backgroundColor: theme.palette.primary.main }}- ></div>- <div- style={{ backgroundColor: theme.palette.primary.main }}- ></div>- <div- style={{ backgroundColor: theme.palette.primary.main }}- ></div>- <div- style={{ backgroundColor: theme.palette.primary.main }}- ></div>+ <div style={{ backgroundColor: theme.palette.primary.main }} />+ <div style={{ backgroundColor: theme.palette.primary.main }} />+ <div style={{ backgroundColor: theme.palette.primary.main }} />+ <div style={{ backgroundColor: theme.palette.primary.main }} /></div></div>)}@@ -729,6 +723,7 @@ function mapStateToProps(state) {selectedEntries: getSelectedEntries(state),directoryContent: getDirectoryContent(state),currentDirectoryFiles: getCurrentDirectoryFiles(state),+ currentDirectoryDirs: getCurrentDirectoryDirs(state),currentDirectoryPerspective: getCurrentDirectoryPerspective(state),searchResultCount: getSearchResultCount(state),currentLocationPath: getCurrentLocationPath(state),diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex dcc570951..8a67f4ceb 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -284,10 +284,18 @@ export default (state: any = initialState, action: any) => {? action.directoryMeta.perspective: state.currentDirectoryPerspective,currentDirectoryPath: directoryPath,- // used for reorder files in KanBan+ /**+ * used for reorder files in KanBan+ */currentDirectoryFiles: action.directoryMeta? action.directoryMeta.files: [],+ /**+ * used for reorder dirs in KanBan+ */+ currentDirectoryDirs: action.directoryMeta+ ? action.directoryMeta.dirs+ : [],isLoading: action.showIsLoading || false};}@@ -2178,6 +2186,8 @@ export const getDirectoryContent = (state: any) =>state.app.currentDirectoryEntries;export const getCurrentDirectoryFiles = (state: any) =>state.app.currentDirectoryFiles;+export const getCurrentDirectoryDirs = (state: any) =>+ state.app.currentDirectoryDirs;export const getCurrentDirectoryColor = (state: any) =>state.app.currentDirectoryColor;export const getCurrentDirectoryDescription = (state: any) =>diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 51e2853c2..a3d76618b 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -335,6 +335,39 @@ export function prepareDirectoryContent();}+export function orderDirectories(directories, metaArray) {+ // if (sortBy === 'custom') {+ try {+ // const metaDirData = await loadMetaDataPromise(currentLocationPath);+ if (metaArray && metaArray.length > 0) {+ // return orderByMetaArray(directories, metaDirData.dirs);+ const arrLength = directories.length;+ return directories.sort((a, b) => {+ let indexA = metaArray.findIndex(+ meta => meta.path === a.path+ // meta => meta.path === Object.keys(a)[0]+ );+ let indexB = metaArray.findIndex(+ meta => meta.path === b.path+ // meta => meta.path === Object.keys(b)[0]+ );+ // set new dirs last+ if (indexA === -1) {+ indexA = arrLength;+ }+ if (indexB === -1) {+ indexB = arrLength;+ }+ return indexA - indexB;+ });+ }+ } catch (e) {+ console.log('error loadMetaDataPromise:', e);+ }+ // }+ return directories;+}+export function orderByMetaArray(arr, metaArray) {const arrLength = arr.length;return arr.sort((a, b) => {