From e285cfa2b08c971f5002259d69cf9d4110ef2d44 Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Mon, 3 May 2021 12:30:23 -0700
Subject: [PATCH] IO-979 Delete parts orders.
---
bodyshop_translations.babel | 21 +++++++++
.../job-detail-lines/job-lines.component.jsx | 12 ++++++
.../parts-order-list-table.component.jsx | 43 ++++++++++++++++---
client/src/graphql/parts-orders.queries.js | 8 ++++
client/src/translations/en_us/common.json | 3 +-
client/src/translations/es/common.json | 1 +
client/src/translations/fr/common.json | 1 +
7 files changed, 82 insertions(+), 7 deletions(-)
diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index 379a97df2..95d869399 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -26439,6 +26439,27 @@
+
+ confirmdelete
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
email
false
diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx
index 5b60a355d..c6376866a 100644
--- a/client/src/components/job-detail-lines/job-lines.component.jsx
+++ b/client/src/components/job-detail-lines/job-lines.component.jsx
@@ -413,6 +413,18 @@ export function JobLinesComponent({
scroll={{
x: true,
}}
+ onRow={(record, rowIndex) => {
+ return {
+ onDoubleClick: (event) => {
+ const notMatchingLines = selectedLines.filter(
+ (i) => i.id !== record.id
+ );
+ notMatchingLines.length !== selectedLines.length
+ ? setSelectedLines(notMatchingLines)
+ : setSelectedLines([...selectedLines, record]);
+ }, // double click row
+ };
+ }}
rowSelection={{
selectedRowKeys: selectedLines.map((item) => item.id),
onSelectAll: (selected, selectedRows, changeRows) => {
diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx
index 6ee708aa6..85bb05dda 100644
--- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx
+++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx
@@ -1,4 +1,5 @@
-import { EyeFilled, SyncOutlined } from "@ant-design/icons";
+import { DeleteFilled, EyeFilled, SyncOutlined } from "@ant-design/icons";
+import { useMutation } from "@apollo/client";
import {
Button,
Card,
@@ -7,6 +8,7 @@ import {
Grid,
Input,
PageHeader,
+ Popconfirm,
Space,
Table,
} from "antd";
@@ -17,6 +19,7 @@ import { connect } from "react-redux";
import { useLocation } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils";
+import { DELETE_PARTS_ORDER } from "../../graphql/parts-orders.queries";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
@@ -74,6 +77,8 @@ export function PartsOrderListTableComponent({
const search = queryString.parse(useLocation().search);
const selectedpartsorder = search.partsorderid;
+ const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER);
+
const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : [];
const { refetch } = billsQuery;
@@ -88,7 +93,6 @@ export function PartsOrderListTableComponent({
disabled={jobRO || record.return}
onClick={() => {
logImEXEvent("parts_order_receive_bill");
-
setPartsReceiveContext({
actions: { refetch: refetch },
context: {
@@ -107,6 +111,31 @@ export function PartsOrderListTableComponent({
>
{t("parts_orders.actions.receive")}
+ {
+ //Delete the parts return.!
+
+ await deletePartsOrder({
+ variables: { partsOrderId: record.id },
+ update(cache) {
+ cache.modify({
+ fields: {
+ parts_orders(existingPartsOrders, { readField }) {
+ return existingPartsOrders.filter(
+ (billref) => record.id !== readField("id", billref)
+ );
+ },
+ },
+ });
+ },
+ });
+ }}
+ >
+
+