Skip to content

Commit

Permalink
Merge branch 'main' into feat/1700-parent-tree-calculation-part-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ngunner15 authored Nov 19, 2024
2 parents b1b6d12 + e4ac30a commit 0183993
Show file tree
Hide file tree
Showing 23 changed files with 206 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ schemaspy/output
# local testing
*.bat

oracle-api/config
oracle-api/config
4 changes: 3 additions & 1 deletion frontend/src/api-service/ApiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const ApiConfig = {

areaOfUseSpzList: `${oracleServerHost}/api/area-of-use/spz-list/vegetation-code`,

parentTreeByVegCode: `${oracleServerHost}/api/parent-trees/vegetation-codes/{vegCode}`
parentTreeByVegCode: `${oracleServerHost}/api/parent-trees/vegetation-codes/{vegCode}`,

seedlotFromOracleDbBySeedlotNumber: `${oracleServerHost}/api/seedlot/{seedlotNumber}`
};

export default ApiConfig;
5 changes: 5 additions & 0 deletions frontend/src/api-service/seedlotAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ export const getAClassSeedlotFullForm = (seedlotNumber: string) => {
const url = `${ApiConfig.seedlots}/${seedlotNumber}/a-class-full-form`;
return api.get(url).then((res) => res.data as SeedlotAClassFullResponseType);
};

export const getSeedlotFromOracleDbBySeedlotNumber = (seedlotNumber: string) => {
const url = ApiConfig.seedlotFromOracleDbBySeedlotNumber.replace('{seedlotNumber}', seedlotNumber);
return api.get(url);
};
1 change: 1 addition & 0 deletions frontend/src/components/ClientAndCodeInput/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ClientAndCodeInputProps = {
readOnly?: boolean,
maxInputColSize?: number,
checkBoxInput?: BooleanInputType
shouldSelectDefaultValue?: boolean
}

export default ClientAndCodeInputProps;
27 changes: 17 additions & 10 deletions frontend/src/components/ClientAndCodeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import './styles.scss';
const ClientAndCodeInput = ({
checkboxId, clientInput, locationCodeInput, textConfig, defaultClientNumber,
defaultLocCode, setClientAndCode, readOnly, showCheckbox, maxInputColSize,
checkBoxInput
checkBoxInput, shouldSelectDefaultValue = false
}: ClientAndCodeInputProps) => {
const getIsDefaultVal = () => (
checkBoxInput === undefined
Expand All @@ -38,9 +38,16 @@ const ClientAndCodeInput = ({
const clientInputRef = useRef<HTMLInputElement>(null);
const locCodeInputRef = useRef<HTMLInputElement>(null);
const [isDefault, setIsDefault] = useState<boolean>(
() => getIsDefaultVal()
!shouldSelectDefaultValue ? false : () => getIsDefaultVal()
);

const [isChecked, setIsChecked] = useState<boolean>(() => {
if (!shouldSelectDefaultValue) {
return false;
}
return checkBoxInput ? checkBoxInput.value : isDefault;
});

const [showClientValidationStatus, setShowClientValidationStatus] = useState<boolean>(true);

const [showLocCodeValidationStatus, setShowLocCodeValidationStatus] = useState<boolean>(false);
Expand All @@ -60,7 +67,9 @@ const ClientAndCodeInput = ({
useEffect(() => {
const areValsDefault = getIsDefaultVal();

setIsDefault(areValsDefault);
if (shouldSelectDefaultValue) {
setIsDefault(areValsDefault);
}

// Do not show validation status if isDefault is true
if (areValsDefault) {
Expand Down Expand Up @@ -223,10 +232,8 @@ const ClientAndCodeInput = ({
}
: undefined
);

if (!checkBoxInput) {
setIsDefault(checked);
}
setIsDefault(checked);
setIsChecked(checked);
};

const [openAgnTooltip, setOpenAgnTooltip] = useState<boolean>(false);
Expand Down Expand Up @@ -343,7 +350,7 @@ const ClientAndCodeInput = ({
name={textConfig.useDefaultCheckbox.name}
labelText={textConfig.useDefaultCheckbox.labelText}
readOnly={readOnly}
checked={checkBoxInput ? checkBoxInput.value : isDefault}
checked={isChecked}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
handleDefaultCheckBox(e.target.checked);
}}
Expand All @@ -363,7 +370,7 @@ const ClientAndCodeInput = ({
id={clientInput.id}
autoCapitalize="on"
labelText={textConfig.agencyInput.titleText}
defaultValue={forestClientQuery.data?.acronym}
defaultValue={shouldSelectDefaultValue ? forestClientQuery.data?.acronym : ''}
helperText={
(readOnly || (showCheckbox && isDefault))
? null
Expand Down Expand Up @@ -406,7 +413,7 @@ const ClientAndCodeInput = ({
id={locationCodeInput.id}
ref={locCodeInputRef}
name={textConfig.locationCode.name}
defaultValue={locationCodeInput.value}
defaultValue={shouldSelectDefaultValue ? locationCodeInput.value : ''}
type="number"
maxCount={LOCATION_CODE_LIMIT}
enableCounter
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/LotApplicantAndInfoForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const LotApplicantAndInfoForm = ({
}
readOnly={isEdit}
maxInputColSize={6}
shouldSelectDefaultValue
/>
<Row className="agency-email-row">
<Column sm={4} md={8} lg={16} xlg={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export const fieldsConfig = {
},
volumePerContainers: {
name: 'volumePerContainers',
labelText: 'Volume per Containers (HI)',
labelText: 'Volume per containers (hl)',
invalidText: 'Invalid entry. Number must be between 0 and 10,000 and up to 3 decimal places.'
},
volumeOfCones: {
name: 'volumeOfCones',
labelText: 'Volume of Cones (HI)',
labelText: 'Volume of cones (hl)',
invalidText: 'Number has more than 3 decimals.',
helperText: 'This value must be the "Volume per container" X "Number of containers".',
warnText: 'The total volume of cones does not equal, please note that this value must be the "Volume per container" x "Number of containers"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { EmptyMultiOptObj } from '../../../shared-constants/shared-constants';
import { THREE_HALF_HOURS, THREE_HOURS } from '../../../config/TimeUnits';
import { getMultiOptList } from '../../../utils/MultiOptionsUtils';
import getFundingSources from '../../../api-service/fundingSourcesAPI';
import { getSeedlotFromOracleDbBySeedlotNumber } from '../../../api-service/seedlotAPI';
import TitleAccordion from '../../TitleAccordion';
import ScrollToTop from '../../ScrollToTop';
import SingleOwnerInfo from './SingleOwnerInfo';
Expand Down Expand Up @@ -53,7 +54,8 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => {
setStepData,
defaultClientNumber: defaultAgency,
defaultCode,
isFormSubmitted
isFormSubmitted,
seedlotNumber
} = useContext(ClassAContext);

const [accordionControls, setAccordionControls] = useState<AccordionCtrlObj>({});
Expand Down Expand Up @@ -107,6 +109,12 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => {
cacheTime: THREE_HALF_HOURS
});

const getSeedlotBySeedlotNumberQuery = useQuery(
['get-seedlot-by-seedlotNumber', seedlotNumber],
() => getSeedlotFromOracleDbBySeedlotNumber(seedlotNumber ?? ''),
{ enabled: !!seedlotNumber }
);

// Set default method of payment for the first owner.
useEffect(() => {
if (methodsOfPaymentQuery.status === 'success') {
Expand Down Expand Up @@ -143,6 +151,8 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => {

const getFcQuery = (clientNumber: string): ForestClientType | undefined => qc.getQueryData(['forest-clients', clientNumber]);

const originalSeedQty = getSeedlotBySeedlotNumberQuery.data?.data?.originalSeedQty ?? 0;

return (
<div>
<ScrollToTop enabled={!isReview} />
Expand Down Expand Up @@ -209,7 +219,7 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => {
checkPortionSum={
(updtEntry: SingleOwnerForm, id: number) => checkPortionSum(updtEntry, id)
}
readOnly={isFormSubmitted}
readOnly={isFormSubmitted || originalSeedQty > 0}
isReview={isReview}
/>
</AccordionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,13 @@ export const geneticWorthDict: GeneticWorthDictType = {
PW: ['dsb'],
DR: ['gvo'],
EP: ['gvo'],
FDI: ['gvo'],
FDI: ['gvo', 'wwd'],
HW: ['gvo'],
LW: ['gvo'],
PY: ['gvo'],
SS: ['gvo', 'iws'],
SX: ['gvo', 'iws'],
YC: ['gvo'],
UNKNOWN: ['gvo']
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,21 @@ export type NotifCtrlType = {
}
}

type SpeciesWithGenWorth = 'CW'| 'PLI' |'FDC' | 'PW' | 'DR' | 'EP' | 'FDI' | 'HW' | 'LW' | 'PY' | 'SS' | 'SX' | 'UNKNOWN';
type SpeciesWithGenWorth =
'CW'
|'PLI'
|'FDC'
|'PW'
|'DR'
|'EP'
|'FDI'
|'HW'
|'LW'
|'PY'
|'SS'
|'SX'
|'YC'
|'UNKNOWN';

export type GeneticWorthDictType = {
[key in SpeciesWithGenWorth]: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ const ParentTreeStep = ({ isReviewDisplay, isReviewRead }: ParentTreeStepProps)
setHeaderConfig,
weightedGwInfoItems,
setWeightedGwInfoItems,
setApplicableGenWorths,
isReviewDisplay ?? false
setApplicableGenWorths
), [seedlotSpecies]);

const uploadCompostion = useMutation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ export const configHeaderOpt = (
setHeaderConfig: Function,
weightedGwInfoItems: Record<keyof RowItem, InfoDisplayObj>,
setWeightedGwInfoItems: Function,
setApplicableGenWorths: Function,
isReview: boolean
setApplicableGenWorths: Function
) => {
const speciesKey = Object.keys(geneticWorthDict).includes(seedlotSpecies.code)
? seedlotSpecies.code.toUpperCase()
Expand All @@ -562,10 +561,8 @@ export const configHeaderOpt = (
// Enable option in the column customization
clonedHeaders[optionIndex].isAnOption = true;

// When on review mode, display all columns
if (isReview) {
clonedHeaders[optionIndex].enabled = true;
}
// Display all columns by default
clonedHeaders[optionIndex].enabled = true;

// Enable weighted option in mix tab
const weightedIndex = headerConfig.findIndex((header) => header.id === `w_${opt}`);
Expand Down Expand Up @@ -923,15 +920,11 @@ export const isMissingSecondaryOrchard = (orchardStepData: OrchardForm): boolean
* Check if orchards selections are valid.
*/
export const areOrchardsValid = (orchardStepData: OrchardForm): boolean => {
let isValid = true;
const { orchards } = orchardStepData;

if (!orchards.primaryOrchard.value.code) {
isValid = false;
}
if (isMissingSecondaryOrchard(orchardStepData)) {
isValid = false;
return false;
}

return isValid;
return true;
};
2 changes: 1 addition & 1 deletion frontend/src/components/SeedlotTable/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TableText = {
};

export const PageSizesConfig = [
10, 20, 30, 40, 50
50, 100, 150, 200, 250
];

export const ExclusiveAdminRows: Array<string> = [
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/types/SeedlotType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ export type CollectionFormSubmitType = {
collectionLocnCode: string,
collectionStartDate: string,
collectionEndDate: string,
noOfContainers: number,
volPerContainer: number,
clctnVolume: number,
noOfContainers: string,
volPerContainer: string,
clctnVolume: string,
seedlotComment: string,
coneCollectionMethodCodes: Array<number>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export const emptyCollectionStep: CollectionFormSubmitType = {
collectionLocnCode: '',
collectionStartDate: '',
collectionEndDate: '',
noOfContainers: 1,
volPerContainer: 1,
clctnVolume: 1,
noOfContainers: '',
volPerContainer: '',
clctnVolume: '',
seedlotComment: '',
coneCollectionMethodCodes: []
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/Seedlot/ContextContainerClassA/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,9 @@ export const convertCollection = (collectionData: CollectionForm): CollectionFor
// Assume the date values are present as validation has occurred before payload is generated
collectionStartDate: localDateToUtcFormat(collectionData.startDate.value)!,
collectionEndDate: localDateToUtcFormat(collectionData.endDate.value)!,
noOfContainers: +collectionData.numberOfContainers.value,
volPerContainer: +collectionData.volumePerContainers.value,
clctnVolume: +collectionData.volumeOfCones.value,
noOfContainers: `${+collectionData.numberOfContainers.value}`,
volPerContainer: `${+collectionData.volumePerContainers.value}`,
clctnVolume: `${+collectionData.volumeOfCones.value}`,
seedlotComment: collectionData.comments.value,
coneCollectionMethodCodes: collectionData
.selectedCollectionCodes.value.map((code) => parseInt(code, 10))
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Seedlot/MySeedlots/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const MySeedlots = () => {
isSortable
showSearch
showPagination
defaultPageSize={20}
defaultPageSize={50}
/>
</Row>
</FlexGrid>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Seedlot/ReviewSeedlots/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ReviewSeedlots = () => {
isSortable
showSearch
showPagination
defaultPageSize={20}
defaultPageSize={50}
/>
</Row>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@carbon/icons-react';
import { Beforeunload } from 'react-beforeunload';

import { getSeedlotById, putAClassSeedlotProgress } from '../../../api-service/seedlotAPI';
import { getSeedlotById, putAClassSeedlotProgress, getSeedlotFromOracleDbBySeedlotNumber } from '../../../api-service/seedlotAPI';
import { THREE_HALF_HOURS, THREE_HOURS } from '../../../config/TimeUnits';
import getVegCodes from '../../../api-service/vegetationCodeAPI';
import Breadcrumbs from '../../../components/Breadcrumbs';
Expand Down Expand Up @@ -105,6 +105,12 @@ const SeedlotReviewContent = () => {
refetchOnMount: true
});

const getSeedlotBySeedlotNumberQuery = useQuery({
queryKey: ['seedlot-by-seedlotNumber', seedlotNumber],
queryFn: () => getSeedlotFromOracleDbBySeedlotNumber(seedlotNumber ?? ''),
enabled: seedlotQuery.isFetched
});

useEffect(() => {
const { status } = seedlotQuery;

Expand Down Expand Up @@ -550,6 +556,8 @@ const SeedlotReviewContent = () => {
className="edit-save-btn"
renderIcon={isReadMode ? Edit : Save}
onClick={handleEditSaveBtn}
disabled={getSeedlotBySeedlotNumberQuery.isSuccess
&& getSeedlotBySeedlotNumberQuery.data.data.originalSeedQty > 0}
>
{isReadMode ? 'Edit seedlot' : 'Save edit'}
</Button>
Expand Down
5 changes: 5 additions & 0 deletions oracle-api/config/application-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spring:
datasource:
url: jdbc:oracle:thin:@tcp://localhost:1521/dbdock_01
username: THE
password: default
Loading

0 comments on commit 0183993

Please sign in to comment.