Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Filter } from 'osf-components/components/search-page/component';
interface Column {
name: string;
sortKey?: string;
sortParam?: string;
}
interface ValueColumn extends Column {
getValue(searchResult: SearchResultModel): string;
Expand Down Expand Up @@ -37,6 +38,7 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
@tracked activeFilters: Filter[] = [];
@tracked page = '';
@tracked sort = '-dateModified';
@tracked sortParam?: string;
@tracked visibleColumns = this.args.columns.map(column => column.name);
@tracked dirtyVisibleColumns = [...this.visibleColumns]; // track changes to visible columns before they are saved

Expand All @@ -47,8 +49,8 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
},
'page[cursor]': this.page,
'page[size]': 10,
sort: this.sort,

// sort can look like `sort=dateFieldName` or `sort[integer-value]=fieldName` if sortParam is provided
sort: this.sortParam ? { [this.sortParam]: this.sort } : this.sort,
Comment on lines +52 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's weird.

};
const fullQueryOptions = this.activeFilters.reduce((acc, filter: Filter) => {
const currentValue = acc.cardSearchFilter[filter.propertyPathKey];
Expand Down Expand Up @@ -94,7 +96,8 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
}

@action
updateSortKey(newSortKey: string) {
updateSortKey(newSortKey: string, newSortParam?: string) {
this.sortParam = newSortParam;
if (this.sort === newSortKey) {
this.sort = '-' + newSortKey;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ as |list|>
{{#if column.sortKey}}
<SortArrow
@sortBy={{column.sortKey}}
@sortAction={{queue (fn this.updateSortKey column.sortKey) (perform list.searchObjectsTask)}}
@sortAction={{queue (fn this.updateSortKey column.sortKey column.sortParam) (perform list.searchObjectsTask)}}
/>
{{/if}}
</span>
Expand Down
2 changes: 2 additions & 0 deletions app/institutions/dashboard/projects/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default class InstitutionDashboardProjects extends Controller {
const byteCount = getSingleOsfmapValue(searchResult.resourceMetadata, ['storageByteCount']);
return byteCount ? humanFileSize(byteCount) : this.missingItemPlaceholder;
},
sortKey: 'storageByteCount',
sortParam: 'integer-value',
},
{ // Contributor name + permissions
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),
Expand Down
2 changes: 2 additions & 0 deletions app/institutions/dashboard/registrations/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default class InstitutionDashboardRegistrations extends Controller {
const byteCount = getSingleOsfmapValue(searchResult.resourceMetadata, ['storageByteCount']);
return byteCount ? humanFileSize(byteCount) : this.missingItemPlaceholder;
},
sortKey: 'storageByteCount',
sortParam: 'integer-value',
},
{ // Contributor name + permissions
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),
Expand Down
Loading