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

psp-9080 add missing LEASE_STAKEHOLDER_TYPE codes. #4286

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
IF EXISTS (
SELECT
1
FROM
PIMS_LEASE_STAKEHOLDER_TYPE
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNER'
) BEGIN
UPDATE
PIMS_LEASE_STAKEHOLDER_TYPE
SET
IS_DISABLED = 1,
CONCURRENCY_CONTROL_NUMBER = CONCURRENCY_CONTROL_NUMBER + 1
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNER';

END;

IF EXISTS (
SELECT
1
FROM
PIMS_LEASE_STAKEHOLDER_TYPE
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNREP'
) BEGIN
UPDATE
PIMS_LEASE_STAKEHOLDER_TYPE
SET
IS_DISABLED = 1,
CONCURRENCY_CONTROL_NUMBER = CONCURRENCY_CONTROL_NUMBER + 1
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNREP';

END;

GO
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
IF NOT EXISTS (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Doug did a migration of the old values in the alter up, but forgot to add these new values. They are present in the BUILD.

SELECT
1
FROM
PIMS_LEASE_STAKEHOLDER_TYPE
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNER'
)
INSERT INTO
PIMS_LEASE_STAKEHOLDER_TYPE (
LEASE_STAKEHOLDER_TYPE_CODE,
DESCRIPTION,
IS_PAYABLE_RELATED
)
VALUES
('OWNER', N'Owner', 1);

ELSE
UPDATE
PIMS_LEASE_STAKEHOLDER_TYPE
SET
IS_DISABLED = 0,
CONCURRENCY_CONTROL_NUMBER = CONCURRENCY_CONTROL_NUMBER + 1
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNER';

IF NOT EXISTS (
SELECT
1
FROM
PIMS_LEASE_STAKEHOLDER_TYPE
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNREP'
)
INSERT INTO
PIMS_LEASE_STAKEHOLDER_TYPE (
LEASE_STAKEHOLDER_TYPE_CODE,
DESCRIPTION,
IS_PAYABLE_RELATED
)
VALUES
('OWNREP', N'Owner Representative', 1);

ELSE
UPDATE
PIMS_LEASE_STAKEHOLDER_TYPE
SET
IS_DISABLED = 0,
CONCURRENCY_CONTROL_NUMBER = CONCURRENCY_CONTROL_NUMBER + 1
WHERE
LEASE_STAKEHOLDER_TYPE_CODE = 'OWNREP';

GO
8 changes: 5 additions & 3 deletions source/frontend/src/components/common/form/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ export const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
};

const renderPlaceholder = () => {
if (!placeholder) {
const calculatedPlaceholder =
!value || options.find(option => option.value === value) ? null : 'N/A'; // Render N/A in the event that the currently selected value is not in the list.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is required, otherwise if a value is currently selected that is not in the options list, the select will default to showing the first value in the options list, even if that is not what the select's current value is. To correct this, the user would have to select the value which currently appears selected, which is not intuitive.

if (!calculatedPlaceholder && !placeholder) {
return null;
}
return <option value="">{`${placeholder}`}</option>;
return <option value="">{`${placeholder ?? calculatedPlaceholder}`}</option>;
};

const renderOptions = () => {
Expand Down Expand Up @@ -153,7 +155,7 @@ export const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
custom={custom}
isInvalid={!!touch && !!error}
{...rest}
value={getIn(values, field) ?? ''}
value={value ?? ''}
multiple={multiple}
onChange={onSelectChange}
onBlur={(e: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ exports[`DocumentDetailForm component > renders as expected 1`] = `
id="input-documentStatusCode"
name="documentStatusCode"
>
<option
value=""
>
N/A
</option>
<option
class="option"
data-testid="select-option-NONE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const AddLeaseStakeholderForm: React.FunctionComponent<
setSelectedStakeholders(remainingContacts);
setSelectedContacts(remainingContacts);
};
console.log(stakeholderTypesOptions, initialValues, selectedStakeholders, isPayableLease);
return (
<StyledSummarySection>
<Section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface ITenantProps {
export const ViewStakeholderForm: React.FunctionComponent<
React.PropsWithChildren<ITenantProps>
> = ({ nameSpace, stakeholders, loading, leaseStakeholderTypes, isPayableLease }) => {
console.log(leaseStakeholderTypes, isPayableLease);
return (
<FormSectionOne>
<Formik
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const getColumns = (
isPayableLease: boolean,
): ColumnWithProps<FormStakeholder>[] => {
const stakeholderType = isPayableLease ? 'Payee type' : 'Contact type';
console.log(stakeholderTypes);
return [
{
Header: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ exports[`UpdatePropertyDetailsContainer component > renders as expected 1`] = `
id="input-regionTypeCode"
name="regionTypeCode"
>
<option
value=""
>
N/A
</option>
<option
class="option"
data-testid="select-option-1"
Expand Down Expand Up @@ -1416,6 +1421,11 @@ exports[`UpdatePropertyDetailsContainer component > renders as expected 1`] = `
id="input-pphStatusTypeCode"
name="pphStatusTypeCode"
>
<option
value=""
>
N/A
</option>
<option
class="option"
data-testid="select-option-ARTERY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ exports[`UpdatePropertyDetailsForm component > renders as expected 1`] = `
id="input-regionTypeCode"
name="regionTypeCode"
>
<option
value=""
>
N/A
</option>
<option
class="option"
data-testid="select-option-1"
Expand Down Expand Up @@ -1396,6 +1401,11 @@ exports[`UpdatePropertyDetailsForm component > renders as expected 1`] = `
id="input-pphStatusTypeCode"
name="pphStatusTypeCode"
>
<option
value=""
>
N/A
</option>
<option
class="option"
data-testid="select-option-ARTERY"
Expand Down
Loading
Loading