Skip to content

Commit 496d17a

Browse files
adliusfuta-ikedabp-cos
authored
Feature/preprint details page (#2067)
* [ENG-4450] Add new share-search models (#1835) - Ticket: [ENG-4450] - Feature flag: n/a - Add new models needed for SHARE-powered search page - Add new models - `metadata-record-search` - `metadata-property-search` - `metadata-value-search` - `metadata-record` - `search-match` - New `ShareAdapter` and `ShareSerializer` to be used by these new models - New mirage endpoint for metadata-record-search (other endpoints coming later) * Add basic search page layout (#1850) * [ENG-4465] Left panel facets manager (#1858) - Ticket: [ENG-4465] [ENG-4466] - Feature flag: n/a - Add logic to search page controller to handle active filters and list of filterable properties - Add a component to handle fetching values in a filterable properties in the search page - Add a `filter-facet` component - takes care of fetching filterable property values - `See more` modal * [ENG-4469] Add object filter and sort dropdown to search (#1864) - Ticket: [ENG-4469] - Feature flag: n/a - Add object type filter and sort dropdown to search page - Add tabs to filter by object type (All, Projects, Registrations, Preprints, Files, Users) - Add dropdown to sort results by Relevance, Date modified/created ascending and descending - Change model names to reflect more library-analogy based names - Change how metadata properties are fetched from SHARE models * [No ticket] Update SHARE endpoints (#1879) - Ticket: [No ticket] - Feature flag: n/a - Update SHAREAdapter to point to correct locations - Update SHAREAdapter parent class to point use config variable for share-url - Update SHAREAdapter parent class to point use api/v3 endpoints - Update search-related adapters to point to singularized endpoint names (e.g. api/v3/index-card-search**es** -> api/v3/index-card-search - Update mirage endpoints to reflect these changes * [ENG-4568] Componentize search page (#1886) - Ticket: [ENG-4568] - Feature flag: n/a - Componentize search page for reuse in branded pages - Move logic and templating from search page route to `search-page` component - No logic for branding and default query-params yet in this PR * [ENG-4574] Preprint discover rewrite (#1896) * add brand relationship to preprint provider model (#1887) * Remove unused services from search controller * Use search-page component on preprint discover page * Modifiy branded-navbar for preprints * Error handling and theme resetting * Branded preprint discover part 1 * Branded preprint discover part 2 * Test prerpint discover page * Group CR feedback re: search-page component arguments * Fix test --------- Co-authored-by: Yuhuai Liu <[email protected]> * [ENG-4573] Registry discover (#1900) * preliminary * moar * some more * delete unused components * remove top-level aggregate registries discover route * remove top-level registries discover route cont. * remove unused action and variable on registries application route * remove aggregate registries discover page tests * fix tests * remove discover-test.ts * CR followup * [ENG-4574] Preprint discover fixes (#1905) - Ticket: [ENG-4574] - Feature flag: n/a - Add appropriate page title to discover page - Add appropriate analytics scope to discover page - Make provider description now show html entities - Use `{{html-safe}}` when showing provider description - Add `providerTitle` in preprint-provider model - Most branded providers should show their name with their preprint word (e.g. AfricaRxiv Preprints, MarXiv Papers), except Thesis Commons - If it's OSF, we just show "OSF Preprints" - Add page-title and analytics scope using the new `providerTitle` * [ENG-4535] Search help feature (#1907) - Ticket: [ENG-4535] - Feature flag: n/a - Add search help feature - Basically a re-implementation of #1891 and #1877 - Notable difference is moving the Popovers to the end of the file to avoid merge conflicts - Added EmberPopovers to the search-page component - Added getters to search-page component to fetch EmberPopover targets dynamically - Translations - Tests * [No Ticket] Change queryparam passed to SHARE when filtering by resourceType (#1915) * change queryparam passed to SHARE when filtering by resourceType * add types * add some more types * update tests * [No ticket] Preprint branding rework (#1913) - Ticket: [] - Feature flag: n/a - Only rely on `brand` relationship for setting preprint colors - Use `brand.primaryColor` for branded navbar background color - Add styling if the brand's primaryColor does not provide sufficient contrast with white text - Add special-case for BioHackrXiv to change navbar color to white (their primary color would be white, but that creates problems for `<Button>` behavior, so their primary is black instead) - Use `brand.heroBackgroundImage` for hero banner background, as well as advisory board section when @brianpilati implements that page. Currently just a solid color - Use `brand.navbarLogoImage` for navbar logo if `preprintProvider.assets.square_color_transparent` is not defined - Update `<Button>` component to detect primary color and use white/black text depending on color contrast * Preprints branding update (#1922) - Ticket: [] - Feature flag: n/a ## Purpose - Remove possible failure point by not using preprintProvider.asset - Add special casing to address nutrixiv's navbar color https://osf.io/preprints/nutrixiv/ ## Summary of Changes - Remove use of ThemeStyles from preprint (this set the navbar logo to use the preprintProvider.asset. square_color_transparent, when we want to just use the brand. topnavLogoImage going forward) - Add special case for nutrixiv to use a white background similar to biohackrxiv * Test prerpint discover page * Group CR feedback re: search-page component arguments * Added new preprints index to the new branch * Added translation strings * Fixed a rebase * Rebase fix * Removed the add-ons and moved search-help-modal to osf-components * Fixed a merge conflict * Fixed a few git merge conflicts * Added more logic to get the page to render * Added the taxonomy top list component and integrated it into the index page * Updates to the preprints template file to remove bootstrap * Fixed the css for the taxonomy-top-list * Removed an unnecessary import for analytics * Added more information for the providers * Added the advisory board attribute * Finished the html transformation for preprints * Fixed the routing to use a single template * Updates to remove unused variables and added branding * Fixed the css for the steering committee * Updates for comments from PR * Fixed some css and updated the mirage for global classes * Updates for branding * Added more styling for mobile * Added more information for preprints * Added more information for the taxomony * Added a branded footer for preprints * Fixed the preprint provider logic ... again * Fixed the branded header search * Fixed the page title logic * Removed useless test * Move preprint specific components to the app/preprints/-components * Added taxonomy tests * Added another test * Added another test * Added additional tests for the branded header * Added Branded footer tests * Pruned an unused providerModel from the branded-header * Added more tests * Added a test file * Added the initial template and attempt to have it compiled * Added the controller and the styles -- first pass * Added a router and continued to clean-up the controller * Removed chronos * Fixed an the computed and actions * Cleaned-up computed method * Removed unused route code * Added routing and a factory to mirage for preprints * Fixed the routing, mirage and prototyped the model is working * Initial steps to update the template * mirage updates * Updated users to have html link * Added logic to have the contributors displayed using the pre-build component * Updates for preprint details * Added more details for the preprint details page * Added information for the primaryFile * Added the ability to display a pdf from a local assets * Finished the abstract section * Added the license information * Added some miscellaneous logic for licenses * Added original date published * Added tags to the preprint detail page * Added citations and a lot of stuff that I have no idea about without Futa * Added the preprint doi * Added the supplemental material * Added the download option, with metrics * Initial work on the social icons * Added the plaudit widget * Added the final touches for mobile views * Initial pass for withdrawn preprints * Initial commit for the preprint-status-banner component * Additional refactors to bring the ts file up-to-date with latest ember * Added a current state icon method * Refactored all the constants to be typescript compatible * Appears the preprint status banner will now compile * Fixed mirage logic and some refactors * Added more styling and translations * Added a bunch of serializer, mirage and scenario logic * Added a bunch of mirage love * Finished all the conditional statements for the details page * Fixing scenarios with contributors * Finished adding all the preprint checks * refactored the doi to be a stand-alone component * Renamed doi to be preprint-doi * Added the preprint-license * Added the tombstone page * Added the preprint disciplines component * pruned some code * Converted the preprint-tag page * added the tombstone component * Added the abstract component and refactored the tombstone and detail page * Added the initial author-assertions * Added the preprint assertion link * Fixed the css for author assertions, coi and data * Finished author assertion for pre registration links * Removed unecessary comments * Fixed a few issues recommended by Futa after the mega-merge * Fixed pagination for branded preprint provider, added a provider without an image for a use case that eric is presenting * Removed all the `import config from ember-get-config` * Removed some comments * Removed some commentted out router code * Defined the data-test * Removed a bootstrap and eslint-ignore * Removed comments * Removed an unnecessary max-len * Removed comments * Removed comments * Fixed a length and added an enum * Added enums to a model * Renamed a method * Removed a stale file * Refactor the brandedProvider store call * Refactored a template file * Pruned translation strings * Removed a comment * Enum name change * Updated the inverse to be target on preprint files * removed the preprint-tag/component * Removed the tombstone component * Changed String to string * Changed String to string - Part II * Refactored a string to be an enum * endingWithdrawal to pendingWithdrawal * Removed the preprint-assertion-link component * Removed the branded-footer component * Refactored some comments and enums * Added a better IRI based filter * Pruned unused code * Fixed a translation string name * Removed unnecessary branded navbar params * Fixed a return enum from the api * Moved old unused code * Added the metric start date to the controller and environment * Fixed an overly aggressive find/replace and commented out code * Fixed the query on the taxonomy-top-list component * fixed the belongsTo relationship on a file * made the branded header search placeholder dynamic * Removed the abstractDoi from the preprint doi url * Removed the abstractDoi from the article * Fixed the branded footer * Preprint review action prototype * Updated the reviewActions for the Preprint model * change LinkTo element parameter * fix branded header tests * fix taxonomy-top-list tests * fix branded header test * Updated the abstract template to use expandable-preview and removed the component * set inverse to null * Fixed build issues * fix preprint routing * attempt * try this * Removed the bibiliographic stuff and added feature switches for M1 chips * Better fix for adapters * Revert "Better fix for adapters" This reverts commit da03639. * Revert "Removed the bibiliographic stuff and added feature switches for M1 chips" This reverts commit 4344e41. * Remvoed bibliographicContributors * Fixed the edit link * Added the fix for the search button * Fixed the routing for osf and branded providers * Fixed an issue with theme.reset * Removed button * pruning code * Use gray background for preprint detail * Show preprint as active service * Use config for donate link * Add different set of navbar links for preprints * Fixed the routing for /preprints/<guid> * Fix for Yuhuai * Update for Yuhuai * Fixed the plaudit env variables * Fixed the branded footer link for preprints (#2059) * Added mobile logic to the author assetions * Fixed the styles for the status banner * Fixed the css will be non-biased * This did need a text-align: center * Allow provider-specfic default citation styles (#2056) * Fix branded navbar colors for mobile (#2060) * Fix branded navbar colors for mobile * Less whacky css rules * Fix link to my-preprints * Fixed a link * Fixed the logic for preprints with a coi of null * Preprint metadata (#2065) * Avoid double-loading citation fixture * Add logic to add metadata to head for preprint detail * Updates to fix the text on the branded search page * Move favicon logic to parent route * Fix copy-pasta * Lint --------- Co-authored-by: futa-ikeda <[email protected]> Co-authored-by: Futa Ikeda <[email protected]> Co-authored-by: Brian Pilati <[email protected]> Co-authored-by: Lord Business <[email protected]>
1 parent 59018e0 commit 496d17a

File tree

122 files changed

+4772
-464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+4772
-464
lines changed

app/config/environment.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface KeenConfig {
1818
}
1919

2020
declare const config: {
21+
WATER_BUTLER_ENABLED: boolean;
22+
plauditWidgetUrl: string,
2123
environment: any;
2224
lintOnBuild: boolean;
2325
testsEnabled: boolean;
@@ -68,6 +70,7 @@ declare const config: {
6870
apiVersion: string;
6971
apiHeaders: { [k: string]: string };
7072
learnMoreUrl: string;
73+
donateUrl: string;
7174
renderUrl: string;
7275
waterbutlerUrl: string;
7376
helpUrl: string;
@@ -77,6 +80,7 @@ declare const config: {
7780
devMode: boolean;
7881
cookieDomain: string;
7982
authenticator: string;
83+
metricsStartDate: string;
8084
cookies: {
8185
status: string;
8286
keenUserId: string;

app/institutions/discover/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
export default class InstitutionDiscoverController extends Controller {
1111
@service currentUser!: CurrentUser;
1212

13-
@tracked q?: string = '';
13+
@tracked cardSearchText?: string = '';
1414
@tracked sort?: string = '-relevance';
1515
@tracked resourceType: ResourceTypeFilterValue = ResourceTypeFilterValue.Projects;
1616
@tracked activeFilters?: Filter[] = [];

app/models/contributor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { not } from '@ember/object/computed';
33
import { buildValidations, validator } from 'ember-cp-validations';
44

55
import DraftRegistrationModel from './draft-registration';
6+
import PreprintModel from './preprint';
67
import NodeModel from './node';
78
import OsfModel, { Permission } from './osf-model';
89
import UserModel from './user';
@@ -53,6 +54,9 @@ export default class ContributorModel extends OsfModel.extend(Validations) {
5354
@belongsTo('node', { inverse: 'contributors', polymorphic: true })
5455
node!: AsyncBelongsTo<NodeModel> & NodeModel;
5556

57+
@belongsTo('preprint', { inverse: 'contributors'})
58+
preprint!: AsyncBelongsTo<PreprintModel> & PreprintModel;
59+
5660
@belongsTo('draft-registration', { inverse: 'contributors' })
5761
draftRegistration!: AsyncBelongsTo<DraftRegistrationModel> & DraftRegistrationModel;
5862

app/models/file-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class FileProviderModel extends BaseFileItem {
1919
@belongsTo('base-file-item', { polymorphic: true })
2020
rootFolder!: AsyncBelongsTo<FileModel> & FileModel;
2121

22-
@hasMany('file', { polymorphic: true })
22+
@hasMany('file', { inverse:'parentFolder', polymorphic: true })
2323
files!: AsyncHasMany<FileModel>;
2424

2525
@belongsTo('abstract-node', { inverse: 'files', polymorphic: true })

app/models/file.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Link } from 'jsonapi-typescript';
55
import { FileReference } from 'ember-osf-web/packages/registration-schema';
66
import getHref from 'ember-osf-web/utils/get-href';
77

8+
import PreprintModel from 'ember-osf-web/models/preprint';
89
import AbstractNodeModel from './abstract-node';
910
import BaseFileItem, { BaseFileLinks } from './base-file-item';
1011
import CommentModel from './comment';
@@ -56,8 +57,9 @@ export default class FileModel extends BaseFileItem {
5657
@hasMany('comment', { inverse: null })
5758
comments!: AsyncHasMany<CommentModel>;
5859

59-
@belongsTo('abstract-node', { polymorphic: true })
60-
target!: (AsyncBelongsTo<AbstractNodeModel> & AbstractNodeModel) | (AsyncBelongsTo<DraftNode> & DraftNode);
60+
@belongsTo('osf-model', { polymorphic: true })
61+
// eslint-disable-next-line max-len
62+
target!: (AsyncBelongsTo<AbstractNodeModel> & AbstractNodeModel) | (AsyncBelongsTo<PreprintModel> & PreprintModel) | (AsyncBelongsTo<DraftNode> & DraftNode);
6163

6264
// BaseFileItem override
6365
isFileModel = true;

app/models/preprint-provider.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const { defaultProvider } = config;
1818
export default class PreprintProviderModel extends ProviderModel {
1919
@service intl!: Intl;
2020

21+
@attr('fixstring') email_support!: string | null;
2122
@attr('array') subjectsAcceptable!: string[];
2223
@attr('array') additionalProviders!: string[];
2324
@attr('string') shareSource!: string;
@@ -52,23 +53,29 @@ export default class PreprintProviderModel extends ProviderModel {
5253
};
5354
}
5455

56+
get searchPlaceholder(): string {
57+
return this.intl.t('preprints.header.search_placeholder',
58+
{ placeholder: this.documentType.plural});
59+
}
60+
5561
@computed('id')
56-
get preprintWordInTitle() {
57-
return this.id !== 'thesiscommons';
62+
get preprintWordNotInTitle() {
63+
return this.id === 'thesiscommons';
5864
}
5965

6066
// Is either OSF Preprints if provider is the default provider,
6167
// name+preprintWord.pluralCapitalized(e.g.AfricArXiv Preprints or MarXiv Papers), or "Thesis Commons"
62-
@computed('documentType.pluralCapitalized', 'id', 'name', 'preprintWordInTitle')
68+
@computed('documentType.pluralCapitalized', 'id', 'name', 'preprintWordNotInTitle')
6369
get providerTitle() {
6470
if (this.id !== defaultProvider) {
65-
if (this.preprintWordInTitle) {
66-
return this.intl.t('preprints.provider-title',
67-
{ name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized });
71+
if (this.preprintWordNotInTitle) {
72+
return this.name;
6873
}
69-
return this.name;
74+
return this.intl.t('preprints.provider-title',
75+
{ name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized });
76+
} else {
77+
return this.intl.t('preprints.header.osf_preprints');
7078
}
71-
return this.intl.t('preprints.osf-title');
7279
}
7380
}
7481

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { AsyncBelongsTo, attr, belongsTo } from '@ember-data/model';
2+
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
3+
import UserModel from 'ember-osf-web/models/user';
4+
5+
import OsfModel from './osf-model';
6+
7+
8+
export enum PreprintRequestActionTriggerEnum {
9+
SUBMIT= 'submit',
10+
ACCEPT = 'accept',
11+
REJECT = 'reject',
12+
}
13+
14+
export default class PreprintRequestActionModel extends OsfModel {
15+
@attr('string') comment!: string;
16+
@attr('string') actionTrigger!: string;
17+
@attr('date') dateModified!: Date;
18+
@attr('boolean') auto!: boolean;
19+
20+
// Relationships
21+
@belongsTo('preprint-request', { inverse: 'actions' })
22+
target!: (AsyncBelongsTo<PreprintRequestModel> & PreprintRequestModel);
23+
24+
@belongsTo('user', { inverse: null, async: true })
25+
creator!: AsyncBelongsTo<UserModel> & UserModel;
26+
}
27+
28+
declare module 'ember-data/types/registries/model' {
29+
export default interface ModelRegistry {
30+
'preprint-request-action': PreprintRequestActionModel;
31+
} // eslint-disable-line semi
32+
}

app/models/preprint-request.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { AsyncBelongsTo, SyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model';
2+
import PreprintModel from 'ember-osf-web/models/preprint';
3+
import UserModel from 'ember-osf-web/models/user';
4+
import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action';
5+
6+
import OsfModel from './osf-model';
7+
8+
export enum PreprintRequestType{
9+
WITHDRAWAL = 'withdrawal',
10+
}
11+
12+
export enum PreprintRequestMachineState {
13+
PENDING = 'pending',
14+
ACCEPTED = 'accepted',
15+
REJECTED = 'rejected',
16+
}
17+
18+
export default class PreprintRequestModel extends OsfModel {
19+
@attr('string') comment!: string;
20+
@attr('date') dateLastTransitioned!: Date;
21+
@attr('date') created!: Date;
22+
@attr('date') modified!: Date;
23+
@attr('string') machineState!: string;
24+
@attr('string') requestType!: string;
25+
26+
@belongsTo('preprint', { inverse: 'requests'})
27+
target!: (AsyncBelongsTo<PreprintModel> & PreprintModel);
28+
29+
@belongsTo('user', { inverse: null, async: true })
30+
creator!: AsyncBelongsTo<UserModel> & UserModel;
31+
32+
@hasMany('preprint-request-action', { inverse: 'target'})
33+
actions!: SyncHasMany<PreprintRequestActionModel> & PreprintRequestActionModel;
34+
}
35+
36+
declare module 'ember-data/types/registries/model' {
37+
export default interface ModelRegistry {
38+
'preprint-request': PreprintRequestModel;
39+
} // eslint-disable-line semi
40+
}

app/models/preprint.ts

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,60 @@
1-
import { attr, belongsTo, hasMany, SyncHasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';
1+
import { attr, belongsTo, hasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';
22
import { computed } from '@ember/object';
33
import { alias } from '@ember/object/computed';
4+
import CitationModel from 'ember-osf-web/models/citation';
5+
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
6+
import { ReviewsState } from 'ember-osf-web/models/provider';
7+
import ReviewActionModel from 'ember-osf-web/models/review-action';
48

59
import ContributorModel from './contributor';
610
import FileModel from './file';
711
import LicenseModel from './license';
812
import NodeModel from './node';
9-
import OsfModel from './osf-model';
13+
import OsfModel, { Permission } from './osf-model';
1014
import PreprintProviderModel from './preprint-provider';
11-
import ReviewActionModel from './review-action';
1215
import SubjectModel from './subject';
1316

17+
export enum PreprintDataLinksEnum {
18+
AVAILABLE = 'available',
19+
YES = 'yes',
20+
NO = 'no',
21+
NOT_APPLICABLE = 'not_applicable',
22+
}
23+
24+
export enum PreprintPreregLinksEnum {
25+
AVAILABLE = 'available',
26+
YES = 'yes',
27+
NO = 'no',
28+
NOT_APPLICABLE = 'not_applicable',
29+
}
30+
1431
export default class PreprintModel extends OsfModel {
1532
@attr('fixstring') title!: string;
1633
@attr('date') dateCreated!: Date;
1734
@attr('date') datePublished!: Date;
35+
@attr('date') dateWithdrawn!: Date;
1836
@attr('date') originalPublicationDate!: Date | null;
1937
@attr('date') dateModified!: Date;
2038
@attr('fixstring') doi!: string | null;
39+
@attr('boolean') public!: boolean;
2140
@attr('boolean') isPublished!: boolean;
2241
@attr('boolean') isPreprintOrphan!: boolean;
2342
@attr('object') licenseRecord!: any;
24-
@attr('string') reviewsState!: string;
43+
@attr('string') reviewsState!: ReviewsState;
44+
@attr('string') description!: string;
2545
@attr('date') dateLastTransitioned!: Date;
2646
@attr('date') preprintDoiCreated!: Date;
47+
@attr('array') currentUserPermissions!: Permission[];
48+
@attr('fixstringarray') tags!: string[];
49+
@attr('fixstring') withdrawalJustification! : string;
50+
@attr('boolean') hasCoi!: boolean;
51+
@attr('string') hasDataLinks!: PreprintDataLinksEnum;
52+
@attr('string') hasPreregLinks!: PreprintPreregLinksEnum;
53+
@attr('string') conflictOfInterestStatement!: string;
54+
@attr('array') dataLinks!: string[];
55+
@attr('array') preregLinks!: string[];
56+
@attr('string') whyNoData!: string;
57+
@attr('string') whyNoPrereg!: string;
2758

2859
@belongsTo('node', { inverse: 'preprints' })
2960
node!: AsyncBelongsTo<NodeModel> & NodeModel;
@@ -37,18 +68,34 @@ export default class PreprintModel extends OsfModel {
3768
@belongsTo('preprint-provider', { inverse: 'preprints' })
3869
provider!: AsyncBelongsTo<PreprintProviderModel> & PreprintProviderModel;
3970

40-
@hasMany('review-action', { inverse: 'target' })
71+
@hasMany('review-action')
4172
reviewActions!: AsyncHasMany<ReviewActionModel>;
4273

43-
@hasMany('contributor')
44-
contributors!: AsyncHasMany<ContributorModel>;
74+
@hasMany('files', { inverse: 'target'})
75+
files!: AsyncHasMany<FileModel> & FileModel;
76+
77+
@hasMany('contributors', { inverse: 'preprint'})
78+
contributors!: AsyncHasMany<ContributorModel> & ContributorModel;
4579

46-
@hasMany('subject', { inverse: null, async: false })
47-
subjects!: SyncHasMany<SubjectModel>;
80+
@hasMany('contributor', { inverse: null })
81+
bibliographicContributors!: AsyncHasMany<ContributorModel>;
82+
83+
@belongsTo('citation', { inverse: null })
84+
citation!: AsyncBelongsTo<CitationModel>;
85+
86+
@hasMany('subject', { inverse: null})
87+
subjects!: AsyncHasMany<SubjectModel>;
88+
89+
@hasMany('preprint-request', { inverse: 'target'})
90+
requests!: AsyncHasMany<PreprintRequestModel>;
4891

4992
@alias('links.doi') articleDoiUrl!: string | null;
5093
@alias('links.preprint_doi') preprintDoiUrl!: string;
5194

95+
get isWithdrawn(): boolean{
96+
return this.dateWithdrawn !== null;
97+
}
98+
5299
@computed('license', 'licenseRecord')
53100
get licenseText(): string {
54101
const text = this.license.get('text') || '';

app/models/provider.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { attr, hasMany, SyncHasMany, AsyncHasMany } from '@ember-data/model';
22
import { computed } from '@ember/object';
33

4+
import CitationStyleModel from './citation-style';
45
import LicenseModel from './license';
56
import ModeratorModel from './moderator';
67
import OsfModel from './osf-model';
@@ -20,6 +21,21 @@ export interface Assets {
2021
wide_white: string;
2122
}
2223

24+
export enum PreprintProviderReviewsWorkFlow{
25+
PRE_MODERATION = 'pre-moderation',
26+
POST_MODERATION = 'post-moderation'
27+
}
28+
29+
export enum ReviewsState {
30+
INITIAL = 'initial',
31+
PENDING = 'pending',
32+
ACCEPTED = 'accepted',
33+
REJECTED = 'rejected',
34+
PENDING_WITHDRAWAL = 'pendingWithdrawal',
35+
WITHDRAWAL_REJECTED = 'withdrawalRejected',
36+
WITHDRAWN = 'withdrawn',
37+
}
38+
2339
export enum ReviewPermissions {
2440
SetUpModeration = 'set_up_moderation',
2541
ViewSubmissions = 'view_submissions',
@@ -39,7 +55,6 @@ export enum ReviewPermissions {
3955
}
4056

4157
/* eslint-enable camelcase */
42-
4358
export default abstract class ProviderModel extends OsfModel {
4459
@attr('fixstring') name!: string;
4560
@attr('fixstring') description!: string;
@@ -54,7 +69,7 @@ export default abstract class ProviderModel extends OsfModel {
5469
@attr('boolean') allowCommenting!: boolean;
5570
@attr('boolean') allowUpdates!: boolean;
5671
@attr('array') permissions!: ReviewPermissions[];
57-
@attr('fixstring') reviewsWorkflow!: string | null;
72+
@attr('fixstring') reviewsWorkflow!: PreprintProviderReviewsWorkFlow | null;
5873
@attr('boolean') reviewsCommentsAnonymous!: boolean | null;
5974
@attr() assets?: Partial<Assets>; // TODO: camelize in transform
6075

@@ -70,6 +85,9 @@ export default abstract class ProviderModel extends OsfModel {
7085
@hasMany('moderator', { inverse: 'provider' })
7186
moderators!: AsyncHasMany<ModeratorModel> | ModeratorModel[];
7287

88+
@hasMany('citation-style', { inverse: null })
89+
citationStyles!: AsyncHasMany<CitationStyleModel> & CitationStyleModel[];
90+
7391
@computed('permissions')
7492
get currentUserCanReview() {
7593
if (this.permissions) {

0 commit comments

Comments
 (0)