Skip to content

Commit

Permalink
Survey Progress Field (#1238)
Browse files Browse the repository at this point in the history
* survey repository changes & frontend

* openApi spec

* more openapi spec changes

* migration fixes

* wip: fix migration where survey table does not have progress_id

* set survey status when creating or editing surveys

* cleanup

* include description in planning ui options

* planning chip on survey page

* add survey progress chip to survey list page

* adjust colors of progress chip

* add survey_progress to tests

* linter

* cleanup and fixes

* linter

* make progress required

* wip: validation not yet working on survey form for progress component

* include progress in yup schema

* create index for progress id in survey table

* linter

* fix incorrect name: progress -> progress_id

* cleanup

* address PR comments

* update seed

* update comments in codes repository

* update returns types in codes repository

---------

Co-authored-by: Al Rosenthal <[email protected]>
Co-authored-by: Nick Phura <[email protected]>
  • Loading branch information
3 people authored and KjartanE committed Mar 13, 2024
1 parent aaf4d9b commit 7f75b65
Show file tree
Hide file tree
Showing 29 changed files with 594 additions and 306 deletions.
468 changes: 234 additions & 234 deletions api/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/src/models/biohub-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe('PostSurveyToBiohubObject', () => {
uuid: '1',
project_id: 1,
survey_name: 'survey_name',
progress_id: 1,
start_date: 'start_date',
end_date: 'end_date',
survey_types: [9],
Expand Down Expand Up @@ -180,6 +181,7 @@ describe('PostSurveySubmissionToBioHubObject', () => {
uuid: '1',
project_id: 1,
survey_name: 'survey_name',
progress_id: 1,
start_date: 'start_date',
end_date: 'end_date',
survey_types: [9],
Expand Down
2 changes: 2 additions & 0 deletions api/src/models/survey-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ export class PostSurveyDetailsData {
survey_name: string;
start_date: string;
end_date: string;
progress_id: number;
survey_types: number[];

constructor(obj?: any) {
this.survey_name = obj?.survey_name || null;
this.start_date = obj?.start_date || null;
this.end_date = obj?.end_date || null;
this.progress_id = obj?.progress_id || null;
this.survey_types = (obj?.survey_types?.length && obj.survey_types) || [];
}
}
Expand Down
2 changes: 2 additions & 0 deletions api/src/models/survey-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ export class PutSurveyDetailsData {
name: string;
start_date: string;
end_date: string;
progress_id: number;
survey_types: number[];
revision_count: number;

constructor(obj?: any) {
this.name = obj?.survey_name || null;
this.start_date = obj?.start_date || null;
this.end_date = obj?.end_date || null;
this.progress_id = obj?.progress_id || null;
this.survey_types = (obj?.survey_types?.length && obj.survey_types) || [];
this.revision_count = obj?.revision_count ?? null;
}
Expand Down
2 changes: 2 additions & 0 deletions api/src/models/survey-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class GetSurveyData {
survey_name: string;
start_date: string;
end_date: string;
progress_id: number;
survey_types: number[];
revision_count: number;

Expand All @@ -44,6 +45,7 @@ export class GetSurveyData {
this.survey_name = obj?.name || '';
this.start_date = obj?.start_date || null;
this.end_date = obj?.end_date || null;
this.progress_id = obj?.progress_id || null;
this.survey_types = (obj?.survey_types?.length && obj.survey_types) || [];
this.revision_count = obj?.revision_count || 0;
}
Expand Down
20 changes: 19 additions & 1 deletion api/src/paths/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ GET.apiDoc = {
'administrative_activity_status_type',
'intended_outcomes',
'vantage_codes',
'site_selection_strategies'
'site_selection_strategies',
'survey_progress'
],
properties: {
management_action_type: {
Expand Down Expand Up @@ -324,6 +325,23 @@ GET.apiDoc = {
}
}
}
},
survey_progress: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'integer'
},
name: {
type: 'string'
},
description: {
type: 'string'
}
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions api/src/paths/project/{projectId}/survey/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('survey list', () => {
survey_id: 1001,
name: 'Survey 1',
start_date: '2023-01-01',
progress_id: 1,
end_date: null,
focal_species: [1],
focal_species_names: ['Species 1']
Expand All @@ -55,6 +56,7 @@ describe('survey list', () => {
const mockSurveyB = {
survey_id: 1002,
name: 'Survey 2',
progress_id: 2,
start_date: '2023-04-04',
end_date: '2024-05-05',
focal_species: [1, 2],
Expand Down
5 changes: 4 additions & 1 deletion api/src/paths/project/{projectId}/survey/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GET.apiDoc = {
items: {
type: 'object',
additionalProperties: false,
required: ['survey_id', 'name', 'start_date', 'end_date', 'focal_species'],
required: ['survey_id', 'name', 'start_date', 'end_date', 'progress_id', 'focal_species'],
properties: {
survey_id: {
type: 'integer',
Expand All @@ -94,6 +94,9 @@ GET.apiDoc = {
description: 'ISO 8601 date string',
nullable: true
},
progress_id: {
type: 'integer'
},
focal_species: {
type: 'array',
items: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('survey/{surveyId}/view', () => {
survey_name: 'name',
start_date: '2020-04-04',
end_date: '2020-05-05',
progress_id: 1,
survey_types: [1, 2],
revision_count: 1
},
Expand Down Expand Up @@ -99,6 +100,7 @@ describe('survey/{surveyId}/view', () => {
survey_name: 'name',
start_date: '2020-04-04',
end_date: '2020-05-05',
progress_id: 1,
survey_types: [1, 2],
revision_count: 1
},
Expand Down
Loading

0 comments on commit 7f75b65

Please sign in to comment.