Skip to content

Commit

Permalink
Merge pull request #1514 from cityofaustin/2.26.0-release-candidate
Browse files Browse the repository at this point in the history
2.26.0 Christmas Creek
  • Loading branch information
mddilley authored Dec 19, 2024
2 parents ed96faa + 6ee0a84 commit 72167ad
Show file tree
Hide file tree
Showing 35 changed files with 1,249 additions and 646 deletions.
2 changes: 1 addition & 1 deletion moped-database/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Architecture Independent Docker Stack Components for Moped Development Environment
services:
hasura:
image: hasura/graphql-engine:v2.44.0
image: hasura/graphql-engine:v2.45.0
depends_on:
- moped-pgsql
expose:
Expand Down
99 changes: 99 additions & 0 deletions moped-database/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5188,6 +5188,102 @@
- role: moped-viewer
permission:
filter: {}
- table:
name: moped_user_saved_views
schema: public
insert_permissions:
- role: moped-admin
permission:
check: {}
set:
created_by_user_id: x-hasura-x-hasura-user-db-id
updated_by_user_id: x-hasura-x-hasura-user-db-id
columns:
- description
- is_deleted
- query_filters
- url
comment: ""
- role: moped-editor
permission:
check: {}
set:
created_by_user_id: x-hasura-x-hasura-user-db-id
updated_by_user_id: x-hasura-x-hasura-user-db-id
columns:
- description
- is_deleted
- query_filters
- url
comment: ""
select_permissions:
- role: moped-admin
permission:
columns:
- is_deleted
- id
- query_filters
- description
- url
- updated_at
- created_at
- created_by_user_id
- updated_by_user_id
filter: {}
comment: ""
- role: moped-editor
permission:
columns:
- is_deleted
- id
- query_filters
- description
- url
- updated_at
- created_at
- created_by_user_id
- updated_by_user_id
filter: {}
comment: ""
- role: moped-viewer
permission:
columns:
- is_deleted
- id
- query_filters
- description
- url
- updated_at
- created_at
- created_by_user_id
- updated_by_user_id
filter: {}
comment: ""
update_permissions:
- role: moped-admin
permission:
columns:
- description
- is_deleted
- query_filters
- url
filter: {}
check: null
set:
updated_by_user_id: x-hasura-x-hasura-user-db-id
comment: ""
- role: moped-editor
permission:
columns:
- description
- is_deleted
- query_filters
- url
filter: {}
check: null
set:
updated_by_user_id: x-hasura-x-hasura-user-db-id
comment: ""
- table:
name: moped_users
schema: public
Expand Down Expand Up @@ -5461,6 +5557,7 @@
columns:
- added_by
- children_project_ids
- component_work_type_names
- components
- construction_start_date
- contract_numbers
Expand Down Expand Up @@ -5513,6 +5610,7 @@
columns:
- added_by
- children_project_ids
- component_work_type_names
- components
- construction_start_date
- contract_numbers
Expand Down Expand Up @@ -5565,6 +5663,7 @@
columns:
- added_by
- children_project_ids
- component_work_type_names
- components
- construction_start_date
- contract_numbers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP TRIGGER IF EXISTS set_moped_user_saved_views_updated_at ON moped_user_saved_views;

DROP TABLE moped_user_saved_views;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CREATE TABLE public.moped_user_saved_views (
id serial NOT NULL,
description text NOT NULL,
url text NOT NULL,
query_filters jsonb NOT NULL,
created_by_user_id int4 NOT NULL,
updated_by_user_id int4 NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
is_deleted boolean NOT NULL DEFAULT false
);

ALTER TABLE moped_user_saved_views
ADD CONSTRAINT fk_moped_user_saved_views_created_by FOREIGN KEY (created_by_user_id) REFERENCES moped_users (user_id),
ADD CONSTRAINT fk_moped_user_saved_views_updated_by FOREIGN KEY (updated_by_user_id) REFERENCES moped_users (user_id);

-- Adding comments for audit fields
COMMENT ON COLUMN moped_user_saved_views.description IS 'Description entered by the creator of the view';
COMMENT ON COLUMN moped_user_saved_views.url IS 'URL string associated with the view (may break if database fields or operators are changed)';
COMMENT ON COLUMN moped_user_saved_views.query_filters IS 'JSON blob of filters that make up the query';
COMMENT ON COLUMN moped_user_saved_views.created_by_user_id IS 'User ID of the creator of the view';
COMMENT ON COLUMN moped_user_saved_views.updated_by_user_id IS 'User ID of the last updater of the view';
COMMENT ON COLUMN moped_user_saved_views.created_at IS 'Timestamp of when the view was created';
COMMENT ON COLUMN moped_user_saved_views.updated_at IS 'Timestamp of the last update of the view';
COMMENT ON COLUMN moped_user_saved_views.is_deleted IS 'Boolean indicating whether the view has been soft deleted and thereby not rendered in the UI';

-- Adding comments for moped_user_saved_views constraints
COMMENT ON CONSTRAINT fk_moped_user_saved_views_created_by ON moped_user_saved_views IS 'Foreign key constraint linking created_by_user_id to moped_users table.';
COMMENT ON CONSTRAINT fk_moped_user_saved_views_updated_by ON moped_user_saved_views IS 'Foreign key constraint linking updated_by_user_id to moped_users table.';

CREATE TRIGGER set_moped_user_saved_views_updated_at
BEFORE INSERT OR UPDATE ON moped_user_saved_views
FOR EACH ROW
EXECUTE FUNCTION public.set_updated_at();

COMMENT ON TRIGGER set_moped_user_saved_views_updated_at ON public.moped_user_saved_views IS 'Trigger to set updated_at timestamp for each insert or update on moped_user_saved_views';
28 changes: 16 additions & 12 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.25.1",
"version": "2.26.0",
"homepage": "/moped",
"private": false,
"repository": {
Expand Down
96 changes: 96 additions & 0 deletions moped-editor/src/components/DataGridPro/DataGridActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import {
GridRowModes,
GridActionsCellItem,
useGridApiContext,
useGridSelector,
} from "@mui/x-data-grid-pro";
import CheckIcon from "@mui/icons-material/Check";
import CloseIcon from "@mui/icons-material/Close";
import {
EditOutlined as EditOutlinedIcon,
DeleteOutline as DeleteOutlineIcon,
} from "@mui/icons-material";

import { defaultEditColumnIconStyle } from "src/utils/dataGridHelpers";

/** Component for Data Grid table action buttons
* @param {Number} id - Data Grid row id (same as project id)
* @param {Array} requiredFields - fields that are required in order to save row
* @param {Object} rowModesModel - row modes state from data grid
* @param {Function} handleCancelClick - handles cancel button click
* @param {Function} handleDeleteClick - handles delete button click
* @param {Function} handleSaveClick - handles save button click
* @param {Function} handleEditClick - handles edit button click, optional
* @return {JSX.Element}
*/

const DataGridActions = ({
id,
requiredFields = [],
rowModesModel,
handleCancelClick,
handleDeleteOpen,
handleSaveClick,
handleEditClick,
}) => {
const isInEditMode = rowModesModel[id]?.mode === GridRowModes.Edit;

const apiRef = useGridApiContext();

/**
* To make our row re-render while still in edit mode we need the useGridSelector hook
* which establishes a reactive binding with the grid state and allows us to enable the save button
* if we have all the required fields.
* For reference https://mui.com/x/react-data-grid/state/#access-the-state
*/
const hasRequiredFields = useGridSelector(apiRef, () => {
const editState = apiRef.current.state.editRows;
for (const field of requiredFields) {
if (!editState[id]?.[field]?.value) {
return false;
}
}
return true;
});

if (isInEditMode) {
return [
<GridActionsCellItem
icon={<CheckIcon sx={defaultEditColumnIconStyle} />}
label="Save"
sx={{
color: "primary.main",
}}
onClick={handleSaveClick(id)}
disabled={!hasRequiredFields}
/>,
<GridActionsCellItem
icon={<CloseIcon sx={defaultEditColumnIconStyle} />}
label="Cancel"
className="textPrimary"
onClick={handleCancelClick(id)}
color="inherit"
/>,
];
}
return [
// only render edit button if we were passed an edit handler and are not currently in edit mode
handleEditClick && (
<GridActionsCellItem
icon={<EditOutlinedIcon sx={defaultEditColumnIconStyle} />}
label="Edit"
className="textPrimary"
onClick={handleEditClick(id)}
color="inherit"
/>
),
<GridActionsCellItem
icon={<DeleteOutlineIcon sx={defaultEditColumnIconStyle} />}
label="Delete"
onClick={handleDeleteOpen(id)}
color="inherit"
/>,
];
};

export default DataGridActions;
Loading

0 comments on commit 72167ad

Please sign in to comment.