Skip to content

Commit

Permalink
Feature/preprint details page (CenterForOpenScience#2067)
Browse files Browse the repository at this point in the history
* [ENG-4450] Add new share-search models (CenterForOpenScience#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 (CenterForOpenScience#1850)

* [ENG-4465] Left panel facets manager (CenterForOpenScience#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 (CenterForOpenScience#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 (CenterForOpenScience#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 (CenterForOpenScience#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 (CenterForOpenScience#1896)

* add brand relationship to preprint provider model (CenterForOpenScience#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 (CenterForOpenScience#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 (CenterForOpenScience#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 (CenterForOpenScience#1907)

-   Ticket: [ENG-4535]
-   Feature flag: n/a

- Add search help feature
  - Basically a re-implementation of CenterForOpenScience#1891 and CenterForOpenScience#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 (CenterForOpenScience#1915)

* change queryparam passed to SHARE when filtering by resourceType

* add types

* add some more types

* update tests

* [No ticket] Preprint branding rework (CenterForOpenScience#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 (CenterForOpenScience#1922)

-   Ticket: []
-   Feature flag: n/a

- Remove possible failure point by not using preprintProvider.asset
- Add special casing to address nutrixiv's navbar color https://osf.io/preprints/nutrixiv/

- 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 (CenterForOpenScience#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 (CenterForOpenScience#2056)

* Fix branded navbar colors for mobile (CenterForOpenScience#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 (CenterForOpenScience#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]>
  • Loading branch information
5 people committed Jan 31, 2024
1 parent b1e712e commit 5a96506
Show file tree
Hide file tree
Showing 122 changed files with 4,772 additions and 464 deletions.
4 changes: 4 additions & 0 deletions app/config/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface KeenConfig {
}

declare const config: {
WATER_BUTLER_ENABLED: boolean;
plauditWidgetUrl: string,
environment: any;
cedarConfig: any;
lintOnBuild: boolean;
Expand Down Expand Up @@ -69,6 +71,7 @@ declare const config: {
apiVersion: string;
apiHeaders: { [k: string]: string };
learnMoreUrl: string;
donateUrl: string;
renderUrl: string;
waterbutlerUrl: string;
helpUrl: string;
Expand All @@ -78,6 +81,7 @@ declare const config: {
devMode: boolean;
cookieDomain: string;
authenticator: string;
metricsStartDate: string;
cookies: {
status: string;
keenUserId: string;
Expand Down
2 changes: 1 addition & 1 deletion app/institutions/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
export default class InstitutionDiscoverController extends Controller {
@service currentUser!: CurrentUser;

@tracked q?: string = '';
@tracked cardSearchText?: string = '';
@tracked sort?: string = '-relevance';
@tracked resourceType: ResourceTypeFilterValue = ResourceTypeFilterValue.Projects;
@tracked activeFilters?: Filter[] = [];
Expand Down
4 changes: 4 additions & 0 deletions app/models/contributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { not } from '@ember/object/computed';
import { buildValidations, validator } from 'ember-cp-validations';

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

@belongsTo('preprint', { inverse: 'contributors'})
preprint!: AsyncBelongsTo<PreprintModel> & PreprintModel;

@belongsTo('draft-registration', { inverse: 'contributors' })
draftRegistration!: AsyncBelongsTo<DraftRegistrationModel> & DraftRegistrationModel;

Expand Down
2 changes: 1 addition & 1 deletion app/models/file-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class FileProviderModel extends BaseFileItem {
@belongsTo('base-file-item', { polymorphic: true })
rootFolder!: AsyncBelongsTo<FileModel> & FileModel;

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

@belongsTo('abstract-node', { inverse: 'files', polymorphic: true })
Expand Down
6 changes: 4 additions & 2 deletions app/models/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FileReference } from 'ember-osf-web/packages/registration-schema';
import getHref from 'ember-osf-web/utils/get-href';
import CedarMetadataRecordModel from 'ember-osf-web/models/cedar-metadata-record';

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

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

@hasMany('cedar-metadata-record', { inverse: null })
cedarMetadataRecords!: AsyncBelongsTo<CedarMetadataRecordModel> & CedarMetadataRecordModel;
Expand Down
23 changes: 15 additions & 8 deletions app/models/preprint-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const { defaultProvider } = config;
export default class PreprintProviderModel extends ProviderModel {
@service intl!: Intl;

@attr('fixstring') email_support!: string | null;
@attr('array') subjectsAcceptable!: string[];
@attr('array') additionalProviders!: string[];
@attr('string') shareSource!: string;
Expand Down Expand Up @@ -52,23 +53,29 @@ export default class PreprintProviderModel extends ProviderModel {
};
}

get searchPlaceholder(): string {
return this.intl.t('preprints.header.search_placeholder',
{ placeholder: this.documentType.plural});
}

@computed('id')
get preprintWordInTitle() {
return this.id !== 'thesiscommons';
get preprintWordNotInTitle() {
return this.id === 'thesiscommons';
}

// Is either OSF Preprints if provider is the default provider,
// name+preprintWord.pluralCapitalized(e.g.AfricArXiv Preprints or MarXiv Papers), or "Thesis Commons"
@computed('documentType.pluralCapitalized', 'id', 'name', 'preprintWordInTitle')
@computed('documentType.pluralCapitalized', 'id', 'name', 'preprintWordNotInTitle')
get providerTitle() {
if (this.id !== defaultProvider) {
if (this.preprintWordInTitle) {
return this.intl.t('preprints.provider-title',
{ name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized });
if (this.preprintWordNotInTitle) {
return this.name;
}
return this.name;
return this.intl.t('preprints.provider-title',
{ name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized });
} else {
return this.intl.t('preprints.header.osf_preprints');
}
return this.intl.t('preprints.osf-title');
}
}

Expand Down
32 changes: 32 additions & 0 deletions app/models/preprint-request-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { AsyncBelongsTo, attr, belongsTo } from '@ember-data/model';
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
import UserModel from 'ember-osf-web/models/user';

import OsfModel from './osf-model';


export enum PreprintRequestActionTriggerEnum {
SUBMIT= 'submit',
ACCEPT = 'accept',
REJECT = 'reject',
}

export default class PreprintRequestActionModel extends OsfModel {
@attr('string') comment!: string;
@attr('string') actionTrigger!: string;
@attr('date') dateModified!: Date;
@attr('boolean') auto!: boolean;

// Relationships
@belongsTo('preprint-request', { inverse: 'actions' })
target!: (AsyncBelongsTo<PreprintRequestModel> & PreprintRequestModel);

@belongsTo('user', { inverse: null, async: true })
creator!: AsyncBelongsTo<UserModel> & UserModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'preprint-request-action': PreprintRequestActionModel;
} // eslint-disable-line semi
}
40 changes: 40 additions & 0 deletions app/models/preprint-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { AsyncBelongsTo, SyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model';
import PreprintModel from 'ember-osf-web/models/preprint';
import UserModel from 'ember-osf-web/models/user';
import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action';

import OsfModel from './osf-model';

export enum PreprintRequestType{
WITHDRAWAL = 'withdrawal',
}

export enum PreprintRequestMachineState {
PENDING = 'pending',
ACCEPTED = 'accepted',
REJECTED = 'rejected',
}

export default class PreprintRequestModel extends OsfModel {
@attr('string') comment!: string;
@attr('date') dateLastTransitioned!: Date;
@attr('date') created!: Date;
@attr('date') modified!: Date;
@attr('string') machineState!: string;
@attr('string') requestType!: string;

@belongsTo('preprint', { inverse: 'requests'})
target!: (AsyncBelongsTo<PreprintModel> & PreprintModel);

@belongsTo('user', { inverse: null, async: true })
creator!: AsyncBelongsTo<UserModel> & UserModel;

@hasMany('preprint-request-action', { inverse: 'target'})
actions!: SyncHasMany<PreprintRequestActionModel> & PreprintRequestActionModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'preprint-request': PreprintRequestModel;
} // eslint-disable-line semi
}
65 changes: 56 additions & 9 deletions app/models/preprint.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,60 @@
import { attr, belongsTo, hasMany, SyncHasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';
import { attr, belongsTo, hasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import CitationModel from 'ember-osf-web/models/citation';
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
import { ReviewsState } from 'ember-osf-web/models/provider';
import ReviewActionModel from 'ember-osf-web/models/review-action';

import ContributorModel from './contributor';
import FileModel from './file';
import LicenseModel from './license';
import NodeModel from './node';
import OsfModel from './osf-model';
import OsfModel, { Permission } from './osf-model';
import PreprintProviderModel from './preprint-provider';
import ReviewActionModel from './review-action';
import SubjectModel from './subject';

export enum PreprintDataLinksEnum {
AVAILABLE = 'available',
YES = 'yes',
NO = 'no',
NOT_APPLICABLE = 'not_applicable',
}

export enum PreprintPreregLinksEnum {
AVAILABLE = 'available',
YES = 'yes',
NO = 'no',
NOT_APPLICABLE = 'not_applicable',
}

export default class PreprintModel extends OsfModel {
@attr('fixstring') title!: string;
@attr('date') dateCreated!: Date;
@attr('date') datePublished!: Date;
@attr('date') dateWithdrawn!: Date;
@attr('date') originalPublicationDate!: Date | null;
@attr('date') dateModified!: Date;
@attr('fixstring') doi!: string | null;
@attr('boolean') public!: boolean;
@attr('boolean') isPublished!: boolean;
@attr('boolean') isPreprintOrphan!: boolean;
@attr('object') licenseRecord!: any;
@attr('string') reviewsState!: string;
@attr('string') reviewsState!: ReviewsState;
@attr('string') description!: string;
@attr('date') dateLastTransitioned!: Date;
@attr('date') preprintDoiCreated!: Date;
@attr('array') currentUserPermissions!: Permission[];
@attr('fixstringarray') tags!: string[];
@attr('fixstring') withdrawalJustification! : string;
@attr('boolean') hasCoi!: boolean;
@attr('string') hasDataLinks!: PreprintDataLinksEnum;
@attr('string') hasPreregLinks!: PreprintPreregLinksEnum;
@attr('string') conflictOfInterestStatement!: string;
@attr('array') dataLinks!: string[];
@attr('array') preregLinks!: string[];
@attr('string') whyNoData!: string;
@attr('string') whyNoPrereg!: string;

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

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

@hasMany('contributor')
contributors!: AsyncHasMany<ContributorModel>;
@hasMany('files', { inverse: 'target'})
files!: AsyncHasMany<FileModel> & FileModel;

@hasMany('contributors', { inverse: 'preprint'})
contributors!: AsyncHasMany<ContributorModel> & ContributorModel;

@hasMany('subject', { inverse: null, async: false })
subjects!: SyncHasMany<SubjectModel>;
@hasMany('contributor', { inverse: null })
bibliographicContributors!: AsyncHasMany<ContributorModel>;

@belongsTo('citation', { inverse: null })
citation!: AsyncBelongsTo<CitationModel>;

@hasMany('subject', { inverse: null})
subjects!: AsyncHasMany<SubjectModel>;

@hasMany('preprint-request', { inverse: 'target'})
requests!: AsyncHasMany<PreprintRequestModel>;

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

get isWithdrawn(): boolean{
return this.dateWithdrawn !== null;
}

@computed('license', 'licenseRecord')
get licenseText(): string {
const text = this.license.get('text') || '';
Expand Down
22 changes: 20 additions & 2 deletions app/models/provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { attr, hasMany, SyncHasMany, AsyncHasMany } from '@ember-data/model';
import { computed } from '@ember/object';

import CitationStyleModel from './citation-style';
import LicenseModel from './license';
import ModeratorModel from './moderator';
import OsfModel from './osf-model';
Expand All @@ -20,6 +21,21 @@ export interface Assets {
wide_white: string;
}

export enum PreprintProviderReviewsWorkFlow{
PRE_MODERATION = 'pre-moderation',
POST_MODERATION = 'post-moderation'
}

export enum ReviewsState {
INITIAL = 'initial',
PENDING = 'pending',
ACCEPTED = 'accepted',
REJECTED = 'rejected',
PENDING_WITHDRAWAL = 'pendingWithdrawal',
WITHDRAWAL_REJECTED = 'withdrawalRejected',
WITHDRAWN = 'withdrawn',
}

export enum ReviewPermissions {
SetUpModeration = 'set_up_moderation',
ViewSubmissions = 'view_submissions',
Expand All @@ -39,7 +55,6 @@ export enum ReviewPermissions {
}

/* eslint-enable camelcase */

export default abstract class ProviderModel extends OsfModel {
@attr('fixstring') name!: string;
@attr('fixstring') description!: string;
Expand All @@ -54,7 +69,7 @@ export default abstract class ProviderModel extends OsfModel {
@attr('boolean') allowCommenting!: boolean;
@attr('boolean') allowUpdates!: boolean;
@attr('array') permissions!: ReviewPermissions[];
@attr('fixstring') reviewsWorkflow!: string | null;
@attr('fixstring') reviewsWorkflow!: PreprintProviderReviewsWorkFlow | null;
@attr('boolean') reviewsCommentsAnonymous!: boolean | null;
@attr() assets?: Partial<Assets>; // TODO: camelize in transform

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

@hasMany('citation-style', { inverse: null })
citationStyles!: AsyncHasMany<CitationStyleModel> & CitationStyleModel[];

@computed('permissions')
get currentUserCanReview() {
if (this.permissions) {
Expand Down
4 changes: 3 additions & 1 deletion app/models/review-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { attr, belongsTo, AsyncBelongsTo } from '@ember-data/model';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import Intl from 'ember-intl/services/intl';
import PreprintModel from 'ember-osf-web/models/preprint';

import Action from './action';
import RegistrationModel, { RegistrationReviewStates } from './registration';
Expand Down Expand Up @@ -63,7 +64,8 @@ export default class ReviewActionModel extends Action {
@attr('string') toState!: RegistrationReviewStates;

@belongsTo('registration', { inverse: 'reviewActions', polymorphic: true })
target!: AsyncBelongsTo<RegistrationModel> & RegistrationModel;
target!: (AsyncBelongsTo<RegistrationModel> & RegistrationModel
) | (AsyncBelongsTo<PreprintModel> & PreprintModel);

@computed('actionTrigger')
get triggerPastTense(): string {
Expand Down
1 change: 1 addition & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const Validations = buildValidations({
});

export interface UserLinks extends OsfLinks {
html: Link;
profile_image: Link; // eslint-disable-line camelcase
}

Expand Down
Loading

0 comments on commit 5a96506

Please sign in to comment.