From f20ef2d11dc07a2e413ed4f44e34303bf2f4e06c Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 15 Jun 2021 16:41:24 -0700 Subject: [PATCH] IO-1209 Jobline presets. --- bodyshop_translations.babel | 63 +++++++ .../components/header/header.component.jsx | 6 +- .../job-lines-preset-button.component.jsx | 52 ++++++ .../job-lines-upsert-modal.component.jsx | 7 +- .../jobs-create-vehicle-info.container.jsx | 12 +- .../shop-info/shop-info.general.component.jsx | 174 ++++++++++++++++++ client/src/graphql/bodyshop.queries.js | 2 + client/src/graphql/jobs-lines.queries.js | 1 + client/src/graphql/vehicles.queries.js | 30 +++ .../jobs-create/jobs-create.container.jsx | 2 +- client/src/translations/en_us/common.json | 5 +- client/src/translations/es/common.json | 5 +- client/src/translations/fr/common.json | 5 +- .../down.yaml | 5 + .../up.yaml | 6 + .../down.yaml | 84 +++++++++ .../up.yaml | 85 +++++++++ .../down.yaml | 78 ++++++++ .../up.yaml | 79 ++++++++ hasura/migrations/metadata.yaml | 2 + server/job/job-totals.js | 11 +- 21 files changed, 696 insertions(+), 18 deletions(-) create mode 100644 client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx create mode 100644 hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/down.yaml create mode 100644 hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/up.yaml create mode 100644 hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 5ec01e999..042ad7c33 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -3753,6 +3753,27 @@ + + md_jobline_presets + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + md_payment_types false @@ -15824,6 +15845,27 @@ + + presets + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -24434,6 +24476,27 @@ + + newjob + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + owners false diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx index 2c3887891..5069e3df6 100644 --- a/client/src/components/header/header.component.jsx +++ b/client/src/components/header/header.component.jsx @@ -1,4 +1,5 @@ import Icon, { + FileAddOutlined, BankFilled, BarChartOutlined, CarFilled, @@ -111,12 +112,14 @@ function Header({ {t("menus.header.availablejobs")} + }> + {t("menus.header.newjob")} + }> {t("menus.header.alljobs")} - }> {t("menus.header.productionlist")} @@ -128,7 +131,6 @@ function Header({ - }> {t("menus.header.scoreboard")} diff --git a/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx b/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx new file mode 100644 index 000000000..8e0aa2cb9 --- /dev/null +++ b/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx @@ -0,0 +1,52 @@ +import { DownOutlined } from "@ant-design/icons"; +import { Dropdown, Menu } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); + +export function JoblinePresetButton({ bodyshop, form }) { + const { t } = useTranslation(); + + const handleSelect = (item) => { + form.setFieldsValue(item); + }; + + const menu = ( + + {bodyshop.md_jobline_presets.map((i, idx) => ( + handleSelect(i)} onItemHover key={idx}> + {i.label} + + ))} + + ); + + return ( + + + e.preventDefault()} + > + {t("joblines.labels.presets")} + + + + ); +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(JoblinePresetButton); diff --git a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx index 308caf54e..520154f08 100644 --- a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx +++ b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx @@ -3,7 +3,7 @@ import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import InputCurrency from "../form-items-formatted/currency-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; - +import JoblinesPreset from "../job-lines-preset-button/job-lines-preset-button.component"; export default function JobLinesUpsertModalComponent({ visible, jobLine, @@ -32,6 +32,7 @@ export default function JobLinesUpsertModalComponent({ onOk={() => form.submit()} okButtonProps={{ loading: loading }} onCancel={handleCancel} + e > + + + + diff --git a/client/src/components/jobs-create-vehicle-info/jobs-create-vehicle-info.container.jsx b/client/src/components/jobs-create-vehicle-info/jobs-create-vehicle-info.container.jsx index b95d81274..379fc5638 100644 --- a/client/src/components/jobs-create-vehicle-info/jobs-create-vehicle-info.container.jsx +++ b/client/src/components/jobs-create-vehicle-info/jobs-create-vehicle-info.container.jsx @@ -1,14 +1,14 @@ +import { useQuery } from "@apollo/client"; import React, { useContext } from "react"; -import JobsCreateVehicleInfoComponent from "./jobs-create-vehicle-info.component"; +import { SEARCH_VEHICLES } from "../../graphql/vehicles.queries"; import JobCreateContext from "../../pages/jobs-create/jobs-create.context"; import AlertComponent from "../alert/alert.component"; -import { SEARCH_VEHICLE_BY_VIN } from "../../graphql/vehicles.queries"; -import { useQuery } from "@apollo/client"; +import JobsCreateVehicleInfoComponent from "./jobs-create-vehicle-info.component"; export default function JobsCreateVehicleInfoContainer({ form }) { const [state] = useContext(JobCreateContext); - const { loading, error, data } = useQuery(SEARCH_VEHICLE_BY_VIN, { - variables: { vin: `%${state.vehicle.search}%` }, + const { loading, error, data } = useQuery(SEARCH_VEHICLES, { + variables: { search: `%${state.vehicle.search}%` }, skip: !state.vehicle.search, }); @@ -17,7 +17,7 @@ export default function JobsCreateVehicleInfoContainer({ form }) { return ( ); } diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 9123eddfc..d8bd13647 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -825,6 +825,180 @@ export default function ShopInfoGeneral({ form }) { }} + + + {(fields, { add, remove, move }) => { + return ( + + {fields.map((field, index) => ( + + + + + + + + + + + + {t("joblines.fields.lbr_types.LAA")} + + + {t("joblines.fields.lbr_types.LAB")} + + + {t("joblines.fields.lbr_types.LAD")} + + + {t("joblines.fields.lbr_types.LAE")} + + + {t("joblines.fields.lbr_types.LAF")} + + + {t("joblines.fields.lbr_types.LAG")} + + + {t("joblines.fields.lbr_types.LAM")} + + + {t("joblines.fields.lbr_types.LAR")} + + + {t("joblines.fields.lbr_types.LAS")} + + + {t("joblines.fields.lbr_types.LAU")} + + + {t("joblines.fields.lbr_types.LA1")} + + + {t("joblines.fields.lbr_types.LA2")} + + + {t("joblines.fields.lbr_types.LA3")} + + + {t("joblines.fields.lbr_types.LA4")} + + + + + + + + + + {t("joblines.fields.part_types.PAA")} + + + {t("joblines.fields.part_types.PAC")} + + + {t("joblines.fields.part_types.PAE")} + + + {t("joblines.fields.part_types.PAL")} + + + {t("joblines.fields.part_types.PAM")} + + + {t("joblines.fields.part_types.PAN")} + + + {t("joblines.fields.part_types.PAO")} + + + {t("joblines.fields.part_types.PAR")} + + + {t("joblines.fields.part_types.PAS")} + + {" "} + + + + + + + + + + + + + + + + { + remove(field.name); + }} + /> + + + + + ))} + + { + add(); + }} + style={{ width: "100%" }} + > + {t("general.actions.add")} + + + + ); + }} + + ); } diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index e910fb3a9..e4c429df8 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -88,6 +88,7 @@ export const QUERY_BODYSHOP = gql` enforce_referral website jc_hourly_rates + md_jobline_presets employees { id active @@ -173,6 +174,7 @@ export const UPDATE_SHOP = gql` enforce_referral website jc_hourly_rates + md_jobline_presets employees { id first_name diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index 1b1304653..90086e27c 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -159,6 +159,7 @@ export const UPDATE_JOB_LINE = gql` db_price act_price line_desc + line_no oem_partno notes location diff --git a/client/src/graphql/vehicles.queries.js b/client/src/graphql/vehicles.queries.js index 55f296e1f..507b22399 100644 --- a/client/src/graphql/vehicles.queries.js +++ b/client/src/graphql/vehicles.queries.js @@ -133,6 +133,36 @@ export const SEARCH_VEHICLE_BY_VIN = gql` } `; +export const SEARCH_VEHICLES = gql` + query SEARCH_VEHICLES($search: String!) { + search_vehicles(args: { search: $search }) { + id + plate_no + plate_st + v_vin + v_model_yr + v_model_desc + v_make_desc + v_color + v_bstyle + updated_at + v_type + v_trimcode + v_tone + v_stage + v_prod_dt + v_paint_codes + v_options + v_mldgcode + v_makecode + v_engine + v_cond + trim_color + db_v_code + } + } +`; + export const SEARCH_VEHICLES_BY_ID_FOR_AUTOCOMPLETE = gql` query SEARCH_VEHICLES_BY_ID_FOR_AUTOCOMPLETE($id: uuid!) { vehicles_by_pk(id: $id) { diff --git a/client/src/pages/jobs-create/jobs-create.container.jsx b/client/src/pages/jobs-create/jobs-create.container.jsx index 63aabf3c0..761b1af85 100644 --- a/client/src/pages/jobs-create/jobs-create.container.jsx +++ b/client/src/pages/jobs-create/jobs-create.container.jsx @@ -57,7 +57,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { useEffect(() => { document.title = t("titles.jobs-create"); - setSelectedHeader("availablejobs"); + setSelectedHeader("newjob"); setBreadcrumbs([ { link: "/manage/available", label: t("titles.bc.availablejobs") }, { diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index ca20053e7..662530f70 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -243,6 +243,7 @@ "street2": "Street 2", "zip": "Zip/Postal Code" }, + "md_jobline_presets": "Jobline Presets", "md_payment_types": "Payment Types", "md_referral_sources": "Referral Sources", "messaginglabel": "Messaging Preset Label", @@ -993,7 +994,8 @@ "billref": "Latest Bill", "edit": "Edit Line", "new": "New Line", - "nostatus": "No Status" + "nostatus": "No Status", + "presets": "Jobline Presets" }, "successes": { "created": "Job line created successfully.", @@ -1441,6 +1443,7 @@ "help": "Help", "home": "Home", "jobs": "Jobs", + "newjob": "Create New Job", "owners": "Owners", "parts-queue": "Parts Queue", "phonebook": "Phonebook", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index b6b76da07..0c6b45e48 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -243,6 +243,7 @@ "street2": "", "zip": "" }, + "md_jobline_presets": "", "md_payment_types": "", "md_referral_sources": "", "messaginglabel": "", @@ -993,7 +994,8 @@ "billref": "", "edit": "Línea de edición", "new": "Nueva línea", - "nostatus": "" + "nostatus": "", + "presets": "" }, "successes": { "created": "", @@ -1441,6 +1443,7 @@ "help": "", "home": "Casa", "jobs": "Trabajos", + "newjob": "", "owners": "propietarios", "parts-queue": "", "phonebook": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index d43ebc656..6bce4fe7e 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -243,6 +243,7 @@ "street2": "", "zip": "" }, + "md_jobline_presets": "", "md_payment_types": "", "md_referral_sources": "", "messaginglabel": "", @@ -993,7 +994,8 @@ "billref": "", "edit": "Ligne d'édition", "new": "Nouvelle ligne", - "nostatus": "" + "nostatus": "", + "presets": "" }, "successes": { "created": "", @@ -1441,6 +1443,7 @@ "help": "", "home": "Accueil", "jobs": "Emplois", + "newjob": "", "owners": "Propriétaires", "parts-queue": "", "phonebook": "", diff --git a/hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/down.yaml b/hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/down.yaml new file mode 100644 index 000000000..956e6d1a0 --- /dev/null +++ b/hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "md_jobline_presets"; + type: run_sql diff --git a/hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/up.yaml b/hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/up.yaml new file mode 100644 index 000000000..5e1faf8dd --- /dev/null +++ b/hasura/migrations/1623796879914_alter_table_public_bodyshops_add_column_md_jobline_presets/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "md_jobline_presets" jsonb NULL + DEFAULT jsonb_build_array(); + type: run_sql diff --git a/hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..a1885496e --- /dev/null +++ b/hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/down.yaml @@ -0,0 +1,84 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - default_adjustment_rate + - deliverchecklist + - email + - enforce_class + - enforce_referral + - federal_tax_id + - id + - imexshopid + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - jc_hourly_rates + - jobsizelimit + - logo_img_path + - md_categories + - md_ccc_rates + - md_classes + - md_hour_split + - md_ins_cos + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_payment_types + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - messagingservicesid + - phone + - prodtargethrs + - production_config + - region_config + - schedule_end_time + - schedule_start_time + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - stripe_acct_id + - sub_status + - target_touchtime + - template_header + - textid + - updated_at + - use_fippa + - website + - workingdays + - zip_post + computed_fields: [] + filter: + associations: + user: + authid: + _eq: X-Hasura-User-Id + role: user + table: + name: bodyshops + schema: public + type: create_select_permission diff --git a/hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..fae9999b1 --- /dev/null +++ b/hasura/migrations/1623796895613_update_permission_user_public_table_bodyshops/up.yaml @@ -0,0 +1,85 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - default_adjustment_rate + - deliverchecklist + - email + - enforce_class + - enforce_referral + - federal_tax_id + - id + - imexshopid + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - jc_hourly_rates + - jobsizelimit + - logo_img_path + - md_categories + - md_ccc_rates + - md_classes + - md_hour_split + - md_ins_cos + - md_jobline_presets + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_payment_types + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - messagingservicesid + - phone + - prodtargethrs + - production_config + - region_config + - schedule_end_time + - schedule_start_time + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - stripe_acct_id + - sub_status + - target_touchtime + - template_header + - textid + - updated_at + - use_fippa + - website + - workingdays + - zip_post + computed_fields: [] + filter: + associations: + user: + authid: + _eq: X-Hasura-User-Id + role: user + table: + name: bodyshops + schema: public + type: create_select_permission diff --git a/hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..e8583e4ca --- /dev/null +++ b/hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/down.yaml @@ -0,0 +1,78 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_update_permission +- args: + permission: + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - default_adjustment_rate + - deliverchecklist + - email + - enforce_class + - enforce_referral + - federal_tax_id + - id + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - jc_hourly_rates + - logo_img_path + - md_categories + - md_ccc_rates + - md_classes + - md_hour_split + - md_ins_cos + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_payment_types + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - phone + - prodtargethrs + - production_config + - schedule_end_time + - schedule_start_time + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - target_touchtime + - updated_at + - use_fippa + - website + - workingdays + - zip_post + filter: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: bodyshops + schema: public + type: create_update_permission diff --git a/hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..b09c84f9e --- /dev/null +++ b/hasura/migrations/1623796904892_update_permission_user_public_table_bodyshops/up.yaml @@ -0,0 +1,79 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_update_permission +- args: + permission: + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - default_adjustment_rate + - deliverchecklist + - email + - enforce_class + - enforce_referral + - federal_tax_id + - id + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - jc_hourly_rates + - logo_img_path + - md_categories + - md_ccc_rates + - md_classes + - md_hour_split + - md_ins_cos + - md_jobline_presets + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_payment_types + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - phone + - prodtargethrs + - production_config + - schedule_end_time + - schedule_start_time + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - target_touchtime + - updated_at + - use_fippa + - website + - workingdays + - zip_post + filter: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: bodyshops + schema: public + type: create_update_permission diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index 2dcbc2190..f9bb3e114 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -779,6 +779,7 @@ tables: - md_classes - md_hour_split - md_ins_cos + - md_jobline_presets - md_labor_rates - md_messaging_presets - md_notes_presets @@ -849,6 +850,7 @@ tables: - md_classes - md_hour_split - md_ins_cos + - md_jobline_presets - md_labor_rates - md_messaging_presets - md_notes_presets diff --git a/server/job/job-totals.js b/server/job/job-totals.js index 308c6a806..51f285279 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -353,11 +353,12 @@ function CalculateTaxesTotals(job, otherTotals) { //Audatex sends additional glass part types. IO-774 const BackupGlassTax = - job.parts_tax_rates.PAGD || - job.parts_tax_rates.PAGF || - job.parts_tax_rates.PAGP || - job.parts_tax_rates.PAGQ || - job.parts_tax_rates.PAGR; + job.parts_tax_rates && + (job.parts_tax_rates.PAGD || + job.parts_tax_rates.PAGF || + job.parts_tax_rates.PAGP || + job.parts_tax_rates.PAGQ || + job.parts_tax_rates.PAGR); job.joblines .filter((jl) => !jl.removed)