Ability to delete manually entered job lines IO-568
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { FilterFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import { Button, Dropdown, Input, Menu, Table } from "antd";
|
||||
import { DeleteFilled, FilterFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { useMutation, useQuery } from "@apollo/react-hooks";
|
||||
import { Button, Dropdown, Input, Menu, Space, Table } from "antd";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { QUERY_BILLS_BY_JOB_REF } from "../../graphql/bill-lines.queries";
|
||||
import { DELETE_JOB_LINE_BY_PK } from "../../graphql/jobs-lines.queries";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { onlyUnique } from "../../utils/arrayHelper";
|
||||
@@ -18,7 +19,6 @@ import JobLinesBillRefernece from "../job-lines-bill-reference/job-lines-bill-re
|
||||
// import AllocationsBulkAssignmentContainer from "../allocations-bulk-assignment/allocations-bulk-assignment.container";
|
||||
// import AllocationsEmployeeLabelContainer from "../allocations-employee-label/allocations-employee-label.container";
|
||||
import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
jobRO: selectJobReadOnly,
|
||||
@@ -44,6 +44,7 @@ export function JobLinesComponent({
|
||||
setJobLineEditContext,
|
||||
form,
|
||||
}) {
|
||||
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
|
||||
const {
|
||||
loading: billLinesLoading,
|
||||
error: billLinesError,
|
||||
@@ -53,9 +54,7 @@ export function JobLinesComponent({
|
||||
skip: loading,
|
||||
});
|
||||
|
||||
console.log("billLinesLoading :>> ", billLinesLoading);
|
||||
const billLinesDataObj = useMemo(() => {
|
||||
console.log("Memoized object called");
|
||||
if (!billLinesData) return {};
|
||||
const ret = {};
|
||||
billLinesData.billlines.map((b) => {
|
||||
@@ -292,7 +291,7 @@ export function JobLinesComponent({
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<div>
|
||||
<Space>
|
||||
<Button
|
||||
disabled={jobRO}
|
||||
onClick={() => {
|
||||
@@ -304,6 +303,29 @@ export function JobLinesComponent({
|
||||
>
|
||||
{t("general.actions.edit")}
|
||||
</Button>
|
||||
{record.manual_line && (
|
||||
<Button
|
||||
onClick={() =>
|
||||
deleteJobLine({
|
||||
variables: { joblineId: record.id },
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
id: cache.identify(job),
|
||||
fields: {
|
||||
joblines(existingJobLines, { readField }) {
|
||||
return existingJobLines.filter(
|
||||
(jlRef) => record.id !== readField("id", jlRef)
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
<DeleteFilled />
|
||||
</Button>
|
||||
)}
|
||||
{
|
||||
// <AllocationsAssignmentContainer
|
||||
// key={record.id}
|
||||
@@ -312,7 +334,7 @@ export function JobLinesComponent({
|
||||
// hours={record.mod_lb_hrs}
|
||||
// />
|
||||
}
|
||||
</div>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -33,7 +33,15 @@ function JobLinesUpsertModalContainer({
|
||||
if (!jobLineEditModal.context.id) {
|
||||
insertJobLine({
|
||||
variables: {
|
||||
lineInput: [{ jobid: jobLineEditModal.context.jobid, ...values }],
|
||||
lineInput: [
|
||||
{
|
||||
jobid: jobLineEditModal.context.jobid,
|
||||
manual_line: !(
|
||||
jobLineEditModal.context && jobLineEditModal.context.id
|
||||
),
|
||||
...values,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.then((r) => {
|
||||
|
||||
@@ -30,6 +30,7 @@ export default function DuplicateJob(
|
||||
_tempLines.forEach((line) => {
|
||||
delete line.id;
|
||||
delete line.__typename;
|
||||
line.manual_line = true;
|
||||
});
|
||||
|
||||
delete newJob.joblines;
|
||||
|
||||
@@ -180,3 +180,11 @@ export const generateJobLinesUpdatesForInvoicing = (joblines) => {
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
export const DELETE_JOB_LINE_BY_PK = gql`
|
||||
mutation DELETE_JOB_LINE_BY_PK($joblineId: uuid!) {
|
||||
delete_joblines_by_pk(id: $joblineId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -495,6 +495,7 @@ export const GET_JOB_BY_PK = gql`
|
||||
location
|
||||
tax_part
|
||||
db_ref
|
||||
manual_line
|
||||
parts_order_lines {
|
||||
id
|
||||
parts_order {
|
||||
@@ -1081,6 +1082,7 @@ export const QUERY_ALL_JOB_FIELDS = gql`
|
||||
status
|
||||
tax_part
|
||||
unq_seq
|
||||
manual_line
|
||||
}
|
||||
employee_body
|
||||
employee_refinish
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
"newline": "New Line"
|
||||
},
|
||||
"fields": {
|
||||
"actual": "Actual",
|
||||
"actual": "List Price",
|
||||
"actual_cost": "Actual Cost",
|
||||
"cost_center": "Cost Center",
|
||||
"federal_tax_applicable": "Fed. Tax?",
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: ALTER TABLE "public"."joblines" DROP COLUMN "manual_line";
|
||||
type: run_sql
|
||||
@@ -0,0 +1,6 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: ALTER TABLE "public"."joblines" ADD COLUMN "manual_line" boolean NOT NULL
|
||||
DEFAULT false;
|
||||
type: run_sql
|
||||
@@ -0,0 +1,81 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_insert_permission
|
||||
- args:
|
||||
permission:
|
||||
check:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- act_price
|
||||
- alt_co_id
|
||||
- alt_overrd
|
||||
- alt_part_i
|
||||
- alt_partm
|
||||
- alt_partno
|
||||
- bett_amt
|
||||
- bett_pctg
|
||||
- bett_tax
|
||||
- bett_type
|
||||
- cert_part
|
||||
- created_at
|
||||
- db_hrs
|
||||
- db_price
|
||||
- db_ref
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- jobid
|
||||
- lbr_amt
|
||||
- lbr_hrs_j
|
||||
- lbr_inc
|
||||
- lbr_op
|
||||
- lbr_op_j
|
||||
- lbr_tax
|
||||
- lbr_typ_j
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
- mod_lb_hrs
|
||||
- mod_lbr_ty
|
||||
- notes
|
||||
- oem_partno
|
||||
- op_code_desc
|
||||
- paint_stg
|
||||
- paint_tone
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_inc
|
||||
- price_j
|
||||
- profitcenter_labor
|
||||
- profitcenter_part
|
||||
- prt_dsmk_m
|
||||
- prt_dsmk_p
|
||||
- removed
|
||||
- status
|
||||
- sublet_completed
|
||||
- sublet_ignored
|
||||
- tax_part
|
||||
- unq_seq
|
||||
- updated_at
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_insert_permission
|
||||
@@ -0,0 +1,82 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_insert_permission
|
||||
- args:
|
||||
permission:
|
||||
check:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- act_price
|
||||
- alt_co_id
|
||||
- alt_overrd
|
||||
- alt_part_i
|
||||
- alt_partm
|
||||
- alt_partno
|
||||
- bett_amt
|
||||
- bett_pctg
|
||||
- bett_tax
|
||||
- bett_type
|
||||
- cert_part
|
||||
- created_at
|
||||
- db_hrs
|
||||
- db_price
|
||||
- db_ref
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- jobid
|
||||
- lbr_amt
|
||||
- lbr_hrs_j
|
||||
- lbr_inc
|
||||
- lbr_op
|
||||
- lbr_op_j
|
||||
- lbr_tax
|
||||
- lbr_typ_j
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- manual_line
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
- mod_lb_hrs
|
||||
- mod_lbr_ty
|
||||
- notes
|
||||
- oem_partno
|
||||
- op_code_desc
|
||||
- paint_stg
|
||||
- paint_tone
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_inc
|
||||
- price_j
|
||||
- profitcenter_labor
|
||||
- profitcenter_part
|
||||
- prt_dsmk_m
|
||||
- prt_dsmk_p
|
||||
- removed
|
||||
- status
|
||||
- sublet_completed
|
||||
- sublet_ignored
|
||||
- tax_part
|
||||
- unq_seq
|
||||
- updated_at
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_insert_permission
|
||||
@@ -0,0 +1,82 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: true
|
||||
columns:
|
||||
- act_price
|
||||
- alt_co_id
|
||||
- alt_overrd
|
||||
- alt_part_i
|
||||
- alt_partm
|
||||
- alt_partno
|
||||
- bett_amt
|
||||
- bett_pctg
|
||||
- bett_tax
|
||||
- bett_type
|
||||
- cert_part
|
||||
- created_at
|
||||
- db_hrs
|
||||
- db_price
|
||||
- db_ref
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- jobid
|
||||
- lbr_amt
|
||||
- lbr_hrs_j
|
||||
- lbr_inc
|
||||
- lbr_op
|
||||
- lbr_op_j
|
||||
- lbr_tax
|
||||
- lbr_typ_j
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
- mod_lb_hrs
|
||||
- mod_lbr_ty
|
||||
- notes
|
||||
- oem_partno
|
||||
- op_code_desc
|
||||
- paint_stg
|
||||
- paint_tone
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_inc
|
||||
- price_j
|
||||
- profitcenter_labor
|
||||
- profitcenter_part
|
||||
- prt_dsmk_m
|
||||
- prt_dsmk_p
|
||||
- removed
|
||||
- status
|
||||
- sublet_completed
|
||||
- sublet_ignored
|
||||
- tax_part
|
||||
- unq_seq
|
||||
- updated_at
|
||||
computed_fields: []
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,83 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: true
|
||||
columns:
|
||||
- act_price
|
||||
- alt_co_id
|
||||
- alt_overrd
|
||||
- alt_part_i
|
||||
- alt_partm
|
||||
- alt_partno
|
||||
- bett_amt
|
||||
- bett_pctg
|
||||
- bett_tax
|
||||
- bett_type
|
||||
- cert_part
|
||||
- created_at
|
||||
- db_hrs
|
||||
- db_price
|
||||
- db_ref
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- jobid
|
||||
- lbr_amt
|
||||
- lbr_hrs_j
|
||||
- lbr_inc
|
||||
- lbr_op
|
||||
- lbr_op_j
|
||||
- lbr_tax
|
||||
- lbr_typ_j
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- manual_line
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
- mod_lb_hrs
|
||||
- mod_lbr_ty
|
||||
- notes
|
||||
- oem_partno
|
||||
- op_code_desc
|
||||
- paint_stg
|
||||
- paint_tone
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_inc
|
||||
- price_j
|
||||
- profitcenter_labor
|
||||
- profitcenter_part
|
||||
- prt_dsmk_m
|
||||
- prt_dsmk_p
|
||||
- removed
|
||||
- status
|
||||
- sublet_completed
|
||||
- sublet_ignored
|
||||
- tax_part
|
||||
- unq_seq
|
||||
- updated_at
|
||||
computed_fields: []
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,81 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_update_permission
|
||||
- args:
|
||||
permission:
|
||||
columns:
|
||||
- act_price
|
||||
- alt_co_id
|
||||
- alt_overrd
|
||||
- alt_part_i
|
||||
- alt_partm
|
||||
- alt_partno
|
||||
- bett_amt
|
||||
- bett_pctg
|
||||
- bett_tax
|
||||
- bett_type
|
||||
- cert_part
|
||||
- created_at
|
||||
- db_hrs
|
||||
- db_price
|
||||
- db_ref
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- jobid
|
||||
- lbr_amt
|
||||
- lbr_hrs_j
|
||||
- lbr_inc
|
||||
- lbr_op
|
||||
- lbr_op_j
|
||||
- lbr_tax
|
||||
- lbr_typ_j
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
- mod_lb_hrs
|
||||
- mod_lbr_ty
|
||||
- notes
|
||||
- oem_partno
|
||||
- op_code_desc
|
||||
- paint_stg
|
||||
- paint_tone
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_inc
|
||||
- price_j
|
||||
- profitcenter_labor
|
||||
- profitcenter_part
|
||||
- prt_dsmk_m
|
||||
- prt_dsmk_p
|
||||
- removed
|
||||
- status
|
||||
- sublet_completed
|
||||
- sublet_ignored
|
||||
- tax_part
|
||||
- unq_seq
|
||||
- updated_at
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_update_permission
|
||||
@@ -0,0 +1,82 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_update_permission
|
||||
- args:
|
||||
permission:
|
||||
columns:
|
||||
- act_price
|
||||
- alt_co_id
|
||||
- alt_overrd
|
||||
- alt_part_i
|
||||
- alt_partm
|
||||
- alt_partno
|
||||
- bett_amt
|
||||
- bett_pctg
|
||||
- bett_tax
|
||||
- bett_type
|
||||
- cert_part
|
||||
- created_at
|
||||
- db_hrs
|
||||
- db_price
|
||||
- db_ref
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- jobid
|
||||
- lbr_amt
|
||||
- lbr_hrs_j
|
||||
- lbr_inc
|
||||
- lbr_op
|
||||
- lbr_op_j
|
||||
- lbr_tax
|
||||
- lbr_typ_j
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- manual_line
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
- mod_lb_hrs
|
||||
- mod_lbr_ty
|
||||
- notes
|
||||
- oem_partno
|
||||
- op_code_desc
|
||||
- paint_stg
|
||||
- paint_tone
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_inc
|
||||
- price_j
|
||||
- profitcenter_labor
|
||||
- profitcenter_part
|
||||
- prt_dsmk_m
|
||||
- prt_dsmk_p
|
||||
- removed
|
||||
- status
|
||||
- sublet_completed
|
||||
- sublet_ignored
|
||||
- tax_part
|
||||
- unq_seq
|
||||
- updated_at
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_update_permission
|
||||
@@ -1769,6 +1769,7 @@ tables:
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- manual_line
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
@@ -1829,6 +1830,7 @@ tables:
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- manual_line
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
@@ -1900,6 +1902,7 @@ tables:
|
||||
- line_no
|
||||
- line_ref
|
||||
- location
|
||||
- manual_line
|
||||
- misc_amt
|
||||
- misc_sublt
|
||||
- misc_tax
|
||||
|
||||
Reference in New Issue
Block a user