summaryrefslogtreecommitdiff
path: root/app/client/common/fileList.component.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-09-21 22:50:33 +0200
committerJules Laplace <julescarbon@gmail.com>2018-09-21 22:50:33 +0200
commit10faab7941b28181c7647ff4e390ab651286bc32 (patch)
treeb0d71498d2a0649c7180940a38d2fbfa595ca515 /app/client/common/fileList.component.js
parent53ddf1651d649f65d92e12d36c003ff623226e34 (diff)
parent15d5cea9d1d94a6893ef1a55a916e68a182e5394 (diff)
merge
Diffstat (limited to 'app/client/common/fileList.component.js')
-rw-r--r--app/client/common/fileList.component.js31
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>
}