Skip to content

Commit

Permalink
Merge pull request #1503 from cityofaustin/2.25.0-release-candidate
Browse files Browse the repository at this point in the history
2.25.0 Woman Hollering Creek
  • Loading branch information
mddilley authored Dec 5, 2024
2 parents 1d91e35 + 108eb4b commit 8b955cd
Show file tree
Hide file tree
Showing 19 changed files with 1,622 additions and 239 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Updating moped_department table will be up only. If we need to revert, we will need do it manually or
-- update with a future migration.
SELECT 0;
87 changes: 87 additions & 0 deletions moped-database/migrations/1732661952305_department_reorg/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
-- Add soft deletes to department table
ALTER TABLE moped_department ADD is_deleted boolean DEFAULT FALSE;
COMMENT ON COLUMN moped_department.is_deleted IS 'Indicates soft deletion';

INSERT INTO "public"."moped_department" ("department_name", "department_abbreviation", "organization_id") VALUES
('Austin Transportation and Public Works', 'TPW', 1);

-- Soft delete existing department records that are merging into the new one
UPDATE moped_department SET is_deleted = TRUE WHERE department_name IN ('Austin Transportation', 'Public Works');

-- Find existing workgroup records that are associated with the departments that are merging
-- and update them to the new department row called Austin Transportation and Public Works
WITH department_todos AS (
SELECT department_id AS ids
FROM
moped_department
WHERE
department_name IN (
'Austin Transportation',
'Public Works'
)
),

new_department_row AS (
SELECT department_id AS id
FROM
moped_department
WHERE
department_name = 'Austin Transportation and Public Works'
)

UPDATE
moped_workgroup
SET
department_id = (SELECT id FROM new_department_row)
WHERE
department_id IN (SELECT ids FROM department_todos);

-- Find existing entity records that are associated with the departments that are merging
-- and update them to the new department row called Austin Transportation and Public Works
WITH department_todos AS (
SELECT department_id AS ids
FROM
moped_department
WHERE
department_name IN (
'Austin Transportation',
'Public Works'
)
),

new_department_row AS (
SELECT department_id AS id
FROM
moped_department
WHERE
department_name = 'Austin Transportation and Public Works'
)

UPDATE
moped_entity
SET
department_id = (SELECT id FROM new_department_row)
WHERE
department_id IN (SELECT ids FROM department_todos);

-- Add foreign key constraints to entity table department_id column; moped_workgroup already has this constraint
ALTER TABLE moped_entity
ADD CONSTRAINT moped_entity_department_id_fkey FOREIGN KEY ("department_id")
REFERENCES moped_department ("department_id");

-- Add foreign key constraints to entity table workgroup_id column
ALTER TABLE moped_entity
ADD CONSTRAINT moped_entity_workgroup_id_fkey FOREIGN KEY ("workgroup_id")
REFERENCES moped_workgroup ("workgroup_id");

-- Add foreign key constraints to department and entity tables for organization_id columns
ALTER TABLE moped_entity
ADD CONSTRAINT moped_entity_organization_id_fkey FOREIGN KEY ("organization_id")
REFERENCES moped_organization ("organization_id");

ALTER TABLE moped_department
ADD CONSTRAINT moped_department_organization_id_fkey FOREIGN KEY ("organization_id")
REFERENCES moped_organization ("organization_id");

-- Remove row with 0 for id and 'None' for name; we're not using it and null is more appropriate for entities and workgroups with no department
DELETE FROM moped_department WHERE department_id = 0;
542 changes: 542 additions & 0 deletions moped-database/migrations/1733184698645_add_comp_work_types/down.sql

Large diffs are not rendered by default.

557 changes: 557 additions & 0 deletions moped-database/migrations/1733184698645_add_comp_work_types/up.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion moped-database/views/component_arcgis_online_view.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Most recent migration: moped-database/migrations/1730931541883_update_agol_view_geometry/up.sql
-- Most recent migration: moped-database/migrations/1733184698645_add_comp_work_types/up.sql

CREATE OR REPLACE VIEW component_arcgis_online_view AS WITH work_types AS (
SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Most recent migration: moped-database/migrations/1730931541883_update_agol_view_geometry/up.sql
-- Most recent migration: moped-database/migrations/1733184698645_add_comp_work_types/up.sql

CREATE OR REPLACE VIEW exploded_component_arcgis_online_view AS SELECT
component_arcgis_online_view.project_id,
Expand Down
19 changes: 16 additions & 3 deletions moped-database/views/project_list_view.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Most recent migration: moped-database/migrations/1729197757693_remove_completion_date_from_project_list_view/up.sql
-- Most recent migration: moped-database/migrations/1733184698645_add_comp_work_types/up.sql

CREATE OR REPLACE VIEW project_list_view AS WITH project_person_list_lookup AS (
SELECT
Expand Down Expand Up @@ -165,6 +165,17 @@ min_estimated_phase_dates AS (
min(min_dates.min_date) AS min_phase_date
FROM min_dates
GROUP BY min_dates.project_id
),

project_component_work_types AS (
SELECT
mpc.project_id,
string_agg(DISTINCT mwt.name, ', '::text ORDER BY mwt.name) AS component_work_type_names
FROM moped_proj_components mpc
LEFT JOIN moped_proj_component_work_types mpcwt ON mpcwt.project_component_id = mpc.project_component_id
LEFT JOIN moped_work_types mwt ON mwt.id = mpcwt.work_type_id
WHERE true AND mpc.is_deleted = false AND mpcwt.is_deleted = false
GROUP BY mpc.project_id
)

SELECT
Expand Down Expand Up @@ -252,7 +263,8 @@ SELECT
concat(added_by_user.first_name, ' ', added_by_user.last_name) AS added_by,
mpcs.components,
districts.project_council_districts,
districts.project_and_child_project_council_districts
districts.project_and_child_project_council_districts,
pcwt.component_work_type_names
FROM moped_project mp
LEFT JOIN project_person_list_lookup ppll ON mp.project_id = ppll.project_id
LEFT JOIN funding_sources_lookup fsl ON mp.project_id = fsl.project_id
Expand All @@ -270,6 +282,7 @@ LEFT JOIN moped_proj_components_subtypes mpcs ON mp.project_id = mpcs.project_id
LEFT JOIN project_district_association districts ON mp.project_id = districts.project_id
LEFT JOIN min_confirmed_phase_dates mcpd ON mp.project_id = mcpd.project_id
LEFT JOIN min_estimated_phase_dates mepd ON mp.project_id = mepd.project_id
LEFT JOIN project_component_work_types pcwt ON mp.project_id = pcwt.project_id
LEFT JOIN LATERAL (
SELECT
mpn.project_note,
Expand All @@ -280,4 +293,4 @@ LEFT JOIN LATERAL (
LIMIT 1
) proj_status_update ON true
WHERE mp.is_deleted = false
GROUP BY mp.project_id, mp.project_name, mp.project_description, ppll.project_team_members, mp.ecapris_subproject_id, mp.date_added, mp.is_deleted, me.entity_name, mel.entity_name, mp.updated_at, mp.interim_project_id, mp.parent_project_id, mp.knack_project_id, current_phase.phase_name, current_phase.phase_key, current_phase.phase_name_simple, ptl.type_name, mpcs.components, fsl.funding_source_name, fsl.funding_program_names, fsl.funding_source_and_program_names, added_by_user.first_name, added_by_user.last_name, mpps.name, cpl.children_project_ids, proj_status_update.project_note, proj_status_update.date_created, work_activities.workgroup_contractors, work_activities.contract_numbers, work_activities.task_order_names, work_activities.task_order_names_short, work_activities.task_orders, districts.project_council_districts, districts.project_and_child_project_council_districts, mepd.min_phase_date, mcpd.min_phase_date;
GROUP BY mp.project_id, mp.project_name, mp.project_description, ppll.project_team_members, mp.ecapris_subproject_id, mp.date_added, mp.is_deleted, me.entity_name, mel.entity_name, mp.updated_at, mp.interim_project_id, mp.parent_project_id, mp.knack_project_id, current_phase.phase_name, current_phase.phase_key, current_phase.phase_name_simple, ptl.type_name, mpcs.components, fsl.funding_source_name, fsl.funding_program_names, fsl.funding_source_and_program_names, added_by_user.first_name, added_by_user.last_name, mpps.name, cpl.children_project_ids, proj_status_update.project_note, proj_status_update.date_created, work_activities.workgroup_contractors, work_activities.contract_numbers, work_activities.task_order_names, work_activities.task_order_names_short, work_activities.task_orders, districts.project_council_districts, districts.project_and_child_project_council_districts, mepd.min_phase_date, mcpd.min_phase_date, pcwt.component_work_type_names;
10 changes: 5 additions & 5 deletions moped-editor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion moped-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "atd-moped-editor",
"author": "ATD Data & Technology Services",
"license": "CC0-1.0",
"version": "2.24.0",
"version": "2.25.0",
"homepage": "/moped",
"private": false,
"repository": {
Expand Down
61 changes: 23 additions & 38 deletions moped-editor/src/components/GridTable/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { useQuery } from "@apollo/client";
import {
Button,
TextField,
InputLabel,
Select,
FormControl,
MenuItem,
Grid,
Hidden,
Icon,
Expand Down Expand Up @@ -154,7 +151,10 @@ const Filters = ({
/* Some features like all/any radios require more than one filter to appear */
const areMoreThanOneFilters = filterParameters.length > 1;

const autocompleteOptionsMap = useCreateAutocompleteOptions(filtersConfig, data);
const autocompleteOptionsMap = useCreateAutocompleteOptions(
filtersConfig,
data
);

/**
* Handles the click event on the field drop-down menu
Expand Down Expand Up @@ -387,10 +387,8 @@ const Filters = ({
const operators = fieldConfig?.operators ?? [];

/* If the field uses a lookup table, get the table and field names */
const {
table_name: lookupTable,
operators: lookupOperators,
} = fieldConfig?.lookup ?? {};
const { table_name: lookupTable, operators: lookupOperators } =
fieldConfig?.lookup ?? {};

/* Check filter row validity */
const isValidInput = checkIsValidInput(filter, type);
Expand Down Expand Up @@ -445,43 +443,30 @@ const Filters = ({
fullWidth
className={classes.formControl}
>
<InputLabel
id={`filter-operator-select-${filterIndex}-label`}
>
Operator
</InputLabel>
<Select
variant="standard"
fullWidth
disabled={operators.length === 0}
labelId={`filter-operator-select-${filterIndex}-label`}
<Autocomplete
value={operator || null}
id={`filter-operator-select-${filterIndex}`}
value={operator || ""}
onChange={(e) =>
options={operators}
disabled={operators.length === 0}
getOptionLabel={(operator) =>
FILTERS_COMMON_OPERATORS[operator]?.label || ""
}
onChange={(e, value) =>
handleFilterOperatorChange(
filterIndex,
e.target.value,
value,
lookupTable,
lookupOperators
)
}
label="field"
data-testid="operator-select"
>
{operators.map((operator, operatorIndex) => {
const label = FILTERS_COMMON_OPERATORS[operator]?.label;
return (
<MenuItem
value={operator}
key={`filter-operator-select-item-${filterIndex}-${operatorIndex}`}
id={`filter-operator-select-item-${filterIndex}-${operatorIndex}`}
data-testid={label}
>
{label}
</MenuItem>
);
})}
</Select>
renderInput={(params) => (
<TextField
{...params}
variant="standard"
label={"Operator"}
/>
)}
/>
</FormControl>
</Grid>

Expand Down
30 changes: 18 additions & 12 deletions moped-editor/src/components/GridTable/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Grid,
Paper,
Popper,
ClickAwayListener,
} from "@mui/material";
import FormControlLabel from "@mui/material/FormControlLabel";
import FormGroup from "@mui/material/FormGroup";
Expand Down Expand Up @@ -244,18 +245,23 @@ const Search = ({
placement={"bottom"}
className={classes.advancedSearchRoot}
>
<Paper className={classes.advancedSearchPaper}>
<Filters
setFilters={setFilters}
handleAdvancedSearchClose={handleAdvancedSearchClose}
filtersConfig={filtersConfig}
resetSimpleSearch={resetSimpleSearch}
isOr={isOr}
setIsOr={setIsOr}
setSearchParams={setSearchParams}
searchParams={searchParams}
/>
</Paper>
{/* FYI: you cannot use a Select component inside the click away listener
as discussed in this thread https://github.com/mui/material-ui/issues/25578
so we have opted to use Autocompletes instead*/}
<ClickAwayListener onClickAway={handleAdvancedSearchClose}>
<Paper className={classes.advancedSearchPaper}>
<Filters
setFilters={setFilters}
handleAdvancedSearchClose={handleAdvancedSearchClose}
filtersConfig={filtersConfig}
resetSimpleSearch={resetSimpleSearch}
isOr={isOr}
setIsOr={setIsOr}
setSearchParams={setSearchParams}
searchParams={searchParams}
/>
</Paper>
</ClickAwayListener>
</Popper>
</div>
);
Expand Down
7 changes: 2 additions & 5 deletions moped-editor/src/components/RenderFieldLink.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React from "react";
import { NavLink as RouterLink } from "react-router-dom";
import theme from "src/theme/index"
import theme from "src/theme/index";

const RenderFieldLink = ({ projectId, value, tab }) => {
const route = tab
? `/moped/projects/${projectId}?tab=${tab}`
: `/moped/projects/${projectId}/`;
return (
<RouterLink
to={route}
style={{color: theme.palette.primary.main}}
>
<RouterLink to={route} style={{ color: theme.palette.primary.main }}>
{value}
</RouterLink>
);
Expand Down
11 changes: 10 additions & 1 deletion moped-editor/src/queries/subprojects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { gql } from "@apollo/client";
export const SUBPROJECT_QUERY = gql`
query SubprojectSummary($projectId: Int) {
subprojects: moped_project(
where: { parent_project_id: { _eq: $projectId }, is_deleted: { _eq: false } }
where: {
parent_project_id: { _eq: $projectId }
is_deleted: { _eq: false }
}
) {
project_name
project_name_full
Expand All @@ -28,6 +31,12 @@ export const SUBPROJECT_QUERY = gql`
) {
project_id
project_name_full
moped_proj_phases(where: { is_current_phase: { _eq: true } }) {
moped_phase {
phase_name
phase_key
}
}
}
}
`;
Expand Down
Loading

0 comments on commit 8b955cd

Please sign in to comment.