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 @@ -71,7 +71,7 @@ module('Integration | institutions | dashboard | -components | object-list', hoo
assert.dom('[data-test-page-tab="summary"]').exists('Summary tab exists');

// Elements in the top bar are present
assert.dom('[data-test-object-count]').containsText('10 total thingies', 'Object count is correct');
assert.dom('[data-test-object-count]').containsText('10,000+ total thingies', 'Object count is correct');
assert.dom('[data-test-toggle-filter-button]').exists('Filter button exists');
assert.dom('[data-test-customize-columns-button]').exists('Columns button exists');

Expand Down
16 changes: 13 additions & 3 deletions app/models/index-card-search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { inject as service } from '@ember/service';
import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model';
import {Links} from 'jsonapi-typescript';
import Intl from 'ember-intl/services/intl';

import RelatedPropertyPathModel from './related-property-path';
import SearchResultModel from './search-result';
Expand All @@ -10,12 +12,12 @@ export interface SearchFilter {
filterType?: string;
}

export const ShareMoreThanTenThousand = 'trove:ten-thousands-and-more';

export default class IndexCardSearchModel extends Model {
@service intl!: Intl;

@attr('string') cardSearchText!: string;
@attr('array') cardSearchFilters!: SearchFilter[];
@attr('string') totalResultCount!: number | typeof ShareMoreThanTenThousand;
@attr totalResultCount!: number | object;
@attr('object') links!: Links;

@hasMany('search-result', { inverse: null })
Expand Down Expand Up @@ -47,6 +49,14 @@ export default class IndexCardSearchModel extends Model {
}
return null;
}

get displayCount(): number | string {
return (
typeof this.totalResultCount === 'number'
? this.totalResultCount
: this.intl.t('search.ten-thousand-plus')
);
}
}

declare module 'ember-data/types/registries/model' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class IndexCardSearcher extends Component<IndexCardSearcherArgs>
debounceTime = this.args.debounceTime || 1000;

@tracked searchResults: SearchResultModel[] = [];
@tracked totalResultCount = 0;
@tracked totalResultCount: number | string = 0;

@tracked relatedProperties?: RelatedPropertyPathModel[] = [];
@tracked booleanFilters?: RelatedPropertyPathModel[] = [];
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class IndexCardSearcher extends Component<IndexCardSearcherArgs>
this.nextPageCursor = searchResult.nextPageCursor;
this.prevPageCursor = searchResult.prevPageCursor;
this.searchResults = searchResult.searchResultPage.toArray();
this.totalResultCount = searchResult.totalResultCount;
this.totalResultCount = searchResult.displayCount;

return searchResult;
} catch (error) {
Expand Down
6 changes: 2 additions & 4 deletions lib/osf-components/addon/components/search-page/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Store from '@ember-data/store';
import { action } from '@ember/object';
import Media from 'ember-responsive';

import { ShareMoreThanTenThousand } from 'ember-osf-web/models/index-card-search';
import InstitutionModel from 'ember-osf-web/models/institution';
import SearchResultModel from 'ember-osf-web/models/search-result';
import ProviderModel from 'ember-osf-web/models/provider';
Expand Down Expand Up @@ -83,7 +82,7 @@ export default class SearchPage extends Component<SearchArgs> {
@tracked relatedProperties?: RelatedPropertyPathModel[] = [];
@tracked booleanFilters?: RelatedPropertyPathModel[] = [];
@tracked page?: string = '';
@tracked totalResultCount?: number | {'@id': string};
@tracked totalResultCount?: number | string;
@tracked firstPageCursor?: string | null;
@tracked prevPageCursor?: string | null;
@tracked nextPageCursor?: string | null;
Expand Down Expand Up @@ -263,8 +262,7 @@ export default class SearchPage extends Component<SearchArgs> {
this.nextPageCursor = searchResult.nextPageCursor;
this.prevPageCursor = searchResult.prevPageCursor;
this.searchResults = searchResult.searchResultPage.toArray();
this.totalResultCount = searchResult.totalResultCount?.['@id'] === ShareMoreThanTenThousand ? '10,000+' :
searchResult.totalResultCount;
this.totalResultCount = searchResult.displayCount;
} catch (e) {
this.toast.error(e);
}
Expand Down
2 changes: 1 addition & 1 deletion mirage/views/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export function cardSearch(_: Schema, request: Request) {
],
},
],
totalResultCount: 10,
totalResultCount: {'@id': 'trove:ten-thousands-and-more'},
},
relationships: {
relatedProperties: {
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ search:
search-help-label: 'Help tutorial'
total-results: '{count} {count, plural, one {result} other {results} }'
no-results: 'No results found'
ten-thousand-plus: '10,000+'
resource-type:
search-by: 'Search by object type'
all: 'All'
Expand Down