From afc674d74cfaf866baeafe77edeb5f49f2d52bc8 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 7 Feb 2022 19:31:08 -0800 Subject: [PATCH] IO-1676 Add RO Comment. --- bodyshop_translations.babel | 42 ++++++++++ .../jobs-detail-header.component.jsx | 7 ++ .../jobs-list-paginated.component.jsx | 27 ++++--- .../jobs-list/jobs-list.component.jsx | 10 +++ ...duction-list-columns.comment.component.jsx | 79 +++++++++++++++++++ .../production-list-columns.data.js | 20 ++++- client/src/graphql/jobs.queries.js | 32 ++------ client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + hasura/metadata/tables.yaml | 3 + .../down.sql | 4 + .../up.sql | 2 + server/graphql-client/queries.js | 1 + 14 files changed, 196 insertions(+), 37 deletions(-) create mode 100644 client/src/components/production-list-columns/production-list-columns.comment.component.jsx create mode 100644 hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/down.sql create mode 100644 hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 5879459cd..5070b9dad 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -20350,6 +20350,27 @@ + + comment + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + customerowing false @@ -36125,6 +36146,27 @@ + + comment + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + compact false diff --git a/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx b/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx index 86fbde089..59ca3821c 100644 --- a/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx +++ b/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx @@ -21,6 +21,7 @@ import ProductionListColumnProductionNote from "../production-list-columns/produ import "./jobs-detail-header.styles.scss"; import JobsRelatedRos from "../jobs-related-ros/jobs-related-ros.component"; import { DateTimeFormatter } from "../../utils/DateFormatter"; +import ProductionListColumnComment from "../production-list-columns/production-list-columns.comment.component"; const mapStateToProps = createStructuredSelector({ jobRO: selectJobReadOnly, @@ -86,6 +87,12 @@ export function JobsDetailHeader({ job, bodyshop, disabled }) { ) : null} + + + {job.ins_co_nm} diff --git a/client/src/components/jobs-list-paginated/jobs-list-paginated.component.jsx b/client/src/components/jobs-list-paginated/jobs-list-paginated.component.jsx index a751be3e2..2a6ea300b 100644 --- a/client/src/components/jobs-list-paginated/jobs-list-paginated.component.jsx +++ b/client/src/components/jobs-list-paginated/jobs-list-paginated.component.jsx @@ -30,7 +30,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.ro_number"), dataIndex: "ro_number", key: "ro_number", - width: "8%", + sorter: true, //(a, b) => alphaSort(a.ro_number, b.ro_number), sortOrder: sortcolumn === "ro_number" && sortorder, @@ -47,7 +47,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { key: "ownr_ln", ellipsis: true, //sorter: true, // (a, b) => alphaSort(a.ownr_ln, b.ownr_ln), - width: "25%", + //sortOrder: sortcolumn === "ownr_ln" && sortorder, render: (text, record) => { return record.ownerid ? ( @@ -67,7 +67,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.ownr_ph1"), dataIndex: "ownr_ph1", key: "ownr_ph1", - width: "12%", + ellipsis: true, render: (text, record) => ( @@ -77,7 +77,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.ownr_ph2"), dataIndex: "ownr_ph2", key: "ownr_ph2", - width: "12%", + ellipsis: true, render: (text, record) => ( @@ -87,7 +87,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.status"), dataIndex: "status", key: "status", - width: "10%", + ellipsis: true, sorter: true, // (a, b) => alphaSort(a.status, b.status), sortOrder: sortcolumn === "status" && sortorder, @@ -104,7 +104,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.vehicle"), dataIndex: "vehicle", key: "vehicle", - width: "15%", + ellipsis: true, render: (text, record) => { return record.vehicleid ? ( @@ -124,7 +124,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("vehicles.fields.plate_no"), dataIndex: "plate_no", key: "plate_no", - width: "8%", + ellipsis: true, sorter: true, //(a, b) => alphaSort(a.plate_no, b.plate_no), sortOrder: sortcolumn === "plate_no" && sortorder, @@ -136,7 +136,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.clm_no"), dataIndex: "clm_no", key: "clm_no", - width: "12%", + ellipsis: true, sorter: true, //(a, b) => alphaSort(a.clm_no, b.clm_no), sortOrder: sortcolumn === "clm_no" && sortorder, @@ -155,7 +155,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.clm_total"), dataIndex: "clm_total", key: "clm_total", - width: "10%", + sorter: true, //(a, b) => a.clm_total - b.clm_total, sortOrder: sortcolumn === "clm_total" && sortorder, render: (text, record) => { @@ -170,11 +170,17 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { title: t("jobs.fields.owner_owing"), dataIndex: "owner_owing", key: "owner_owing", - width: "8%", + render: (text, record) => ( {record.owner_owing} ), }, + { + title: t("jobs.fields.comment"), + dataIndex: "comment", + key: "comment", + ellipsis: true, + }, ]; const handleTableChange = (pagination, filters, sorter) => { @@ -224,7 +230,6 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { > {record.clm_total} ), }, + { + title: t("jobs.fields.comment"), + dataIndex: "comment", + key: "comment", + ellipsis: true, + responsive: ["md"], + }, // { // title: t("jobs.fields.owner_owing"), // dataIndex: "owner_owing", diff --git a/client/src/components/production-list-columns/production-list-columns.comment.component.jsx b/client/src/components/production-list-columns/production-list-columns.comment.component.jsx new file mode 100644 index 000000000..fafccff93 --- /dev/null +++ b/client/src/components/production-list-columns/production-list-columns.comment.component.jsx @@ -0,0 +1,79 @@ +import Icon from "@ant-design/icons"; +import { useMutation } from "@apollo/client"; +import { Button, Input, Popover } from "antd"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { FaRegStickyNote } from "react-icons/fa"; +import { UPDATE_JOB } from "../../graphql/jobs.queries"; +export default function ProductionListColumnComment({ record }) { + const { t } = useTranslation(); + + const [note, setNote] = useState(record.comment || ""); + + const [visible, setVisible] = useState(false); + + const [updateAlert] = useMutation(UPDATE_JOB); + + const handleSaveNote = (e) => { + e.stopPropagation(); + setVisible(false); + updateAlert({ + variables: { + jobId: record.id, + job: { + comment: note, + }, + }, + }).then(() => { + if (record.refetch) record.refetch(); + }); + }; + + const handleChange = (e) => { + e.stopPropagation(); + setNote(e.target.value); + }; + + const handleVisibleChange = (flag) => { + setVisible(flag); + if (flag) setNote(record.comment || ""); + }; + + return ( + + +
+ +
+ + } + trigger={["click"]} + > +
+ + {record.comment || " "} +
+
+ ); +} diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index d8d547665..240d8074b 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -20,6 +20,7 @@ import ProductionListColumnNote from "./production-list-columns.productionnote.c import ProductionListColumnStatus from "./production-list-columns.status.component"; import ProductionListColumnCategory from "./production-list-columns.status.category"; import ProductionlistColumnTouchTime from "./prodution-list-columns.touchtime.component"; +import ProductionListColumnComment from "./production-list-columns.comment.component"; const r = ({ technician, state, activeStatuses, bodyshop }) => { return [ @@ -109,7 +110,11 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { state.sortedInfo.columnKey === "scheduled_completion" && state.sortedInfo.order, render: (text, record) => ( - + ), }, { @@ -156,7 +161,11 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { state.sortedInfo.columnKey === "scheduled_delivery" && state.sortedInfo.order, render: (text, record) => ( - + ), }, { @@ -325,6 +334,13 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { ellipsis: true, render: (text, record) => , }, + { + title: i18n.t("production.labels.comment"), + dataIndex: "comment", + key: "comment", + ellipsis: true, + render: (text, record) => , + }, { title: i18n.t("production.labels.touchtime"), dataIndex: "tt", diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 8f927d4ff..9d0641d8a 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -12,11 +12,7 @@ export const QUERY_ALL_ACTIVE_JOBS = gql` ownr_ph1 ownr_ph2 ownr_ea - owner { - id - allow_text_message - preferred_contact - } + comment plate_no plate_st v_vin @@ -121,6 +117,7 @@ export const QUERY_EXACT_JOB_IN_PRODUCTION = gql` id status ro_number + comment ownr_fn ownr_ln category @@ -193,6 +190,7 @@ export const QUERY_EXACT_JOBS_IN_PRODUCTION = gql` id status ro_number + comment ownr_fn category ownr_ln @@ -264,6 +262,7 @@ export const QUERY_JOBS_IN_PRODUCTION = gql` jobs(where: { inproduction: { _eq: true } }) { id updated_at + comment status category ro_number @@ -489,6 +488,7 @@ export const GET_JOB_BY_PK = gql` alt_transport intakechecklist invoice_final_note + comment loss_desc kmin kmout @@ -830,6 +830,7 @@ export const QUERY_JOB_CARD_DETAILS = gql` ownr_co_nm ownr_ph1 ownr_ph2 + comment ownr_ea ca_gst_registrant owner_owing @@ -1034,7 +1035,7 @@ export const UPDATE_JOB = gql` update_jobs(where: { id: { _eq: $jobId } }, _set: $job) { returning { id - + comment date_exported status alt_transport @@ -1766,13 +1767,12 @@ export const QUERY_ALL_JOBS_PAGINATED_STATUS_FILTERED = gql` order_by: $order where: { status: { _in: $statusList } } ) { + comment ownr_fn ownr_ln ownr_co_nm - ownerid ownr_ph1 ownr_ph2 - ownr_ea plate_no plate_st v_vin @@ -1781,32 +1781,16 @@ export const QUERY_ALL_JOBS_PAGINATED_STATUS_FILTERED = gql` v_make_desc v_color vehicleid - actual_completion - actual_delivery - actual_in id ins_co_nm - ins_ct_fn - ins_ct_ln - ins_ph1 - ins_ea - est_co_nm - est_ph1 - est_ea - est_ct_fn - est_ct_ln clm_no clm_total owner_owing ro_number po_number - scheduled_completion - scheduled_in - scheduled_delivery status updated_at ded_amt - vehicleid } search_jobs_aggregate( args: { search: $search } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 0f537f652..d80f8950a 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1243,6 +1243,7 @@ "class": "Class", "clm_no": "Claim #", "clm_total": "Claim Total", + "comment": "Comment", "customerowing": "Customer Owing", "date_estimated": "Date Estimated", "date_exported": "Exported", @@ -2151,6 +2152,7 @@ "bodypriority": "B/P", "cardsettings": "Card Settings", "clm_no": "Claim Number", + "comment": "Comment", "compact": "Compact Cards", "detailpriority": "D/P", "employeeassignments": "Employee Assignments", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index aa5169aa4..29ff8e820 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1243,6 +1243,7 @@ "class": "", "clm_no": "Reclamación #", "clm_total": "Reclamar total", + "comment": "", "customerowing": "Cliente debido", "date_estimated": "Fecha estimada", "date_exported": "Exportado", @@ -2151,6 +2152,7 @@ "bodypriority": "", "cardsettings": "", "clm_no": "", + "comment": "", "compact": "", "detailpriority": "", "employeeassignments": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 37be43e40..655f3fc02 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1243,6 +1243,7 @@ "class": "", "clm_no": "Prétendre #", "clm_total": "Total réclamation", + "comment": "", "customerowing": "Client propriétaire", "date_estimated": "Date estimée", "date_exported": "Exportés", @@ -2151,6 +2152,7 @@ "bodypriority": "", "cardsettings": "", "clm_no": "", + "comment": "", "compact": "", "detailpriority": "", "employeeassignments": "", diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 0ce2ea143..3f989dc2c 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -2709,6 +2709,7 @@ - clm_title - clm_total - clm_zip + - comment - converted - created_at - cust_pr @@ -2965,6 +2966,7 @@ - clm_title - clm_total - clm_zip + - comment - converted - created_at - cust_pr @@ -3231,6 +3233,7 @@ - clm_title - clm_total - clm_zip + - comment - converted - created_at - cust_pr diff --git a/hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/down.sql b/hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/down.sql new file mode 100644 index 000000000..db9525eff --- /dev/null +++ b/hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."jobs" add column "comment" text +-- null; diff --git a/hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/up.sql b/hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/up.sql new file mode 100644 index 000000000..f0393cfcb --- /dev/null +++ b/hasura/migrations/1644289021089_alter_table_public_jobs_add_column_comment/up.sql @@ -0,0 +1,2 @@ +alter table "public"."jobs" add column "comment" text + null; diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index a1ad30545..d5bb2a3f8 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -834,6 +834,7 @@ exports.GET_JOB_BY_PK = ` query GET_JOB_BY_PK($id: uuid!) { loss_desc kmin kmout + comment referral_source referral_source_extra unit_number