From cb503e392f081ebc7cdad4e79693b3e5fe72cb0c Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 20 Jan 2021 10:47:08 -0800 Subject: [PATCH] Ability to delete manually entered job lines IO-568 --- .../job-detail-lines/job-lines.component.jsx | 38 +++++++-- .../job-lines-upsert-modal.container.jsx | 10 ++- ...bs-detail-header-actions.duplicate.util.js | 1 + client/src/graphql/jobs-lines.queries.js | 8 ++ client/src/graphql/jobs.queries.js | 2 + client/src/translations/en_us/common.json | 2 +- .../down.yaml | 5 ++ .../up.yaml | 6 ++ .../down.yaml | 81 ++++++++++++++++++ .../up.yaml | 82 ++++++++++++++++++ .../down.yaml | 82 ++++++++++++++++++ .../up.yaml | 83 +++++++++++++++++++ .../down.yaml | 81 ++++++++++++++++++ .../up.yaml | 82 ++++++++++++++++++ hasura/migrations/metadata.yaml | 3 + 15 files changed, 556 insertions(+), 10 deletions(-) create mode 100644 hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/down.yaml create mode 100644 hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/up.yaml create mode 100644 hasura/migrations/1611165639521_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1611165639521_update_permission_user_public_table_joblines/up.yaml create mode 100644 hasura/migrations/1611165651041_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1611165651041_update_permission_user_public_table_joblines/up.yaml create mode 100644 hasura/migrations/1611165680112_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1611165680112_update_permission_user_public_table_joblines/up.yaml 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 f8fd87d2b..85c7ee393 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -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) => ( -
+ + {record.manual_line && ( + + )} { // } -
+ ), }, ]; diff --git a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx index 615b70df0..5cf8c211a 100644 --- a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx +++ b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx @@ -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) => { diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js index 17f1a75a8..ef812c934 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js @@ -30,6 +30,7 @@ export default function DuplicateJob( _tempLines.forEach((line) => { delete line.id; delete line.__typename; + line.manual_line = true; }); delete newJob.joblines; diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index 0eb0b1f22..abafd438e 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -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 + } + } +`; diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 88f301c56..2750f9447 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -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 diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 9618a2727..6a02ffc12 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -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?", diff --git a/hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/down.yaml b/hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/down.yaml new file mode 100644 index 000000000..c85404ff9 --- /dev/null +++ b/hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."joblines" DROP COLUMN "manual_line"; + type: run_sql diff --git a/hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/up.yaml b/hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/up.yaml new file mode 100644 index 000000000..32d081b42 --- /dev/null +++ b/hasura/migrations/1611165627078_alter_table_public_joblines_add_column_manual_line/up.yaml @@ -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 diff --git a/hasura/migrations/1611165639521_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1611165639521_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 000000000..ff9ac5fde --- /dev/null +++ b/hasura/migrations/1611165639521_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1611165639521_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1611165639521_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 000000000..abd20d1ed --- /dev/null +++ b/hasura/migrations/1611165639521_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1611165651041_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1611165651041_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 000000000..5c724e8f3 --- /dev/null +++ b/hasura/migrations/1611165651041_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1611165651041_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1611165651041_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 000000000..8bca3a998 --- /dev/null +++ b/hasura/migrations/1611165651041_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1611165680112_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1611165680112_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 000000000..288f51729 --- /dev/null +++ b/hasura/migrations/1611165680112_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1611165680112_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1611165680112_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 000000000..3dd70cec3 --- /dev/null +++ b/hasura/migrations/1611165680112_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index b3db13652..a57f88a39 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -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