Fixed joblines query sorting. Added in additional fields. Added region to bodyshop.

This commit is contained in:
Patrick Fic
2020-01-30 17:18:36 -08:00
parent f7e050da58
commit 24fc50826c
22 changed files with 628 additions and 27 deletions

View File

@@ -552,6 +552,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>oem_partno</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>part_type</name>
<definition_loaded>false</definition_loaded>

View File

@@ -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) => (
<span>
{record.oem_partno ? record.oem_partno : record.op_code_desc}
</span>
)
},
{
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 }) {
<Table
size="small"
pagination={{ position: "bottom" }}
pagination={{ position: "bottom", defaultPageSize: 50 }}
columns={columns.map(item => ({ ...item }))}
rowKey="id"
dataSource={jobLines}

View File

@@ -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);
// });
}
});

View File

@@ -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
}
}
`;

View File

@@ -211,6 +211,7 @@ export const GET_JOB_BY_PK = gql`
mod_lb_hrs
lbr_op
lbr_amt
op_code_desc
}
}
}

View File

@@ -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 #"
}

View File

@@ -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 #"
}

View File

@@ -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 #"
}

View File

@@ -5,6 +5,8 @@ export default function CurrencyFormatter(props) {
return (
<NumberFormat
thousandSeparator={true}
decimalScale={2}
fixedDecimalScale={true}
prefix={"$"}
value={props.children}
displayType={"text"}

View File

@@ -1,9 +1,13 @@
export function alphaSort(a, b) {
if (a > 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)
}

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "region_config";
type: run_sql

View File

@@ -0,0 +1,4 @@
- args:
sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "region_config" text NOT NULL
DEFAULT 'CA_BC';
type: run_sql

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."joblines" DROP COLUMN "op_code_desc";
type: run_sql

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."joblines" ADD COLUMN "op_code_desc" text NULL;
type: run_sql

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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