Skip to content

Commit 7026d65

Browse files
authored
Merge pull request #2306 from uditijmehta/preprints-paginated-list
[ENG-6010] Paginated list of public preprints
2 parents 9330ce6 + 7360de3 commit 7026d65

File tree

6 files changed

+45
-13
lines changed

6 files changed

+45
-13
lines changed

app/preprints/-components/preprint-card/styles.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
display: block;
1212
padding: 10px 15px;
1313
margin-bottom: -1px;
14-
background-color: #fff;
15-
border: 1px solid #ddd;
1614

1715
.heading {
1816
display: flex;

app/preprints/my-preprints/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import Route from '@ember/routing/route';
22
import requireAuth from 'ember-osf-web/decorators/require-auth';
33
import { inject as service } from '@ember/service';
44
import Store from '@ember-data/store';
5+
import CurrentUser from 'ember-osf-web/services/current-user';
56

67
@requireAuth()
78
export default class PreprintsMyPreprintsRoute extends Route {
89
@service store!: Store;
10+
@service currentUser!: CurrentUser;
911

1012
async model() {
11-
const preprints = await this.store.findAll('preprint');
12-
return preprints;
13+
return this.currentUser.user;
1314
}
1415
}

app/preprints/my-preprints/styles.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@
6161
padding-top: 85px;
6262
padding-bottom: 85px;
6363
}
64+
65+
.SortDescription {
66+
text-align: right;
67+
margin-top: 10px;
68+
margin-right: 15px;
69+
}
Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{page-title (t 'preprints.my_preprints.header')}}
22

33
<OsfLayout @backgroundClass='{{local-class 'ContentBackground'}}' as |layout|>
4-
<layout.heading local-class = 'Hero'>
4+
<layout.heading local-class='Hero'>
55
<div local-class='Title'>
66
<h1>
77
{{t 'preprints.my_preprints.header'}}
@@ -10,9 +10,32 @@
1010
</layout.heading>
1111
<layout.main>
1212
<div local-class='GutterBody'>
13-
{{#each this.model as |preprint|}}
14-
<Preprints::-Components::PreprintCard @preprint={{preprint}} />
15-
{{/each}}
13+
<div data-test-my-preprints-sort-description local-class='SortDescription'>
14+
{{t 'preprints.my_preprints.sorted'}}
15+
</div>
16+
<ContentPlaceholders as |placeholder|>
17+
<PaginatedList::HasMany
18+
@model={{this.model}}
19+
@relationshipName='preprints'
20+
@pageSize={{10}}
21+
@usePlaceholders={{false}}
22+
as |list|
23+
>
24+
<list.item as |preprint|>
25+
{{#if preprint}}
26+
<Preprints::-Components::PreprintCard @preprint={{preprint}} />
27+
{{else}}
28+
{{placeholder.text lines=1}}
29+
{{/if}}
30+
</list.item>
31+
32+
<list.empty local-class='FlexContainer'>
33+
<div local-class='NoContentContainer'>
34+
<p>{{t 'preprints.noPreprints'}}</p>
35+
</div>
36+
</list.empty>
37+
</PaginatedList::HasMany>
38+
</ContentPlaceholders>
1639
</div>
1740
</layout.main>
1841
</OsfLayout>

mirage/factories/preprint.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Factory, Trait, trait } from 'ember-cli-mirage';
1+
import { Factory, ModelInstance, Trait, trait } from 'ember-cli-mirage';
22
import faker from 'faker';
33
import { ReviewActionTrigger } from 'ember-osf-web/models/review-action';
44

55
import PreprintModel from 'ember-osf-web/models/preprint';
66
import { Permission } from 'ember-osf-web/models/osf-model';
77
import { ReviewsState } from 'ember-osf-web/models/provider';
8-
8+
import UserModel from 'ember-osf-web/models/user';
99
import { guid, guidAfterCreate} from './utils';
1010

1111
function buildLicenseText(): string {
@@ -170,11 +170,14 @@ export default Factory.extend<PreprintMirageModel & PreprintTraits>({
170170

171171
isContributor: trait<PreprintModel>({
172172
afterCreate(preprint, server) {
173-
const { currentUserId } = server.schema.roots.first();
174-
server.create('contributor', {
173+
const contributors = preprint.contributors.models;
174+
const firstContributor = server.create('contributor', {
175175
preprint,
176-
id: currentUserId,
176+
index:0,
177+
users: server.schema.roots.first().currentUser as ModelInstance<UserModel>,
177178
});
179+
contributors.splice(0,1,firstContributor);
180+
preprint.update({ contributors, bibliographicContributors:contributors });
178181
},
179182
}),
180183

translations/en-us.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,7 @@ preprints:
14341434
paragraph: 'Our advisory group includes leaders in preprints and scholarly communication'
14351435
my_preprints:
14361436
header: 'My Preprints'
1437+
sorted: 'Sorted by last updated'
14371438
preprint_card:
14381439
statuses:
14391440
pending: 'Pending'

0 commit comments

Comments
 (0)