Skip to content

Commit

Permalink
ASAP-533 CRN Schema changes (#4412)
Browse files Browse the repository at this point in the history
* ASAP-533 CRN Schema changes

* fix test

* Update packages/contentful/migrations/crn/manuscripts/20241009181503-update-lifecycle-validations.js

Co-authored-by: Diana Guimarães <47486047+dianaguimaraes@users.noreply.github.com>

---------

Co-authored-by: Diana Guimarães <47486047+dianaguimaraes@users.noreply.github.com>
  • Loading branch information
gabiayako and dianaguimaraes authored Oct 11, 2024
1 parent 12c4f23 commit 51ab580
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/crn-server/test/integration/fixtures/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const getTeamFixture = (
displayName: chance.animal(),
applicationNumber: chance.guid(),
projectTitle: 'Project title',
teamId: 'team-id',
grantId: 'grant-id',
...props,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports.description = 'Update Lifecycle Validations';

module.exports.up = (migration) => {
const manuscriptVersions = migration.editContentType('manuscriptVersions');

manuscriptVersions.editField('lifecycle').validations([
{
in: [
'Draft Manuscript (prior to Publication)',
'Preprint',
'Typeset proof',
'Publication',
'Publication with addendum or corrigendum',
'Other',
],
},
]);
};

module.exports.down = (migration) => {
const manuscriptVersions = migration.editContentType('manuscriptVersions');

manuscriptVersions.editField('lifecycle').validations([
{
in: [
'Draft manuscript (prior to preprint submission)',
'Revised Draft Manuscript (prior to preprint submission)',
'Preprint, version 1',
'Preprint, version 2',
'Preprint, version 3+',
'Typeset proof',
'Publication',
'Publication with addendum or corrigendum',
'Other',
],
},
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports.description = 'Removes research theme field';

module.exports.up = (migration) => {
const researchOutputs = migration.editContentType('researchOutputs');
researchOutputs.deleteField('researchTheme');
};

module.exports.down = (migration) => {
const researchOutputs = migration.editContentType('researchOutputs');

researchOutputs
.createField('researchTheme')
.name('Research Theme')
.type('Array')
.localized(false)
.required(false)
.validations([])
.disabled(false)
.omitted(false)
.items({
type: 'Symbol',
validations: [],
});

researchOutputs.changeFieldControl(
'researchTheme',
'builtin',
'tagEditor',
{},
);
researchOutputs.moveField('researchTheme').afterField('tags');
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports.description = 'Add team id and grant id fields';

module.exports.up = (migration) => {
const teams = migration.editContentType('teams');

teams
.createField('teamId')
.name('Team ID')
.type('Symbol')
.localized(false)
.required(true)
.validations([])
.disabled(false)
.omitted(false);

teams
.createField('grantId')
.name('Grant ID')
.type('Symbol')
.localized(false)
.required(true)
.validations([])
.disabled(false)
.omitted(false);

teams.moveField('teamId').afterField('displayName');
teams.moveField('grantId').afterField('teamId');
};

module.exports.down = (migration) => {
const teams = migration.editContentType('teams');
teams.deleteField('teamId');
teams.deleteField('grantId');
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports.description =
'Add open science team field and delete research theme';

module.exports.up = (migration) => {
const users = migration.editContentType('users');
users.deleteField('researchTheme');

users
.createField('openScienceTeamMember')
.name('Open Science Team Member')
.type('Boolean')
.localized(false)
.required(false)
.validations([])
.defaultValue({
'en-US': false,
})
.disabled(false)
.omitted(false);

users.changeFieldControl('openScienceTeamMember', 'builtin', 'boolean', {});
users.moveField('openScienceTeamMember').afterField('role');
};

module.exports.down = (migration) => {
const users = migration.editContentType('users');
users
.createField('researchTheme')
.name('Research Theme')
.type('Array')
.localized(false)
.required(false)
.validations([])
.disabled(false)
.omitted(false)
.items({
type: 'Symbol',
validations: [],
});

users.changeFieldControl('researchTheme', 'builtin', 'tagEditor', {});
users.moveField('researchTheme').afterField('researchTags');

users.deleteField('openScienceTeamMember');
};
2 changes: 2 additions & 0 deletions packages/model/src/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export type TeamCreateDataObject = {
projectSummary?: string;
projectTitle: string;
tools?: TeamTool[];
teamId: string;
grantId: string;
};

export type TeamResponse = TeamDataObject;
Expand Down

0 comments on commit 51ab580

Please sign in to comment.