From 092b09b6d5d2a0883b7149e1ba6d7e14b8965ecb Mon Sep 17 00:00:00 2001 From: VineetBala-AOT Date: Tue, 7 Jan 2025 10:04:56 -0800 Subject: [PATCH] Data Structuring and Colour/Text Edits --- .../services/condition_service.py | 1 + .../services/document_service.py | 12 +++++- .../ConditionDetails/ConditionHeader.tsx | 26 +++++++++---- .../ConditionDetails/ConditionInfoTabs.tsx | 37 ++++++++++++++++--- .../ConditionDetails/SubCondition.tsx | 7 +++- .../Conditions/ConditionTableRow.tsx | 13 ++++++- .../components/Conditions/ConditionsTable.tsx | 20 +++++----- .../src/components/Conditions/index.tsx | 8 ++-- .../src/components/Documents/index.tsx | 4 +- .../src/components/Projects/index.tsx | 7 +++- 10 files changed, 103 insertions(+), 32 deletions(-) diff --git a/condition-api/src/condition_api/services/condition_service.py b/condition-api/src/condition_api/services/condition_service.py index 7864b01..282d1bc 100644 --- a/condition-api/src/condition_api/services/condition_service.py +++ b/condition-api/src/condition_api/services/condition_service.py @@ -308,6 +308,7 @@ def get_all_conditions(project_id, document_id): date_issued_query, document_label_query ) + .order_by(conditions.condition_number) .all() ) diff --git a/condition-api/src/condition_api/services/document_service.py b/condition-api/src/condition_api/services/document_service.py index 85ab47d..6ef812d 100644 --- a/condition-api/src/condition_api/services/document_service.py +++ b/condition-api/src/condition_api/services/document_service.py @@ -24,6 +24,7 @@ def get_all_documents_by_category(project_id, category_id): Document.id.label('id'), Document.document_id.label('document_id'), Document.document_label.label('document_label'), + Document.created_date, extract('year', Document.date_issued).label('year_issued'), case( (func.count(Condition.id) == 0, None), @@ -50,6 +51,7 @@ def get_all_documents_by_category(project_id, category_id): Document.id, Document.document_id, Document.document_label, + Document.created_date, Document.date_issued ).all() @@ -66,6 +68,7 @@ def get_all_documents_by_category(project_id, category_id): amendments_query = db.session.query( Amendment.amended_document_id.label('document_id'), Amendment.amendment_name.label('document_label'), + Amendment.created_date, extract('year', Amendment.date_issued).label('year_issued'), case( (func.count(Condition.id) == 0, None), @@ -77,13 +80,17 @@ def get_all_documents_by_category(project_id, category_id): ).filter( Amendment.document_id == document.id ).group_by( - Amendment.amended_document_id, Amendment.amendment_name, Amendment.date_issued + Amendment.amended_document_id, + Amendment.amendment_name, + Amendment.created_date, + Amendment.date_issued ).all() # Append the main document to the result list result.append({ 'document_id': document.document_id, 'document_label': document.document_label, + 'created_date': document.created_date, 'year_issued': document.year_issued, 'status': document.status }) @@ -93,6 +100,7 @@ def get_all_documents_by_category(project_id, category_id): result.append({ 'document_id': amendment.document_id, 'document_label': amendment.document_label, + 'created_date': amendment.created_date, 'year_issued': amendment.year_issued, 'status': amendment.status }) @@ -100,7 +108,7 @@ def get_all_documents_by_category(project_id, category_id): project_name = documents[0].project_name if documents else None document_category = documents[0].document_category if documents else None - sorted_result = sorted(result, key=lambda x: x['year_issued'], reverse=True) + sorted_result = sorted(result, key=lambda x: x['created_date']) return { "project_name": project_name, "document_category": document_category, diff --git a/condition-web/src/components/ConditionDetails/ConditionHeader.tsx b/condition-web/src/components/ConditionDetails/ConditionHeader.tsx index 02762d1..ad736f3 100644 --- a/condition-web/src/components/ConditionDetails/ConditionHeader.tsx +++ b/condition-web/src/components/ConditionDetails/ConditionHeader.tsx @@ -1,8 +1,8 @@ import { useEffect, useState } from "react"; import { Box, Button, Grid, Stack, Typography } from "@mui/material"; -import ContentCopyOutlinedIcon from '@mui/icons-material/ContentCopyOutlined'; +import LayersOutlinedIcon from '@mui/icons-material/LayersOutlined'; import EditIcon from '@mui/icons-material/Edit'; -import { Save } from "@mui/icons-material"; +import SaveAltIcon from '@mui/icons-material/SaveAlt'; import DocumentStatusChip from "../Projects/DocumentStatusChip"; import { ConditionModel } from "@/models/Condition"; import { DocumentStatus } from "@/models/Document"; @@ -79,7 +79,7 @@ const ConditionHeader = ({ {condition?.condition_name} - + {!condition.is_topic_tags_approved && (