Skip to content

Commit 961a036

Browse files
futa-ikedacslzchenbp-cosadlius
authored
Feature/preprints phase 2 (#2261)
* Fix TS variable naming * Implement is-selected style check/listener * Add data-test selector * Clean up css and hbs for mobile * Disable and grey out the create button when no provider is selected * Improve naming for CSS classes * Fix extra spaces in translations/en-us.yml * CR reponse: improve code quality + use <Button> component * Initial Step to install a changeset * Final css change * Updates for PR comments * Updates for the pr comments * Respond to CR pass 2: fix provider fetch query + improve code quality * Added the updates for the metadata page * Added the publication year * Added the publication citation * Fixed a typo in the field validation * Added an optional type for the changeset * Removed the validator for the optional field * Fix provider filter for `allowSubmissions` * Update mirage fixtures to allow submissions for all * Added logic to persist a preprint * Fixed some issues with the contributors widget * Added a new user scenario and updates to be able to persist contributors * Added case insensitivity to the user search * Added updates to handle adding a contributor to the preprint * Added the license component ENG-5310 * Updates per the PR * Fixed some filtering * Added the licenses acceptable * Fixed some PR stuff * Added the tags widget to the metadata page * Added the subjects widget * Removed an unnecessary method * Fixed a copy and paste error * Updates to the author assertions page to handle the conflict of insterest * Updates for PR review * Added backwards compatability for the radio buton group * Fixed the conflict of interest issue for null * Minor Updates * Updates to finalize the radio button form control * Updates for the PR * Initial step to add public data * Another step for public data * Additional formatting for the radio buttons * Another step with the changeset * Fixed a typo * Added more logic for the links widget * Updates for yuhuai to debug * Added the remove options for a link * Additional updates to the public data components * fix bugs * remove debugger * Additional updates after Yuhuais cherry picks * Updates for the PR * Updates to the changesets * Fix link for botton "submit a preprint" * Fix link for "add a preprint" in both branded and osf nav-bar * Respond to CR * Use in-app transition * Fix @computed property * "add a preprint" in osf nav bar now goes to the "select page" * Add data test and analytics selectors * Update edit preprint link to use in-app transition * Respond to CR: fix getting provider, now from model directly * Initial step to add public data * Additional formatting for the radio buttons * Another step with the changeset * Initial update for public preregistrations * Updated some missed merges * Additional updates to merge issues * Updates for preregistrations * Additional typo updates * Fixed logic issue * Fixed some typecasting * Updates for the PR * Additional updates for the PR * Final update * Added a few more updates * Fixed for why nos * Added buttons to the supplements page * Added more buttons and widgets to the supplements page * Added the initial node-picker to the addon components * All working for now * More refactors * Added the final changeset * Additional updates for looks * Added some updates for the PR * Updated some file names * updates for the PR * Updated the state machine to start at the first * Fixed another button issue * Updates for the supplements page * Added styling for the review page * Added an onchange for the subject manager * Added the metadata * Fixed the doi and publication date * Bibliographic updates * Updates for PR comments * Additional Updates for publication date * Added finishing upates for the pr comments * Removed unnnecessary formatting * Part - 2Removed unnnecessary formatting * Part - 3 Removed unnnecessary formatting * Updates to fix all the back and forths * Added the min-max date for publications * Translation typo * Added the logic to handle the last step of the preprint "submit" * Updates for the delete button * Added the finishing touches to the delete button modal * Updates from actions to tasks * Updates for the PR * Final updates for the PR * Updates to the tests * Updates to the tests * redesigned the select page for the new mock * Added the publication citation to the details page * Added the coi for the review page * Added a public data component * Added the data component * Added the preprint public prereg component * Oops forgot a component * Fixed some copy and paste issues * Added the supplements to the review page * Added a few PR updates * Update priority when computing required status for validated-inputs * Removed the caution warning * Fixed link colors * Fixed the next button active and disable states * Additional styling * Added additional updates for mark * Added one last touch * Initial pass for reformatting the contributors display * Updates for the search box * Another step in the reformat * Added more styling * Final updates for the contributor list * Fixed some tests * Updates for mobile view * Additional Updates * Updates to the read-only template and styles * Fixed Author assertions * updates for supplements * Updates for the PR * Added a new component template to abstract the flow * Added the edit work flow * Removed an unneeded import * Phase one to remove an added supplemental material * Finished the requests for Mark * Added a create project widget * Deleted an unecessary component and added the create-node component * Removed unnecessary translations * Fixed the formatting on the user-search cancel widget * Changed the background color of the disabled date picker * Initial commit to add buttons and functionality * Next steps * Upload file code * modify factories * make it polymorphic? * make it not polymorphic * Added a create project widget * Initial commit to add buttons and functionality * Updates to the ui and removed a bad merge * A few update * Updates for mobile * Another brick in the wall * make it work * Updated the css * Small fixed to attempt to get the file uploading. * Updates to the flow to remove the file upload * Removed some strings * Minor updates * Updates for pre-file component addition * Added a new file page * Fixed the upload to work in mirage and added functionality to show the file name after upload * Finished the flow by showing the file name * Updates for the PR and some styling changes and reductions * Fixed some mirage logic to help with failing tests * Fixes for failing tests * Added a popover to fix a bug * [ENG-5715] [ENG-5713] [ENG-5644] Sundry fixes for the preprint project waiting for a blocker on dropzone (#2228) ## Purpose Fix various sundry issues regarding preprints ## Summary of Changes Authentication on selecting, submitting and editing a preprint Disabled multiple clicks on the next button Disabled multiple clicks on the "create draft" button for registries Fixed the `add user` issue for contributors Enabled the next button on key up for title and abstract Added a min length validator for abstract Updated the hover on select usage Add the year and copyright for licenses Added a spinner for clicking the next button * 2 quick clean-up items * Updates for a few bugs that I have found * Add an or statement * Initital commit to get the public and prereg links to be editable * Finally found an answer to the riddle of persisting the author assertion page * Final updates to get the author assertion page to persist with all permutations * Fixed to disable coi when it is no * Initial attempt to remove a supplement during creation * Updated code on the advice of Brian to remove a supplement * Update for the PR review * Fixed the max length of the title with css adjustments * Fixed the no license issue with copyright holders * Updates for eng-5786 * Add alt text * Updates for various fixes * Fixed some aria labels * Minor fix * Updates to get the preprint to either go to moderation or be public * Removed a space * Added a new component * Added some PR comments * Fixed a translation issue * Fixed bug ENG-5734 and ENG-5744 * Fixed bug ENG-5793 * Fixed an issue with the changeset and subjects * Fixed some logic based on a PR comment * Added some fixes for eng-5813 * Perform to action * Removed the function form the model * Fixed the action flow and the navigation arrows * Fixed the drag and drop for mobile contributors * Fixed the drag and drop for mobile contributors * Added a "save preprint toast message" * Removed unneeded code * Reverted the isMobile and to be isDisplayMobileMenu * Fixed an error in review states * Fixed bug ENG-5823 * Added logic to be able to version a file * Added logic for browsing away from the create and edit flow * Withdrawal updates * Added logic to withdrawal * Added a withdrawal preprint dialog * Added the missing preprint-request adapter * Added ability to display the withdrawal button and fixed an error in character length. * More permissions and fun stuff * Added the remaining logic * Re-added a translation string and fixed the subject errors * Fixed the withdrawal button in mobile * Fixed a non-sentence * Changed the button color * Fixed some typos * Added a fix for the abstract * Fixed the contributors user search to require a filter string * Fixed the branded issue * Fixed an issue with a missing property on a translations * Updated the translations * Fixed some a11y issues * Added updates to be more precise * REmoved a comment * Updates to the logic for the changeset * Added logic to update the file name when selecting a new file for a preprint * Added text to the contributors widget * Fixed the css color * Added the permission warning * Renamed originalPublicationCitation to customPublicationCitation * Fixed the submit button color * Fixed a double header on the registries contributors (#2265) * Fixed a double header on the registries contributors * Fixed an issue with parenthesis --------- Co-authored-by: Longze Chen <cslzchen@gmail.com> Co-authored-by: Brian Pilati <brianpilati@cos.io> Co-authored-by: Yuhuai Liu <yuhuai@cos.io> Co-authored-by: Lord Business <113387478+bp-cos@users.noreply.github.com>
1 parent 3a2d898 commit 961a036

File tree

175 files changed

+7010
-685
lines changed

Some content is hidden

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

175 files changed

+7010
-685
lines changed

app/adapters/contributor.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ export default class ContributorAdapter extends OsfAdapter {
1818
if (requestType === 'findRecord') {
1919
const [objectId, userId] = (id || '').split('-');
2020
const node = this.store.peekRecord('node', objectId);
21+
const preprint = this.store.peekRecord('preprint', objectId);
2122
const draft = this.store.peekRecord('draft-registration', objectId);
2223
let baseUrl;
2324
assert(`"contributorId" must be "objectId-userId": got ${objectId}-${userId}`, Boolean(objectId && userId));
2425
if (node) {
2526
baseUrl = this.buildRelationshipURL((node as any)._internalModel.createSnapshot(), 'contributors');
27+
} else if (preprint) {
28+
baseUrl = this.buildRelationshipURL((preprint as any)._internalModel.createSnapshot(), 'contributors');
2629
} else {
2730
baseUrl = this.buildRelationshipURL((draft as any)._internalModel.createSnapshot(), 'contributors');
2831
}
@@ -31,13 +34,21 @@ export default class ContributorAdapter extends OsfAdapter {
3134

3235
if (snapshot && requestType === 'createRecord') {
3336
const node = snapshot.belongsTo('node');
37+
const preprint = snapshot.belongsTo('preprint');
3438
const draftRegistration = snapshot.belongsTo('draftRegistration');
3539
const user = snapshot.belongsTo('users');
36-
assert('"node" or "draftRegistration" relationship is needed to create a contributor',
37-
Boolean(node || draftRegistration));
40+
assert('"node" or "draftRegistration" or "preprint" relationship is needed to create a contributor',
41+
Boolean(node || draftRegistration || preprint));
3842
assert('"users" relationship, "email" or "fullName" is needed to create a contributor',
3943
Boolean(user || snapshot.attr('email') || snapshot.attr('fullName')));
4044
let baseUrl;
45+
46+
if (preprint) {
47+
// if preprint relationship is defined
48+
// we post to v2/preprints/<preprint_id>/contributors
49+
baseUrl = this.buildRelationshipURL(preprint, 'contributors');
50+
}
51+
4152
if (node) {
4253
// if node relationship is defined
4354
// we post to v2/nodes/<node_id>/contributors

app/adapters/preprint-request.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import ActionAdapter from './action';
2+
3+
export default class PreprintRequestAdapter extends ActionAdapter {
4+
}
5+
6+
declare module 'ember-data/types/registries/adapter' {
7+
export default interface AdapterRegistry {
8+
'preprint-request': PreprintRequestAdapter;
9+
} // eslint-disable-line semi
10+
}

app/models/file-provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { attr, belongsTo, AsyncBelongsTo, hasMany, AsyncHasMany } from '@ember-data/model';
2+
import PreprintModel from 'ember-osf-web/models/preprint';
23
import { Link } from 'jsonapi-typescript';
34

45
import AbstractNodeModel from './abstract-node';
@@ -24,7 +25,8 @@ export default class FileProviderModel extends BaseFileItem {
2425

2526
@belongsTo('abstract-node', { inverse: 'files', polymorphic: true })
2627
target!: (AsyncBelongsTo<AbstractNodeModel> & AbstractNodeModel) |
27-
(AsyncBelongsTo<DraftNodeModel> & DraftNodeModel);
28+
(AsyncBelongsTo<DraftNodeModel> & DraftNodeModel) |
29+
(AsyncBelongsTo<PreprintModel> & PreprintModel);
2830

2931
// BaseFileItem override
3032
isProvider = true;

app/models/license.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export default class LicenseModel extends OsfModel {
99
@attr('fixstring') url!: string;
1010
@attr('fixstring') text!: string;
1111
@attr('array') requiredFields!: Array<keyof NodeLicense>;
12+
13+
get hasRequiredFields(): boolean {
14+
return this.requiredFields?.length > 0;
15+
}
1216
}
1317

1418
declare module 'ember-data/types/registries/model' {

app/models/osf-model.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Model, { attr } from '@ember-data/model';
22
import Store from '@ember-data/store';
3-
import EmberArray, { A } from '@ember/array';
3+
import EmberArray, { A, isArray } from '@ember/array';
44
import { assert } from '@ember/debug';
55
import { set } from '@ember/object';
66
import { alias } from '@ember/object/computed';
@@ -226,6 +226,13 @@ export default class OsfModel extends Model {
226226
return this.modifyM2MRelationship('post', relationshipName, relatedModel);
227227
}
228228

229+
async removeM2MRelationship<T extends OsfModel>(
230+
this: T,
231+
relationshipName: RelationshipsFor<T> & string,
232+
) {
233+
return this.modifyM2MRelationship('patch', relationshipName, []);
234+
}
235+
229236
async deleteM2MRelationship<T extends OsfModel>(
230237
this: T,
231238
relationshipName: RelationshipsFor<T> & string,
@@ -266,20 +273,26 @@ export default class OsfModel extends Model {
266273

267274
async modifyM2MRelationship<T extends OsfModel>(
268275
this: T,
269-
action: 'post' | 'delete',
276+
action: 'post' | 'delete' | 'patch',
270277
relationshipName: RelationshipsFor<T> & string,
271-
relatedModel: OsfModel,
278+
relatedModel: OsfModel | [],
272279
) {
273280
const apiRelationshipName = underscore(relationshipName);
274281
const url = getSelfHref(this.relationshipLinks[apiRelationshipName]);
275282

276-
const data = JSON.stringify({
277-
data: [{
278-
id: relatedModel.id,
279-
type: relatedModel.apiType,
280-
}],
283+
let data = JSON.stringify({
284+
data: [ ],
281285
});
282286

287+
if (!isArray(relatedModel)) {
288+
data = JSON.stringify({
289+
data: [{
290+
id: relatedModel?.id,
291+
type: relatedModel?.apiType,
292+
}],
293+
});
294+
}
295+
283296
if (!url) {
284297
throw new Error(`Couldn't find self link for ${apiRelationshipName} relationship`);
285298
}
@@ -353,7 +366,7 @@ export default class OsfModel extends Model {
353366
* });
354367
*
355368
* contributors.sparseModels.forEach(contrib => {
356-
* console.log(contrib.users.fullName);
369+
* console.info(contrib.users.fullName);
357370
* );
358371
* ```
359372
*/

app/models/preprint-provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class PreprintProviderModel extends ProviderModel {
2020

2121
@attr('fixstring') email_support!: string | null;
2222
@attr('array') subjectsAcceptable!: string[];
23+
@attr('boolean') assertionsEnabled!: boolean;
2324
@attr('array') additionalProviders!: string[];
2425
@attr('string') shareSource!: string;
2526
@attr('string') preprintWord!: PreprintWord;

app/models/preprint.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
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 AbstractNodeModel from 'ember-osf-web/models/abstract-node';
45
import CitationModel from 'ember-osf-web/models/citation';
56
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
67
import { ReviewsState } from 'ember-osf-web/models/provider';
@@ -11,51 +12,63 @@ import FileModel from './file';
1112
import IdentifierModel from './identifier';
1213
import LicenseModel from './license';
1314
import NodeModel from './node';
14-
import OsfModel, { Permission } from './osf-model';
15+
import { Permission } from './osf-model';
1516
import PreprintProviderModel from './preprint-provider';
1617
import SubjectModel from './subject';
1718

1819
export enum PreprintDataLinksEnum {
1920
AVAILABLE = 'available',
20-
YES = 'yes',
2121
NO = 'no',
2222
NOT_APPLICABLE = 'not_applicable',
2323
}
2424

2525
export enum PreprintPreregLinksEnum {
2626
AVAILABLE = 'available',
27-
YES = 'yes',
2827
NO = 'no',
2928
NOT_APPLICABLE = 'not_applicable',
3029
}
3130

32-
export default class PreprintModel extends OsfModel {
31+
export enum PreprintPreregLinkInfoEnum {
32+
PREREG_EMPTY = '',
33+
PREREG_DESIGNS = 'prereg_designs',
34+
PREREG_ANALYSIS = 'prereg_analysis',
35+
PREREG_BOTH = 'prereg_both',
36+
}
37+
38+
export interface PreprintLicenseRecordModel {
39+
copyright_holders: string[];
40+
year: string;
41+
}
42+
43+
export default class PreprintModel extends AbstractNodeModel {
3344
@attr('fixstring') title!: string;
3445
@attr('date') dateCreated!: Date;
3546
@attr('date') datePublished!: Date;
3647
@attr('date') dateWithdrawn!: Date;
3748
@attr('date') originalPublicationDate!: Date | null;
49+
@attr('fixstring') customPublicationCitation!: string | null;
3850
@attr('date') dateModified!: Date;
3951
@attr('fixstring') doi!: string | null;
4052
@attr('boolean') public!: boolean;
4153
@attr('boolean') isPublished!: boolean;
4254
@attr('boolean') isPreprintOrphan!: boolean;
43-
@attr('object') licenseRecord!: any;
55+
@attr('object') licenseRecord!: PreprintLicenseRecordModel;
4456
@attr('string') reviewsState!: ReviewsState;
4557
@attr('string') description!: string;
4658
@attr('date') dateLastTransitioned!: Date;
4759
@attr('date') preprintDoiCreated!: Date;
4860
@attr('array') currentUserPermissions!: Permission[];
4961
@attr('fixstringarray') tags!: string[];
50-
@attr('fixstring') withdrawalJustification! : string;
62+
@attr('fixstring') withdrawalJustification!: string;
5163
@attr('boolean') hasCoi!: boolean;
5264
@attr('string') hasDataLinks!: PreprintDataLinksEnum;
5365
@attr('string') hasPreregLinks!: PreprintPreregLinksEnum;
54-
@attr('string') conflictOfInterestStatement!: string;
66+
@attr('string') conflictOfInterestStatement!: string | null;
5567
@attr('array') dataLinks!: string[];
5668
@attr('array') preregLinks!: string[];
57-
@attr('string') whyNoData!: string;
58-
@attr('string') whyNoPrereg!: string;
69+
@attr('string') whyNoData!: string | null;
70+
@attr('string') whyNoPrereg!: string | null;
71+
@attr('string') preregLinkInfo!: PreprintPreregLinkInfoEnum;
5972

6073
@belongsTo('node', { inverse: 'preprints' })
6174
node!: AsyncBelongsTo<NodeModel> & NodeModel;
@@ -72,9 +85,6 @@ export default class PreprintModel extends OsfModel {
7285
@hasMany('review-action')
7386
reviewActions!: AsyncHasMany<ReviewActionModel>;
7487

75-
@hasMany('files', { inverse: 'target'})
76-
files!: AsyncHasMany<FileModel> & FileModel;
77-
7888
@hasMany('contributors', { inverse: 'preprint'})
7989
contributors!: AsyncHasMany<ContributorModel> & ContributorModel;
8090

@@ -103,7 +113,7 @@ export default class PreprintModel extends OsfModel {
103113
@computed('license', 'licenseRecord')
104114
get licenseText(): string {
105115
const text = this.license.get('text') || '';
106-
const { year = '', copyright_holders = [] } = this.licenseRecord; // eslint-disable-line camelcase
116+
const { year = '', copyright_holders = [] } = this.licenseRecord;
107117

108118
return text
109119
.replace(/({{year}})/g, year)

app/packages/registration-schema/validations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { RegistrationResponse } from 'ember-osf-web/packages/registration-schema
1111
import { SchemaBlockGroup } from 'ember-osf-web/packages/registration-schema/schema-block-group';
1212
import { validateFileList } from 'ember-osf-web/validators/validate-response-format';
1313
import SchemaResponseModel from 'ember-osf-web/models/schema-response';
14+
import PreprintModel from 'ember-osf-web/models/preprint';
1415

1516
type LicensedContent = DraftRegistration | NodeModel;
1617

@@ -131,7 +132,7 @@ export function validateNodeLicense() {
131132
}
132133

133134
export function validateSubjects() {
134-
return (_: unknown, __: unknown, ___: unknown, ____: unknown, content: DraftRegistration) => {
135+
return (_: unknown, __: unknown, ___: unknown, ____: unknown, content: DraftRegistration | PreprintModel ) => {
135136
const subjects = content.hasMany('subjects').value();
136137
if (!subjects || subjects.length === 0) {
137138
return {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Component from '@glimmer/component';
2+
import PreprintModel from 'ember-osf-web/models/preprint';
3+
import { inject as service } from '@ember/service';
4+
import Intl from 'ember-intl/services/intl';
5+
6+
interface CoiArgs {
7+
preprint: PreprintModel;
8+
}
9+
10+
export default class PreprintCoi extends Component<CoiArgs> {
11+
@service intl!: Intl;
12+
13+
preprint = this.args.preprint;
14+
15+
get coiDisplay(): string {
16+
return this.preprint.hasCoi
17+
? this.preprint.conflictOfInterestStatement as string
18+
: this.intl.t('preprints.submit.step-review.no-conflict-of-interest');
19+
}
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div>
2+
<h4>
3+
{{t 'preprints.submit.step-review.conflict-of-interest'}}
4+
</h4>
5+
<ExpandablePreview @height='50'>
6+
{{this.coiDisplay}}
7+
</ExpandablePreview>
8+
</div>

0 commit comments

Comments
 (0)