Skip to content

Commit ba638c1

Browse files
authored
feat: add instrumentIds property to Proposal schema (#2124)
* feat: add instrumentIds property to Proposal schema * add missing config * fix proposal fullQuery example * make _id customizable for each measurementPeriod * add missing fields in the dto
1 parent 8b07879 commit ba638c1

File tree

7 files changed

+69
-1
lines changed

7 files changed

+69
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
async up(db, client) {
3+
await db
4+
.collection("Proposal")
5+
.updateMany(
6+
{ instrumentIds: { $exists: false } },
7+
{ $set: { instrumentIds: [] } },
8+
);
9+
},
10+
11+
async down(db, client) {
12+
// No path backward
13+
},
14+
};

src/common/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ export const filterDescription =
922922
</pre>';
923923

924924
export const fullQueryExampleLimits =
925-
'{"limit": 1, "skip": 1, "order": "creationTime:desc"}';
925+
'{"limit": 1, "skip": 0, "order": "creationTime:desc"}';
926926

927927
export const fullQueryDescriptionLimits =
928928
'<pre>\n \

src/config/frontend.config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,5 +436,27 @@
436436
"row": 2
437437
}
438438
]
439+
},
440+
"mainMenu": {
441+
"nonAuthenticatedUser": {
442+
"datasets": true,
443+
"files": false,
444+
"instruments": true,
445+
"jobs": false,
446+
"policies": false,
447+
"proposals": true,
448+
"publishedData": true,
449+
"samples": false
450+
},
451+
"authenticatedUser": {
452+
"datasets": true,
453+
"files": true,
454+
"instruments": true,
455+
"jobs": true,
456+
"policies": false,
457+
"proposals": true,
458+
"publishedData": true,
459+
"samples": true
460+
}
439461
}
440462
}

src/proposals/dto/create-measurement-period.dto.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { IsDateString, IsOptional, IsString } from "class-validator";
22

33
export class CreateMeasurementPeriodDto {
4+
/**
5+
* Unique identifier for the measurement period. Ideally, it should match the UUID of the corresponding instrument from the instrument table
6+
*/
7+
@IsOptional()
8+
@IsString()
9+
readonly _id?: string;
410
/**
511
* Instrument or beamline identifier where measurement was pursued, e.g. /PSI/SLS/TOMCAT
612
*/

src/proposals/dto/update-proposal.dto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ export class UpdateProposalDto extends OwnableDto {
111111
@IsOptional()
112112
@IsString()
113113
readonly type?: string;
114+
115+
/**
116+
* List of instrument IDs associated with the proposal.
117+
*/
118+
@IsOptional()
119+
@IsArray()
120+
@IsString({ each: true })
121+
readonly instrumentIds?: string[];
114122
}
115123

116124
export class PartialUpdateProposalDto extends PartialType(UpdateProposalDto) {}

src/proposals/schemas/measurement-period.schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ export type MeasurementPeriodDocument = MeasurementPeriodClass & Document;
55

66
@Schema()
77
export class MeasurementPeriodClass {
8+
/**
9+
* Unique identifier for the measurement period. Ideally, it should match the UUID of the corresponding instrument from the instrument table
10+
*/
11+
@Prop({
12+
type: String,
13+
})
14+
_id: string;
15+
816
/**
917
* Instrument or beamline identifier where measurement was pursued, e.g. /PSI/SLS/TOMCAT
1018
*/

src/proposals/schemas/proposal.schema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ export class ProposalClass extends OwnableClass {
161161
default: DEFAULT_PROPOSAL_TYPE,
162162
})
163163
type: string = DEFAULT_PROPOSAL_TYPE;
164+
165+
/**
166+
* List of instrument IDs associated with the proposal.
167+
*/
168+
@Prop({
169+
type: [String],
170+
default: [],
171+
required: false,
172+
})
173+
instrumentIds?: string[];
164174
}
165175

166176
export const ProposalSchema = SchemaFactory.createForClass(ProposalClass);

0 commit comments

Comments
 (0)