Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BHBC-2058: Edit Project as a Single Page / General UI Clean-up #858

Merged
merged 48 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
fa61046
BHBC-1966: Push Dev To Test (#826)
NickPhura Sep 29, 2022
1575cfe
Merge branch 'dev' of https://github.com/bcgov/biohubbc into secure-d…
jeznorth Nov 10, 2022
a6739b7
Clean-up / Refactor Project Details and Related Components
jeznorth Nov 10, 2022
a9a4a41
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
jeznorth Nov 14, 2022
2860992
Update Project List Page / Remove Unused Functionality from Attachmen…
jeznorth Nov 14, 2022
a7d5667
Standardize Title Container Structure and Styling
jeznorth Nov 14, 2022
0cfdbea
Cleanup Title Container Alignment and Spacing
jeznorth Nov 14, 2022
3206205
Resource Page Clean-up
jeznorth Nov 14, 2022
8506c57
Resource Page Clean-up
jeznorth Nov 14, 2022
8687ef1
Manage Users Page Clean-up
jeznorth Nov 14, 2022
4f0fe8a
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
jeznorth Nov 14, 2022
f6ba3b7
Users Interface Clean-up
jeznorth Nov 14, 2022
1e74eae
dialog setup
KjartanE Nov 14, 2022
97e15e8
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 14, 2022
49c7fda
Formatting Updates
jeznorth Nov 14, 2022
a82bdf0
Project Details and Component Clean-up
jeznorth Nov 15, 2022
2e3ff55
Edit Page functioning errors still present
KjartanE Nov 15, 2022
bb8ac71
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 15, 2022
a77fed2
UI Layout Updates
jeznorth Nov 15, 2022
35a5165
UI Cleanup
jeznorth Nov 15, 2022
269a69c
Clean-up Front-end for Edit Project Page
jeznorth Nov 16, 2022
a7b3507
UI Updates for Create / Edit Project UI's
jeznorth Nov 16, 2022
571f9b6
fix iucn and funding edits
KjartanE Nov 16, 2022
1b35009
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 16, 2022
235de06
BHBC-2052 (#847)
AlfredRosenthal Nov 16, 2022
2e82aa0
PR fix (#844)
KjartanE Nov 16, 2022
159b508
Project Detail Component Clean-up
jeznorth Nov 16, 2022
6264b86
Merge branch 'dev' of https://github.com/bcgov/biohubbc into BHBC-205…
KjartanE Nov 16, 2022
0432e80
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 16, 2022
942727b
UI Clean-up
jeznorth Nov 16, 2022
13e7ad1
Fix one line
jeznorth Nov 16, 2022
c58a3f2
fix save and cancel buttons
KjartanE Nov 16, 2022
377b37a
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 16, 2022
d451073
Spacing clean-up
jeznorth Nov 16, 2022
b45e815
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
jeznorth Nov 16, 2022
20ce349
BHBC-1976: Update API to utilize new DB changes for processing summar…
curtisupshall Nov 16, 2022
f14e880
Merge branch 'dev' into BHBC-1097-secure-documents-prototype
curtisupshall Nov 17, 2022
08f43c3
Test rework more work to be done
KjartanE Nov 17, 2022
61e1f6b
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 17, 2022
fb568d4
Test to Dev (#850)
AlfredRosenthal Nov 17, 2022
c577394
merged test -> dev
AlfredRosenthal Nov 17, 2022
4b783d3
User Details Page Cleanup
jeznorth Nov 17, 2022
381604b
Fix Naming Conventions
jeznorth Nov 17, 2022
cf0215e
Merge branch 'dev' of https://github.com/bcgov/biohubbc into BHBC-205…
KjartanE Nov 17, 2022
76735fe
Merge branch 'BHBC-2058-SDP' of https://github.com/bcgov/biohubbc int…
KjartanE Nov 17, 2022
b067936
Finish fix all broken tests
KjartanE Nov 17, 2022
1e198ea
Merge branch 'BHBC-1097-secure-documents-prototype' of https://github…
KjartanE Nov 17, 2022
b5f93cf
Merge branch 'secure-documents-prototype' of https://github.com/bcgov…
KjartanE Nov 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ run-db-setup: ## Run the database migrations and seeding

build-db-migrate: ## Build the db knex migrations image
@echo "==============================================="
@echo "Make: build-db-migrate - bnuilding db knex migrate image"
@echo "Make: build-db-migrate - building db knex migrate image"
@echo "==============================================="
@docker-compose -f docker-compose.yml build db_migrate

Expand Down
34 changes: 32 additions & 2 deletions api/src/constants/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,33 @@ export enum SUBMISSION_STATUS_TYPE {
'INVALID_MEDIA' = 'Media is not valid',
'FAILED_VALIDATION' = 'Failed to validate',
'FAILED_TRANSFORMED' = 'Failed to transform',
'FAILED_PROCESSING_OCCURRENCE_DATA' = 'Failed to process occurrence data'
'FAILED_PROCESSING_OCCURRENCE_DATA' = 'Failed to process occurrence data',
'FAILED_SUMMARY_PREPARATION' = 'Failed to prepare summary submission'
}

export enum SUMMARY_SUBMISSION_MESSAGE_TYPE {
'DUPLICATE_HEADER' = 'Duplicate Header',
'UNKNOWN_HEADER' = 'Unknown Header',
'MISSING_REQUIRED_HEADER' = 'Missing Required Header',
'MISSING_RECOMMENDED_HEADER' = 'Missing Recommended Header',
'MISCELLANEOUS' = 'Miscellaneous',
'MISSING_REQUIRED_FIELD' = 'Missing Required Field',
'UNEXPECTED_FORMAT' = 'Unexpected Format',
'OUT_OF_RANGE' = 'Out of Range',
'INVALID_VALUE' = 'Invalid Value',
'MISSING_VALIDATION_SCHEMA' = 'Missing Validation Schema',
'INVALID_MEDIA' = 'Media is Invalid',
'INVALID_XLSX_CSV' = 'XLSX CSV is Invalid',
'FAILED_TO_GET_TEMPLATE_NAME_VERSION' = 'Missing Name or Version Number',
'FAILED_GET_VALIDATION_RULES' = 'Failed to Get Validation Rules',
'FAILED_PARSE_VALIDATION_SCHEMA' = 'Failed to Parse Validation Schema',
'UNSUPPORTED_FILE_TYPE' = 'Unsupported File Type',
'FOUND_VALIDATION' = 'Found Validation',
'SYSTEM_ERROR' = 'System Error'
}

// Message types that match the submission_message_type table
export enum SUBMISSION_MESSAGE_TYPE {
//message types that match the submission_message_type table
'DUPLICATE_HEADER' = 'Duplicate header',
'UNKNOWN_HEADER' = 'Unknown Header',
'MISSING_REQUIRED_HEADER' = 'Missing Required Header',
Expand All @@ -64,6 +86,14 @@ export enum SUBMISSION_MESSAGE_TYPE {
'FAILED_PERSIST_VALIDATION_RESULTS' = 'Failed to persist validation results',
'FAILED_UPDATE_OCCURRENCE_SUBMISSION' = 'Failed to update occurrence submission',
'FAILED_TO_GET_TRANSFORM_SCHEMA' = 'Unable to get transform schema for submission',
'FAILED_TO_GET_TEMPLATE_NAME_VERSION' = 'Missing name or version number.',
'INVALID_MEDIA' = 'Media is invalid',
'INVALID_XLSX_CSV' = 'Media is not a valid XLSX CSV file.',
'UNSUPPORTED_FILE_TYPE' = 'File submitted is not a supported type'
}

export enum MESSAGE_CLASS_NAME {
NOTICE = 'Notice',
ERROR = 'Error',
WARNING = 'Warning'
}
24 changes: 12 additions & 12 deletions api/src/models/project-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('PostProjectObject', () => {
]
},
funding: {
funding_sources: [
fundingSources: [
{
agency_id: 1,
investment_action_category: 1,
Expand Down Expand Up @@ -522,48 +522,48 @@ describe('PostFundingData', () => {
data = new PostFundingData(null);
});

it('sets funding_sources', () => {
expect(data.funding_sources).to.eql([]);
it('sets fundingSources', () => {
expect(data.fundingSources).to.eql([]);
});
});

describe('Values provided but not valid arrays', () => {
let data: PostFundingData;

const obj = {
funding_sources: null
fundingSources: null
};

before(() => {
data = new PostFundingData(obj);
});

it('sets funding_sources', () => {
expect(data.funding_sources).to.eql([]);
it('sets fundingSources', () => {
expect(data.fundingSources).to.eql([]);
});
});

describe('Values provided but with no length', () => {
let data: PostFundingData;

const obj = {
funding_sources: []
fundingSources: []
};

before(() => {
data = new PostFundingData(obj);
});

it('sets funding_sources', () => {
expect(data.funding_sources).to.eql([]);
it('sets fundingSources', () => {
expect(data.fundingSources).to.eql([]);
});
});

describe('All values provided', () => {
let data: PostFundingData;

const obj = {
funding_sources: [
fundingSources: [
{
agency_id: 1,
investment_action_category: 1,
Expand All @@ -579,8 +579,8 @@ describe('PostFundingData', () => {
data = new PostFundingData(obj);
});

it('sets funding_sources', () => {
expect(data.funding_sources).to.eql(obj.funding_sources);
it('sets fundingSources', () => {
expect(data.fundingSources).to.eql(obj.fundingSources);
});
});
});
6 changes: 3 additions & 3 deletions api/src/models/project-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ export class PostFundingSource {
* @class PostFundingData
*/
export class PostFundingData {
funding_sources: PostFundingSource[];
fundingSources: PostFundingSource[];

constructor(obj?: any) {
defaultLog.debug({ label: 'PostFundingData', message: 'params', obj });

this.funding_sources =
(obj?.funding_sources?.length && obj.funding_sources.map((item: any) => new PostFundingSource(item))) || [];
this.fundingSources =
(obj?.fundingSources?.length && obj.fundingSources.map((item: any) => new PostFundingSource(item))) || [];
}
}

Expand Down
18 changes: 7 additions & 11 deletions api/src/models/project-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,13 @@ describe('PutFundingSource', () => {

before(() => {
data = new PutFundingSource({
fundingSources: [
{
id: 1,
investment_action_category: 1,
agency_project_id: 'agency project id',
funding_amount: 20,
start_date: '2020/04/04',
end_date: '2020/05/05',
revision_count: 1
}
]
id: 1,
investment_action_category: 1,
agency_project_id: 'agency project id',
funding_amount: 20,
start_date: '2020/04/04',
end_date: '2020/05/05',
revision_count: 1
});
});

Expand Down
33 changes: 24 additions & 9 deletions api/src/models/project-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,30 @@ export class PutFundingSource {
constructor(obj?: any) {
defaultLog.debug({ label: 'PutFundingSource', message: 'params', obj });

const fundingSource = obj?.fundingSources?.length && obj.fundingSources[0];

this.id = fundingSource?.id || null;
this.investment_action_category = fundingSource?.investment_action_category || null;
this.agency_project_id = fundingSource?.agency_project_id || null;
this.funding_amount = fundingSource?.funding_amount || null;
this.start_date = fundingSource?.start_date || null;
this.end_date = fundingSource?.end_date || null;
this.revision_count = fundingSource?.revision_count ?? null;
this.id = obj?.id || null;
this.investment_action_category = obj?.investment_action_category || null;
this.agency_project_id = obj?.agency_project_id || null;
this.funding_amount = obj?.funding_amount || null;
this.start_date = obj?.start_date || null;
this.end_date = obj?.end_date || null;
this.revision_count = obj?.revision_count ?? null;
}
}

/**
* Processes PUT /project funding data
*
* @export
* @class PostFundingData
*/
export class PutFundingData {
fundingSources: PutFundingSource[];

constructor(obj?: any) {
defaultLog.debug({ label: 'PostFundingData', message: 'params', obj });

this.fundingSources =
(obj?.fundingSources?.length && obj.fundingSources.map((item: any) => new PutFundingSource(item))) || [];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import chai, { expect } from 'chai';
import { describe } from 'mocha';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import SQL from 'sql-template-strings';
import { MESSAGE_CLASS_NAME } from '../../../../../../../constants/status';
import * as db from '../../../../../../../database/db';
import { HTTPError } from '../../../../../../../errors/http-error';
import survey_queries from '../../../../../../../queries/survey';
import { ISummarySubmissionMessagesResponse } from '../../../../../../../repositories/summary-repository';
import { SummaryService } from '../../../../../../../services/summary-service';
import { getMockDBConnection } from '../../../../../../../__mocks__/db';
import * as summarySubmission from './get';

Expand Down Expand Up @@ -56,29 +57,6 @@ describe('getSummarySubmission', () => {
}
});

it('should throw a 400 error when no sql statement returned for getLatestSurveySummarySubmissionSQL', async () => {
sinon.stub(db, 'getDBConnection').returns({
...dbConnectionObj,
systemUserId: () => {
return 20;
}
});

sinon.stub(survey_queries, 'getLatestSurveySummarySubmissionSQL').returns(null);

try {
const result = summarySubmission.getSurveySummarySubmission();

await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect((actualError as HTTPError).status).to.equal(400);
expect((actualError as HTTPError).message).to.equal(
'Failed to build getLatestSurveySummarySubmissionSQLStatement statement'
);
}
});

it('should return a summary submission, on success', async () => {
const mockQuery = sinon.stub();

Expand All @@ -100,16 +78,44 @@ describe('getSummarySubmission', () => {
query: mockQuery
});

sinon.stub(survey_queries, 'getLatestSurveySummarySubmissionSQL').returns(SQL`something`);
const messages: ISummarySubmissionMessagesResponse[] = [
{
id: 1,
class: MESSAGE_CLASS_NAME.ERROR,
type: 'Miscellaneous',
message: 'error message'
},
{
id: 2,
class: MESSAGE_CLASS_NAME.ERROR,
type: 'Miscellaneous',
message: 'another error message'
}
];

const submission = {
id: 13,
file_name: 'file13.xlsx',
key: 's3_key',
delete_timestamp: null,
submission_message_type_id: 1,
message: 'another error message',
submission_message_type_name: 'Miscellaneous',
summary_submission_message_class_id: 1,
submission_message_class_name: MESSAGE_CLASS_NAME.ERROR
};

sinon.stub(SummaryService.prototype, 'getLatestSurveySummarySubmission').resolves(submission);
sinon.stub(SummaryService.prototype, 'getSummarySubmissionMessages').resolves(messages);

const result = summarySubmission.getSurveySummarySubmission();

await result(sampleReq, sampleRes as any, (null as unknown) as any);

expect(actualResult).to.be.eql({
id: 13,
fileName: 'file.xlsx',
messages: []
fileName: 'file13.xlsx',
messages
});
});

Expand All @@ -126,8 +132,6 @@ describe('getSummarySubmission', () => {
query: mockQuery
});

sinon.stub(survey_queries, 'getLatestSurveySummarySubmissionSQL').returns(SQL`something`);

const result = summarySubmission.getSurveySummarySubmission();

await result(sampleReq, sampleRes as any, (null as unknown) as any);
Expand Down
Loading