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

219 status #2646

Merged
merged 8 commits into from
Jan 10, 2025
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
23 changes: 23 additions & 0 deletions bc_obps/reporting/migrations/0043_alter_reportversion_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.10 on 2025-01-02 20:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('reporting', '0042_alter_reportverification_other_facility_coordinates_and_more'),
]

operations = [
migrations.AlterField(
model_name='reportversion',
name='status',
field=models.CharField(
choices=[('Draft', 'Draft'), ('Submitted', 'Submitted')],
db_comment='The status for this report version: Draft or Submitted.',
default='Draft',
max_length=1000,
),
),
]
6 changes: 3 additions & 3 deletions bc_obps/reporting/models/report_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ReportVersion(TimeStampedModel):
)

class ReportVersionStatus(models.TextChoices):
Draft = 'draft'
Submitted = 'submitted'
Draft = 'Draft'
Submitted = 'Submitted'

status = models.CharField(
max_length=1000,
choices=ReportVersionStatus.choices,
db_comment="The status for this report version: draft or submitted.",
db_comment="The status for this report version: Draft or Submitted.",
default=ReportVersionStatus.Draft,
)

Expand Down
2 changes: 1 addition & 1 deletion bc_obps/service/tests/test_report_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_creates_report_with_right_data(self):
report_version = report.report_versions.first()
self.assertEqual(report_version.report, report)
self.assertFalse(report_version.is_latest_submitted)
self.assertEqual(report_version.status, 'draft')
self.assertEqual(report_version.status, 'Draft')

# Testing the report_operation data
self.assertSequenceEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import MoreVertIcon from "@mui/icons-material/MoreVert";
import { actionHandler } from "@bciers/actions";
import { useRouter } from "next/navigation";
import { getReportingYear } from "@reporting/src/app/utils/getReportingYear";
import ReportingOperationStatusCell from "@reporting/src/app/components/operations/cells/ReportingOperationStatusCell";

export const OPERATOR_COLUMN_INDEX = 1;

Expand Down Expand Up @@ -122,6 +123,14 @@ const operationColumns = (): GridColDef[] => {
sortable: false,
width: 120,
},
{
field: "report_status",
headerName: "Status",
renderCell: ReportingOperationStatusCell,
align: "center",
headerAlign: "center",
width: 160,
},
{
field: "more",
headerName: "More",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,20 @@ import {
} from "@mui/x-data-grid";
import EmptyGroupCell from "@bciers/components/datagrid/cells/EmptyGroupCell";
import { OPERATOR_COLUMN_INDEX } from "./operationColumns";
import createColumnGroup from "@bciers/components/datagrid/createColumnGrid";

const operationGroupColumns = (
isOperatorColumn: boolean,
SearchCell: (params: GridColumnGroupHeaderParams) => JSX.Element,
) => {
const columnGroupModel = [
{
groupId: "bcghg_id",
headerName: "BC GHG ID",
renderHeaderGroup: SearchCell,
children: [{ field: "bcghg_id" }],
},
{
groupId: "name",
headerName: "Operation",
renderHeaderGroup: SearchCell,
children: [{ field: "name" }],
},
{
groupId: "submission_date",
headerName: "Submission Date",
renderHeaderGroup: EmptyGroupCell,
children: [{ field: "submission_date" }],
},
{
groupId: "bc_obps_regulated_operation",
headerName: "BORO ID",
renderHeaderGroup: SearchCell,
children: [{ field: "bc_obps_regulated_operation" }],
},
{
groupId: "status",
headerName: "Application Status",
renderHeaderGroup: SearchCell,
children: [{ field: "status" }],
},
{
groupId: "action",
headerName: "Action",
renderHeaderGroup: EmptyGroupCell,
children: [{ field: "action" }],
},
createColumnGroup("bcghg_id", "BC GHG ID", SearchCell),
createColumnGroup("name", "Operation", SearchCell),
createColumnGroup("submission_date", "Submission Date", EmptyGroupCell),
createColumnGroup("bc_obps_regulated_operation", "BORO ID", SearchCell),
createColumnGroup("status", "Application Status", SearchCell),
createColumnGroup("report_status", "Status", SearchCell),
createColumnGroup("action", "Action", EmptyGroupCell),
] as GridColumnGroupingModel;

if (isOperatorColumn) {
gdalcengio marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use client";

import { ReportOperationStatus } from "@bciers/utils/src/enums";
import { Chip, ChipOwnProps } from "@mui/material";
import { GridRenderCellParams } from "@mui/x-data-grid";

export default function ReportingOperationStatusCell(
params: GridRenderCellParams,
) {
const colorMap = new Map<string, ChipOwnProps["color"]>([
[ReportOperationStatus.NOT_STARTED, "primary"],
[ReportOperationStatus.DRAFT, "primary"],
[ReportOperationStatus.SUBMITTED, "success"],
]);
const status = params.value || ReportOperationStatus.NOT_STARTED;
const statusColor = colorMap.get(status) || "primary";
const isMultiLineStatus = status === ReportOperationStatus.NOT_STARTED;

const fontSize = isMultiLineStatus ? "14px" : "16px";
return (
<Chip
label={
<div style={{ whiteSpace: "normal", color: statusColor, fontSize }}>
{status}
</div>
}
variant="outlined"
color={statusColor}
sx={{
width: 100,
height: 40,
borderRadius: "20px",
}}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("operationColumns function", () => {
it("returns an array of column definitions", () => {
const columns: GridColDef[] = operationColumns();

assert(columns.length === 4, "Expected 4 columns");
assert(columns.length === 5, "Expected 5 columns");

assert(
columns[0].field === "bcghg_id",
Expand Down Expand Up @@ -51,14 +51,20 @@ describe("operationColumns function", () => {
);
assert(columns[2].width === 120, "Column 3 width should be 120");

assert(columns[3].field === "more", 'Column 4 field should be "action"');
assert(
columns[3].headerName === "More",
'Column 4 headerName should be "More"',
columns[3].field === "report_status",
'Column 4 field should be "report_status"',
);
assert(columns[3].sortable === false, "Column 4 sortable should be false");
assert(columns[3].width === 120, "Column 4 width should be 120");
assert(columns[3].flex === 1, "Column 4 flex should be 1");
assert(columns[3].width === 160, "Column 4 width should be 160");

assert(columns[4].field === "more", 'Column 5 field should be "action"');
assert(
columns[4].headerName === "More",
'Column 5 headerName should be "More"',
);
assert(columns[4].sortable === false, "Column 4 sortable should be false");
assert(columns[4].width === 120, "Column 4 width should be 120");
assert(columns[4].flex === 1, "Column 4 flex should be 1");
});

it("has a 'start' button in the 'Actions' column when report_id is null", () => {
Expand Down Expand Up @@ -116,7 +122,7 @@ describe("operationColumns function", () => {
name: "Operation without report",
report_id: 1,
report_version_id: 1,
report_status: "draft",
report_status: "Draft",
};

const params = {
Expand All @@ -139,7 +145,7 @@ describe("operationColumns function", () => {
name: "Operation with report",
report_id: 15,
report_version_id: 15,
report_status: "draft",
report_status: "Draft",
};

const params = {
Expand Down
12 changes: 12 additions & 0 deletions bciers/libs/components/src/datagrid/createColumnGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const createColumnGroup = (
groupId: string,
headerName: string,
renderHeaderGroup: any,
) => ({
groupId,
headerName,
renderHeaderGroup,
children: [{ field: groupId }],
});

export default createColumnGroup;
7 changes: 7 additions & 0 deletions bciers/libs/utils/src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ export enum Status {
NOT_STARTED = "Not Started",
}

// report operation statuses
export enum ReportOperationStatus {
NOT_STARTED = "Not started",
DRAFT = "Draft",
SUBMITTED = "Submitted",
}

export enum FormMode {
CREATE = "create",
EDIT = "edit",
Expand Down
Loading