Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert/restore old code #2476

Merged
merged 1 commit into from
Jan 16, 2025
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 @@ -24,8 +24,9 @@ module('Integration | institutions | dashboard | -components | object-list', hoo
const columns = [
{
name: 'Title',
sortKey: 'title',
isSortable: true,
getValue: () => 'Title of some object',
propertyPathKey: 'title',
},
{
name: 'Description',
Expand Down
17 changes: 14 additions & 3 deletions app/institutions/dashboard/-components/object-list/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ import Toast from 'ember-toastr/services/toast';
import Intl from 'ember-intl/services/intl';
import Store from '@ember-data/store';
import CurrentUser from 'ember-osf-web/services/current-user';
import {MessageTypeChoices} from 'ember-osf-web/models/user-message';
import {RequestTypeChoices} from 'ember-osf-web/models/node-request';
import { MessageTypeChoices } from 'ember-osf-web/models/user-message';
import { RequestTypeChoices } from 'ember-osf-web/models/node-request';

import config from 'ember-osf-web/config/environment';

const shareDownloadFlag = config.featureFlagNames.shareDownload;

interface Column {
name: string;
sortKey?: string;
isSortable?: boolean;
sortParam?: string;
propertyPathKey?: string;
}
interface ValueColumn extends Column {
getValue(searchResult: SearchResultModel): string;
Expand Down Expand Up @@ -116,6 +117,16 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
cardSearchUrl.searchParams.set('page[size]', '10000');
cardSearchUrl.searchParams.set('acceptMediatype', format);
cardSearchUrl.searchParams.set('withFileName', `${this.args.objectType}-search-results`);

const columnDownloadKeys = this.args.columns.map(column => {
if (column.propertyPathKey && this.visibleColumns.includes(column.name)) {
return column.propertyPathKey;
}
return null;
});
const { resourceType } = this.args.defaultQueryOptions.cardSearchFilter;

cardSearchUrl.searchParams.set(`fields[${resourceType}]`, columnDownloadKeys.filter(Boolean).join(','));
return cardSearchUrl.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ as |list|>
>
<span>
{{column.name}}
{{#if column.sortKey}}
{{#if column.isSortable}}
<SortArrow
@sortBy={{column.sortKey}}
@sortAction={{queue (fn this.updateSortKey column.sortKey column.sortParam) (perform list.searchObjectsTask)}}
@sortBy={{column.propertyPathKey}}
@sortAction={{queue (fn this.updateSortKey column.propertyPathKey column.sortParam) (perform list.searchObjectsTask)}}
/>
{{/if}}
</span>
Expand Down
16 changes: 12 additions & 4 deletions app/institutions/dashboard/preprints/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class InstitutionDashboardPreprints extends Controller {
type: 'link',
getHref: searchResult => searchResult.indexCard.get('osfIdentifier'),
getLinkText: searchResult => searchResult.displayTitle,
propertyPathKey: 'title',
},
{ // Link
name: this.intl.t('institutions.dashboard.object-list.table-headers.link'),
Expand All @@ -27,42 +28,49 @@ export default class InstitutionDashboardPreprints extends Controller {
{ // Date created
name: this.intl.t('institutions.dashboard.object-list.table-headers.created_date'),
getValue: searchResult => getSingleOsfmapValue(searchResult.resourceMetadata, ['dateCreated']),
sortKey: 'dateCreated',
isSortable: true,
propertyPathKey: 'dateCreated',
},
{ // Date modified
name: this.intl.t('institutions.dashboard.object-list.table-headers.modified_date'),
getValue: searchResult => getSingleOsfmapValue(searchResult.resourceMetadata, ['dateModified']),
sortKey: 'dateModified',
isSortable: true,
propertyPathKey: 'dateModified',
},
{ // DOI
name: this.intl.t('institutions.dashboard.object-list.table-headers.doi'),
type: 'doi',
propertyPathKey: 'sameAs',
},
{ // License
name: this.intl.t('institutions.dashboard.object-list.table-headers.license'),
getValue: searchResult => searchResult.license?.name || this.missingItemPlaceholder,
propertyPathKey: 'rights.name',
},
{ // Contributor name + permissions
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),
type: 'contributors',
propertyPathKey: 'creator.name',
},
{ // View count
name: this.intl.t('institutions.dashboard.object-list.table-headers.view_count'),
getValue: searchResult => {
const metrics = searchResult.usageMetrics;
return metrics ? metrics.viewCount : this.missingItemPlaceholder;
},
sortKey: 'usage.viewCount',
isSortable: true,
sortParam: 'integer-value',
propertyPathKey: 'usage.viewCount',
},
{ // Download count
name: this.intl.t('institutions.dashboard.object-list.table-headers.download_count'),
getValue: searchResult => {
const metrics = searchResult.usageMetrics;
return metrics ? metrics.downloadCount : this.missingItemPlaceholder;
},
sortKey: 'usage.downloadCount',
isSortable: true,
sortParam: 'integer-value',
propertyPathKey: 'usage.downloadCount',
},
];

Expand Down
21 changes: 17 additions & 4 deletions app/institutions/dashboard/projects/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class InstitutionDashboardProjects extends Controller {
type: 'link',
getHref: searchResult => searchResult.indexCard.get('osfIdentifier'),
getLinkText: searchResult => searchResult.displayTitle,
propertyPathKey: 'title',
},
{ // Link
name: this.intl.t('institutions.dashboard.object-list.table-headers.link'),
Expand All @@ -27,55 +28,65 @@ export default class InstitutionDashboardProjects extends Controller {
{ // Date created
name: this.intl.t('institutions.dashboard.object-list.table-headers.created_date'),
getValue: searchResult => getSingleOsfmapValue(searchResult.resourceMetadata, ['dateCreated']),
sortKey: 'dateCreated',
propertyPathKey: 'dateCreated',
isSortable: true,
},
{ // Date modified
name: this.intl.t('institutions.dashboard.object-list.table-headers.modified_date'),
getValue: searchResult => getSingleOsfmapValue(searchResult.resourceMetadata, ['dateModified']),
sortKey: 'dateModified',
propertyPathKey: 'dateModified',
isSortable: true,
},
{ // DOI
name: this.intl.t('institutions.dashboard.object-list.table-headers.doi'),
type: 'doi',
propertyPathKey: 'sameAs',
},
{ // Storage location
name: this.intl.t('institutions.dashboard.object-list.table-headers.storage_location'),
getValue: searchResult => searchResult.storageRegion,
propertyPathKey: 'storageRegion.prefLabel',
},
{ // Total data stored
name: this.intl.t('institutions.dashboard.object-list.table-headers.total_data_stored'),
getValue: searchResult => {
const byteCount = getSingleOsfmapValue(searchResult.resourceMetadata, ['storageByteCount']);
return byteCount ? humanFileSize(byteCount) : this.missingItemPlaceholder;
},
sortKey: 'storageByteCount',
isSortable: true,
sortParam: 'integer-value',
propertyPathKey: 'storageByteCount',
},
{ // Contributor name + permissions
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),
type: 'contributors',
propertyPathKey: 'creator.name',
},
{ // View count
name: this.intl.t('institutions.dashboard.object-list.table-headers.view_count'),
getValue: searchResult => {
const metrics = searchResult.usageMetrics;
return metrics ? metrics.viewCount : this.missingItemPlaceholder;
},
sortKey: 'usage.viewCount',
isSortable: true,
sortParam: 'integer-value',
propertyPathKey: 'usage.viewCount',
},
{ // Resource type
name: this.intl.t('institutions.dashboard.object-list.table-headers.resource_nature'),
getValue: searchResult => searchResult.resourceNature || this.missingItemPlaceholder,
propertyPathKey: 'resourceNature.displayLabel',
},
{ // License
name: this.intl.t('institutions.dashboard.object-list.table-headers.license'),
getValue: searchResult => searchResult.license?.name || this.missingItemPlaceholder,
propertyPathKey: 'rights.name',
},
{ // addons associated
name: this.intl.t('institutions.dashboard.object-list.table-headers.addons'),
getValue: searchResult => searchResult.configuredAddonNames.length ? searchResult.configuredAddonNames :
this.missingItemPlaceholder,
propertyPathKey: 'hasOsfAddon.prefLabel',
},
{ // Funder name
name: this.intl.t('institutions.dashboard.object-list.table-headers.funder_name'),
Expand All @@ -85,6 +96,8 @@ export default class InstitutionDashboardProjects extends Controller {
}
return searchResult.funders.map((funder: { name: string }) => funder.name).join(', ');
},
propertyPathKey: 'funder.name',

},
];

Expand Down
20 changes: 16 additions & 4 deletions app/institutions/dashboard/registrations/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class InstitutionDashboardRegistrations extends Controller {
type: 'link',
getHref: searchResult => searchResult.indexCard.get('osfIdentifier'),
getLinkText: searchResult => searchResult.displayTitle,
propertyPathKey: 'title',
},
{ // Link
name: this.intl.t('institutions.dashboard.object-list.table-headers.link'),
Expand All @@ -26,50 +27,59 @@ export default class InstitutionDashboardRegistrations extends Controller {
{ // Date created
name: this.intl.t('institutions.dashboard.object-list.table-headers.created_date'),
getValue: searchResult => getSingleOsfmapValue(searchResult.resourceMetadata, ['dateCreated']),
sortKey: 'dateCreated',
isSortable: true,
propertyPathKey: 'dateCreated',
},
{ // Date modified
name: this.intl.t('institutions.dashboard.object-list.table-headers.modified_date'),
getValue: searchResult => getSingleOsfmapValue(searchResult.resourceMetadata, ['dateModified']),
sortKey: 'dateModified',
isSortable: true,
propertyPathKey: 'dateModified',
},
{ // DOI
name: this.intl.t('institutions.dashboard.object-list.table-headers.doi'),
type: 'doi',
propertyPathKey: 'sameAs',
},
{ // Storage location
name: this.intl.t('institutions.dashboard.object-list.table-headers.storage_location'),
getValue: searchResult => searchResult.storageRegion,
propertyPathKey: 'storageRegion.prefLabel',
},
{ // Total data stored
name: this.intl.t('institutions.dashboard.object-list.table-headers.total_data_stored'),
getValue: searchResult => {
const byteCount = getSingleOsfmapValue(searchResult.resourceMetadata, ['storageByteCount']);
return byteCount ? humanFileSize(byteCount) : this.missingItemPlaceholder;
},
sortKey: 'storageByteCount',
isSortable: true,
sortParam: 'integer-value',
propertyPathKey: 'storageByteCount',
},
{ // Contributor name + permissions
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),
type: 'contributors',
propertyPathKey: 'creator.name',
},
{ // View count
name: this.intl.t('institutions.dashboard.object-list.table-headers.view_count'),
getValue: searchResult => {
const metrics = searchResult.usageMetrics;
return metrics ? metrics.viewCount : this.missingItemPlaceholder;
},
sortKey: 'usage.viewCount',
isSortable: true,
sortParam: 'integer-value',
propertyPathKey: 'usage.viewCount',
},
{ // Resource type
name: this.intl.t('institutions.dashboard.object-list.table-headers.resource_nature'),
getValue: searchResult => searchResult.resourceNature || this.missingItemPlaceholder,
propertyPathKey: 'resourceNature.displayLabel',
},
{ // License
name: this.intl.t('institutions.dashboard.object-list.table-headers.license'),
getValue: searchResult => searchResult.license?.name || this.missingItemPlaceholder,
propertyPathKey: 'rights.name',
},
{ // Funder name
name: this.intl.t('institutions.dashboard.object-list.table-headers.funder_name'),
Expand All @@ -79,10 +89,12 @@ export default class InstitutionDashboardRegistrations extends Controller {
}
return searchResult.funders.map((funder: { name: string }) => funder.name).join(', ');
},
propertyPathKey: 'funder.name',
},
{ // schema
name: this.intl.t('institutions.dashboard.object-list.table-headers.registration_schema'),
getValue: searchResult => searchResult.registrationTemplate,
propertyPathKey: 'conformsTo.title',
},
];

Expand Down
Loading