From 24fc50826c2062df0b5d93e8adb5599295342f14 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 30 Jan 2020 17:18:36 -0800 Subject: [PATCH] Fixed joblines query sorting. Added in additional fields. Added region to bodyshop. --- bodyshop_translations.babel | 21 ++++++ .../job-detail-lines/job-lines.component.jsx | 38 +++++++--- client/src/graphql/apollo-error-handling.js | 23 +++--- client/src/graphql/jobs-lines.queries.js | 14 +++- client/src/graphql/jobs.queries.js | 1 + client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + client/src/utils/CurrencyFormatter.jsx | 2 + client/src/utils/sorters.js | 18 +++-- .../down.yaml | 3 + .../up.yaml | 4 + .../down.yaml | 39 ++++++++++ .../up.yaml | 40 ++++++++++ .../down.yaml | 3 + .../up.yaml | 3 + .../down.yaml | 74 ++++++++++++++++++ .../up.yaml | 75 +++++++++++++++++++ .../down.yaml | 72 ++++++++++++++++++ .../up.yaml | 73 ++++++++++++++++++ .../down.yaml | 74 ++++++++++++++++++ .../up.yaml | 75 +++++++++++++++++++ 22 files changed, 628 insertions(+), 27 deletions(-) create mode 100644 hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/down.yaml create mode 100644 hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/up.yaml create mode 100644 hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/down.yaml create mode 100644 hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/up.yaml create mode 100644 hasura/migrations/1580428876888_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1580428876888_update_permission_user_public_table_joblines/up.yaml create mode 100644 hasura/migrations/1580428884075_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1580428884075_update_permission_user_public_table_joblines/up.yaml create mode 100644 hasura/migrations/1580428891595_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1580428891595_update_permission_user_public_table_joblines/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index b60aba470..6ce698947 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -552,6 +552,27 @@ + + oem_partno + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + part_type 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 02ab7ff4a..010b92df0 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -17,30 +17,50 @@ export default function JobLinesComponent({ jobLines, form, handleSubmit }) { const columns = [ { title: t("joblines.fields.unq_seq"), - dataIndex: "joblines.unq_seq", - key: "joblines.unq_seq", + dataIndex: "unq_seq", + key: "unq_seq", // onFilter: (value, record) => record.ro_number.includes(value), // filteredValue: state.filteredInfo.text || null, - sorter: (a, b) => alphaSort(a, b), + sorter: (a, b) => a.unq_seq - b.unq_seq, sortOrder: state.sortedInfo.columnKey === "unq_seq" && state.sortedInfo.order, //ellipsis: true, - editable: true + editable: true, + width: 75 }, { title: t("joblines.fields.line_desc"), dataIndex: "line_desc", - key: "joblines.line_desc", + key: "line_desc", sorter: (a, b) => alphaSort(a.line_desc, b.line_desc), sortOrder: state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order, ellipsis: true, editable: true }, + { + title: t("joblines.fields.oem_partno"), + dataIndex: "oem_partno", + key: "oem_partno", + sorter: (a, b) => + alphaSort( + a.oem_partno ? a.oem_partno : a.op_code_desc, + b.oem_partno ? b.oem_partno : b.op_code_desc + ), + sortOrder: + state.sortedInfo.columnKey === "oem_partno" && state.sortedInfo.order, + ellipsis: true, + editable: true, + render: (text, record) => ( + + {record.oem_partno ? record.oem_partno : record.op_code_desc} + + ) + }, { title: t("joblines.fields.part_type"), dataIndex: "part_type", - key: "joblines.part_type", + key: "part_type", sorter: (a, b) => alphaSort(a.part_type, b.part_type), sortOrder: state.sortedInfo.columnKey === "part_type" && state.sortedInfo.order, @@ -50,7 +70,7 @@ export default function JobLinesComponent({ jobLines, form, handleSubmit }) { { title: t("joblines.fields.db_price"), dataIndex: "db_price", - key: "joblines.db_price", + key: "db_price", sorter: (a, b) => a.db_price - b.db_price, sortOrder: state.sortedInfo.columnKey === "db_price" && state.sortedInfo.order, @@ -62,7 +82,7 @@ export default function JobLinesComponent({ jobLines, form, handleSubmit }) { { title: t("joblines.fields.act_price"), dataIndex: "act_price", - key: "joblines.act_price", + key: "act_price", sorter: (a, b) => a.act_price - b.act_price, sortOrder: state.sortedInfo.columnKey === "act_price" && state.sortedInfo.order, @@ -112,7 +132,7 @@ export default function JobLinesComponent({ jobLines, form, handleSubmit }) { ({ ...item }))} rowKey="id" dataSource={jobLines} diff --git a/client/src/graphql/apollo-error-handling.js b/client/src/graphql/apollo-error-handling.js index c38c13d78..f6e72f694 100644 --- a/client/src/graphql/apollo-error-handling.js +++ b/client/src/graphql/apollo-error-handling.js @@ -26,6 +26,7 @@ const errorLink = onError( //User access token has expired //props.history.push("/network-error"); console.log("We need a new token!"); + console.log("Old Token", window.localStorage.getItem("token")); // Let's refresh token through async request auth.currentUser.getIdToken(true).then(token => { @@ -39,16 +40,18 @@ const errorLink = onError( } })); - return new Observable(observer => { - const subscriber = { - next: observer.next.bind(observer), - error: observer.error.bind(observer), - complete: observer.complete.bind(observer) - }; - console.log("About to resend the request."); - // Retry last failed request - forward(operation).subscribe(subscriber); - }); + return forward(operation); + + // return new Observable(observer => { + // const subscriber = { + // next: observer.next.bind(observer), + // error: observer.error.bind(observer), + // complete: observer.complete.bind(observer) + // }; + // console.log("About to resend the request."); + // // Retry last failed request + // forward(operation).subscribe(subscriber); + // }); } }); diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index 4203fdf06..334097e37 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -2,10 +2,22 @@ import { gql } from "apollo-boost"; export const GET_JOB_LINES_BY_PK = gql` query GET_JOB_LINES_BY_PK($id: uuid!) { - joblines(where: { jobid: { _eq: $id } }) { + joblines(where: { jobid: { _eq: $id } }, order_by: { unq_seq: asc }) { id + unq_seq line_ind line_desc + part_type + oem_partno + db_price + act_price + part_qty + mod_lbr_ty + db_hrs + mod_lb_hrs + lbr_op + lbr_amt + op_code_desc } } `; diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 307f96b59..472779f40 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -211,6 +211,7 @@ export const GET_JOB_BY_PK = gql` mod_lb_hrs lbr_op lbr_amt + op_code_desc } } } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 236e1b25f..fea8428bb 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -43,6 +43,7 @@ "act_price": "Actual Price", "db_price": "Database Price", "line_desc": "Line Description", + "oem_partno": "OEM Part #", "part_type": "Part Type", "unq_seq": "Seq #" } diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 8b430b09c..721511590 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -43,6 +43,7 @@ "act_price": "Precio actual", "db_price": "Precio de base de datos", "line_desc": "Descripción de línea", + "oem_partno": "OEM parte #", "part_type": "Tipo de parte", "unq_seq": "Seq #" } diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 53405272e..45c50354a 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -43,6 +43,7 @@ "act_price": "Prix actuel", "db_price": "Prix de la base de données", "line_desc": "Description de la ligne", + "oem_partno": "Pièce OEM #", "part_type": "Type de pièce", "unq_seq": "Seq #" } diff --git a/client/src/utils/CurrencyFormatter.jsx b/client/src/utils/CurrencyFormatter.jsx index 083c2cf70..babb6cc85 100644 --- a/client/src/utils/CurrencyFormatter.jsx +++ b/client/src/utils/CurrencyFormatter.jsx @@ -5,6 +5,8 @@ export default function CurrencyFormatter(props) { return ( b) { - return false; - } - if (b > a) { - return true; - } - return true; + let A; + let B; + A = a ? a.toLowerCase() : ""; + + B = b ? b.toLowerCase() : ""; + + if (A < B) + //sort string ascending + return -1; + if (A > B) return 1; + return 0; //default return value (no sorting) } diff --git a/hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/down.yaml b/hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/down.yaml new file mode 100644 index 000000000..6b1476237 --- /dev/null +++ b/hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/down.yaml @@ -0,0 +1,3 @@ +- args: + sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "region_config"; + type: run_sql diff --git a/hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/up.yaml b/hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/up.yaml new file mode 100644 index 000000000..b9a0e7e8e --- /dev/null +++ b/hasura/migrations/1580427566710_alter_table_public_bodyshops_add_column_region_config/up.yaml @@ -0,0 +1,4 @@ +- args: + sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "region_config" text NOT NULL + DEFAULT 'CA_BC'; + type: run_sql diff --git a/hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..80ca70d5d --- /dev/null +++ b/hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/down.yaml @@ -0,0 +1,39 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - address1 + - address2 + - city + - country + - created_at + - email + - federal_tax_id + - id + - insurance_vendor_id + - logo_img_path + - md_ro_statuses + - shopname + - state + - state_tax_id + - updated_at + - zip_post + computed_fields: [] + filter: + associations: + bodyshop: + associations: + user: + authid: + _eq: X-Hasura-User-Id + role: user + table: + name: bodyshops + schema: public + type: create_select_permission diff --git a/hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..0575c9859 --- /dev/null +++ b/hasura/migrations/1580427579544_update_permission_user_public_table_bodyshops/up.yaml @@ -0,0 +1,40 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - address1 + - address2 + - city + - country + - created_at + - email + - federal_tax_id + - id + - insurance_vendor_id + - logo_img_path + - md_ro_statuses + - region_config + - shopname + - state + - state_tax_id + - updated_at + - zip_post + computed_fields: [] + filter: + associations: + bodyshop: + associations: + user: + authid: + _eq: X-Hasura-User-Id + role: user + table: + name: bodyshops + schema: public + type: create_select_permission diff --git a/hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/down.yaml b/hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/down.yaml new file mode 100644 index 000000000..8b33d277c --- /dev/null +++ b/hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/down.yaml @@ -0,0 +1,3 @@ +- args: + sql: ALTER TABLE "public"."joblines" DROP COLUMN "op_code_desc"; + type: run_sql diff --git a/hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/up.yaml b/hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/up.yaml new file mode 100644 index 000000000..f70b7a310 --- /dev/null +++ b/hasura/migrations/1580428867144_alter_table_public_joblines_add_column_op_code_desc/up.yaml @@ -0,0 +1,3 @@ +- args: + sql: ALTER TABLE "public"."joblines" ADD COLUMN "op_code_desc" text NULL; + type: run_sql diff --git a/hasura/migrations/1580428876888_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1580428876888_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 000000000..dc213864d --- /dev/null +++ b/hasura/migrations/1580428876888_update_permission_user_public_table_joblines/down.yaml @@ -0,0 +1,74 @@ +- 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: + - id + - created_at + - updated_at + - jobid + - unq_seq + - line_ind + - line_desc + - part_type + - oem_partno + - est_seq + - db_ref + - line_ref + - tax_part + - db_price + - act_price + - part_qty + - alt_partno + - mod_lbr_ty + - db_hrs + - mod_lb_hrs + - lbr_op + - lbr_amt + - glass_flag + - price_inc + - alt_part_i + - price_j + - cert_part + - alt_co_id + - alt_overrd + - alt_partm + - prt_dsmk_p + - prt_dsmk_m + - lbr_inc + - lbr_hrs_j + - lbr_typ_j + - lbr_op_j + - paint_stg + - paint_tone + - lbr_tax + - misc_amt + - misc_sublt + - misc_tax + - bett_type + - bett_pctg + - bett_amt + - bett_tax + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: joblines + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1580428876888_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1580428876888_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 000000000..3d0722715 --- /dev/null +++ b/hasura/migrations/1580428876888_update_permission_user_public_table_joblines/up.yaml @@ -0,0 +1,75 @@ +- 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: + - id + - created_at + - updated_at + - jobid + - unq_seq + - line_ind + - line_desc + - part_type + - oem_partno + - est_seq + - db_ref + - line_ref + - tax_part + - db_price + - act_price + - part_qty + - alt_partno + - mod_lbr_ty + - db_hrs + - mod_lb_hrs + - lbr_op + - lbr_amt + - glass_flag + - price_inc + - alt_part_i + - price_j + - cert_part + - alt_co_id + - alt_overrd + - alt_partm + - prt_dsmk_p + - prt_dsmk_m + - lbr_inc + - lbr_hrs_j + - lbr_typ_j + - lbr_op_j + - paint_stg + - paint_tone + - lbr_tax + - misc_amt + - misc_sublt + - misc_tax + - bett_type + - bett_pctg + - bett_amt + - bett_tax + - op_code_desc + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: joblines + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1580428884075_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1580428884075_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 000000000..b143512d8 --- /dev/null +++ b/hasura/migrations/1580428884075_update_permission_user_public_table_joblines/down.yaml @@ -0,0 +1,72 @@ +- args: + role: user + table: + name: joblines + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - id + - created_at + - updated_at + - jobid + - unq_seq + - line_ind + - line_desc + - part_type + - oem_partno + - est_seq + - db_ref + - line_ref + - tax_part + - db_price + - act_price + - part_qty + - alt_partno + - mod_lbr_ty + - db_hrs + - mod_lb_hrs + - lbr_op + - lbr_amt + - glass_flag + - price_inc + - alt_part_i + - price_j + - cert_part + - alt_co_id + - alt_overrd + - alt_partm + - prt_dsmk_p + - prt_dsmk_m + - lbr_inc + - lbr_hrs_j + - lbr_typ_j + - lbr_op_j + - paint_stg + - paint_tone + - lbr_tax + - misc_amt + - misc_sublt + - misc_tax + - bett_type + - bett_pctg + - bett_amt + - bett_tax + 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/1580428884075_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1580428884075_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 000000000..32c4e42a2 --- /dev/null +++ b/hasura/migrations/1580428884075_update_permission_user_public_table_joblines/up.yaml @@ -0,0 +1,73 @@ +- args: + role: user + table: + name: joblines + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - alt_overrd + - alt_part_i + - bett_tax + - cert_part + - glass_flag + - lbr_hrs_j + - lbr_inc + - lbr_op_j + - lbr_tax + - lbr_typ_j + - misc_sublt + - misc_tax + - price_inc + - price_j + - tax_part + - est_seq + - paint_stg + - paint_tone + - part_qty + - unq_seq + - act_price + - bett_amt + - bett_pctg + - db_hrs + - db_price + - lbr_amt + - line_ref + - misc_amt + - mod_lb_hrs + - prt_dsmk_m + - prt_dsmk_p + - alt_co_id + - alt_partm + - alt_partno + - bett_type + - db_ref + - lbr_op + - line_desc + - line_ind + - mod_lbr_ty + - oem_partno + - op_code_desc + - part_type + - created_at + - updated_at + - id + - jobid + 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/1580428891595_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1580428891595_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 000000000..6d1063cc8 --- /dev/null +++ b/hasura/migrations/1580428891595_update_permission_user_public_table_joblines/down.yaml @@ -0,0 +1,74 @@ +- args: + role: user + table: + name: joblines + schema: public + type: drop_update_permission +- args: + permission: + columns: + - alt_overrd + - alt_part_i + - bett_tax + - cert_part + - glass_flag + - lbr_hrs_j + - lbr_inc + - lbr_op_j + - lbr_tax + - lbr_typ_j + - misc_sublt + - misc_tax + - price_inc + - price_j + - tax_part + - est_seq + - paint_stg + - paint_tone + - part_qty + - unq_seq + - act_price + - bett_amt + - bett_pctg + - db_hrs + - db_price + - lbr_amt + - line_ref + - misc_amt + - mod_lb_hrs + - prt_dsmk_m + - prt_dsmk_p + - alt_co_id + - alt_partm + - alt_partno + - bett_type + - db_ref + - lbr_op + - line_desc + - line_ind + - mod_lbr_ty + - oem_partno + - part_type + - created_at + - updated_at + - id + - jobid + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: joblines + schema: public + type: create_update_permission diff --git a/hasura/migrations/1580428891595_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1580428891595_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 000000000..befcc2bb7 --- /dev/null +++ b/hasura/migrations/1580428891595_update_permission_user_public_table_joblines/up.yaml @@ -0,0 +1,75 @@ +- args: + role: user + table: + name: joblines + schema: public + type: drop_update_permission +- args: + permission: + columns: + - alt_overrd + - alt_part_i + - bett_tax + - cert_part + - glass_flag + - lbr_hrs_j + - lbr_inc + - lbr_op_j + - lbr_tax + - lbr_typ_j + - misc_sublt + - misc_tax + - price_inc + - price_j + - tax_part + - est_seq + - paint_stg + - paint_tone + - part_qty + - unq_seq + - act_price + - bett_amt + - bett_pctg + - db_hrs + - db_price + - lbr_amt + - line_ref + - misc_amt + - mod_lb_hrs + - prt_dsmk_m + - prt_dsmk_p + - alt_co_id + - alt_partm + - alt_partno + - bett_type + - db_ref + - lbr_op + - line_desc + - line_ind + - mod_lbr_ty + - oem_partno + - op_code_desc + - part_type + - created_at + - updated_at + - id + - jobid + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: joblines + schema: public + type: create_update_permission