Skip to content

Commit 70fc253

Browse files
committed
Add ability to sort by storageByteCount
1 parent 83c4a77 commit 70fc253

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

app/institutions/dashboard/-components/object-list/component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Filter } from 'osf-components/components/search-page/component';
99
interface Column {
1010
name: string;
1111
sortKey?: string;
12+
sortParam?: string;
1213
}
1314
interface ValueColumn extends Column {
1415
getValue(searchResult: SearchResultModel): string;
@@ -37,6 +38,7 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
3738
@tracked activeFilters: Filter[] = [];
3839
@tracked page = '';
3940
@tracked sort = '-dateModified';
41+
@tracked sortParam?: string;
4042
@tracked visibleColumns = this.args.columns.map(column => column.name);
4143
@tracked dirtyVisibleColumns = [...this.visibleColumns]; // track changes to visible columns before they are saved
4244

@@ -47,8 +49,8 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
4749
},
4850
'page[cursor]': this.page,
4951
'page[size]': 10,
50-
sort: this.sort,
51-
52+
// sort can look like `sort=dateFieldName` or `sort[integer-value]=fieldName` if sortParam is provided
53+
sort: this.sortParam ? { [this.sortParam]: this.sort } : this.sort,
5254
};
5355
const fullQueryOptions = this.activeFilters.reduce((acc, filter: Filter) => {
5456
const currentValue = acc.cardSearchFilter[filter.propertyPathKey];
@@ -94,7 +96,8 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
9496
}
9597

9698
@action
97-
updateSortKey(newSortKey: string) {
99+
updateSortKey(newSortKey: string, newSortParam?: string) {
100+
this.sortParam = newSortParam;
98101
if (this.sort === newSortKey) {
99102
this.sort = '-' + newSortKey;
100103
} else {

app/institutions/dashboard/-components/object-list/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ as |list|>
127127
{{#if column.sortKey}}
128128
<SortArrow
129129
@sortBy={{column.sortKey}}
130-
@sortAction={{queue (fn this.updateSortKey column.sortKey) (perform list.searchObjectsTask)}}
130+
@sortAction={{queue (fn this.updateSortKey column.sortKey column.sortParam) (perform list.searchObjectsTask)}}
131131
/>
132132
{{/if}}
133133
</span>

app/institutions/dashboard/projects/controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export default class InstitutionDashboardProjects extends Controller {
4848
const byteCount = getSingleOsfmapValue(searchResult.resourceMetadata, ['storageByteCount']);
4949
return byteCount ? humanFileSize(byteCount) : this.missingItemPlaceholder;
5050
},
51+
sortKey: 'storageByteCount',
52+
sortParam: 'integer-value',
5153
},
5254
{ // Contributor name + permissions
5355
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),

app/institutions/dashboard/registrations/controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export default class InstitutionDashboardRegistrations extends Controller {
4646
const byteCount = getSingleOsfmapValue(searchResult.resourceMetadata, ['storageByteCount']);
4747
return byteCount ? humanFileSize(byteCount) : this.missingItemPlaceholder;
4848
},
49+
sortKey: 'storageByteCount',
50+
sortParam: 'integer-value',
4951
},
5052
{ // Contributor name + permissions
5153
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),

0 commit comments

Comments
 (0)