diff options
Diffstat (limited to 'app/client/common/fileList.component.js')
| -rw-r--r-- | app/client/common/fileList.component.js | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index b71faae..f932274 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -11,18 +11,24 @@ export const FileList = props => { const { files, fields, sort, title, - linkFiles, onClick, onDelete, + linkFiles, + onClick, onClickParent, onDelete, + groupDirectories, parentDirectory, orderBy='name asc', className='', fileListClassName='filelist', rowClassName='row file' } = props const { mapFn, sortFn } = util.sort.orderByFn(orderBy) - const fileList = (files || []) + let sortedFiles = (files || []) .filter(f => !!f) .map(mapFn) .sort(sortFn) - .map(pair => { + if (groupDirectories) { + const groupedFiles = sortedFiles.reduce((a,b) => { a[b[1].dir].push(b); return a }, { true: [], false: [] }) + sortedFiles = groupedFiles.true.concat(groupedFiles.false) + } + const fileList = sortedFiles.map(pair => { return <FileRow file={pair[1]} fields={fieldSet(fields)} @@ -35,8 +41,8 @@ export const FileList = props => { if (!fileList || !fileList.length) { return ( <div className={'rows ' + className}> - <div class='row heading'> - <h4 class='noFiles'>No files</h4> + <div className='row heading'> + <h4 className='noFiles'>No files</h4> </div> </div> ) @@ -45,12 +51,21 @@ export const FileList = props => { return ( <div className={'rows ' + className}> {title && - <div class='row heading'> + <div className='row heading'> <h3>{title}</h3>} </div> } <div className={'rows ' + fileListClassName}> + {parentDirectory && + <div className={rowClassName + ' parent'}> + <div className="filename" title="Parent Directory"> + <span className='link' onClick={(e) => onClickParent && onClickParent(e)}> + <i>Parent Directory</i> + </span> + </div> + </div> + } {fileList} </div> </div> @@ -83,14 +98,14 @@ export const FileRow = props => { } return ( - <div class={className} key={key}> + <div className={className} key={key}> {fields.has('name') && <div className="filename" title={file.name || file.url}> {file.persisted === false ? <span className='unpersisted'>{name}</span> : (linkFiles && file.url) ? <a target='_blank' onClick={(e) => { if (!(e.metaKey || e.ctrlKey || e.altKey) && onClick) { e.preventDefault(); onClick && onClick(file, e) }}} href={file.url}>{name}</a> - : <span class='link' onClick={(e) => onClick && onClick(file, e)}>{name}</span> + : <span className='link' onClick={(e) => onClick && onClick(file, e)}>{name}</span> } </div> } |
