1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00

Merge pull request #3573 from haiwen/sort_size

Sort size
This commit is contained in:
Daniel Pan
2019-05-31 20:37:20 +08:00
committed by GitHub
11 changed files with 80 additions and 10 deletions

View File

@@ -134,6 +134,13 @@ class DirentListView extends React.Component {
this.props.sortItems(sortBy, sortOrder);
}
sortBySize = (e) => {
e.preventDefault();
const sortBy = 'size';
const sortOrder = this.props.sortOrder == 'asc' ? 'desc' : 'asc';
this.props.sortItems(sortBy, sortOrder);
}
// for image popup
prepareImageItem = (item) => {
const useThumbnail = !this.repoEncrypted;
@@ -580,6 +587,7 @@ class DirentListView extends React.Component {
// sort
const sortByName = sortBy == 'name';
const sortByTime = sortBy == 'time';
const sortBySize = sortBy == 'size';
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
return (
@@ -604,7 +612,7 @@ class DirentListView extends React.Component {
<th width="39%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
<th width="6%">{/*tag */}</th>
<th width="18%">{/*operation */}</th>
<th width="11%">{gettext('Size')}</th>
<th width="11%"><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {sortBySize && sortIcon}</a></th>
<th width="15%"><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
</tr>
</thead>

View File

@@ -42,10 +42,18 @@ class SharedRepoListView extends React.Component {
this.props.sortItems(sortBy, sortOrder);
}
sortBySize = (e) => {
e.preventDefault();
const sortBy = 'size';
const sortOrder = this.props.sortOrder == 'asc' ? 'desc' : 'asc';
this.props.sortItems(sortBy, sortOrder);
}
getSortMetaData = () => {
return {
sortByName: this.props.sortBy == 'name',
sortByTime: this.props.sortBy == 'time',
sortBySize: this.props.sortBy == 'size',
sortIcon: this.props.sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>
};
}
@@ -98,7 +106,7 @@ class SharedRepoListView extends React.Component {
renderPCUI = () => {
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
const { sortByName, sortByTime, sortIcon } = this.getSortMetaData();
const { sortByName, sortByTime, sortBySize, sortIcon } = this.getSortMetaData();
return (
<table className={isShowTableThread ? '' : 'table-thead-hidden'}>
@@ -108,7 +116,7 @@ class SharedRepoListView extends React.Component {
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
<th width="36%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
<th width="12%"><span className="sr-only">{gettext('Actions')}</span></th>
<th width={'14%'}>{gettext('Size')}</th>
<th width={'14%'}><a className="d-block table-sort-op" href="#" onClick={this.sortBySize}>{gettext('Size')} {sortBySize && sortIcon}</a></th>
<th width={'14%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>
<th width="16%">{gettext('Owner')}</th>
</tr>