Inversed ignoring of lines and included default filter. RPS-1 RPS-5

This commit is contained in:
Patrick Fic
2020-10-22 19:37:09 -07:00
parent e9e95935fc
commit 5ef32c5465
8 changed files with 58 additions and 16 deletions

View File

@@ -4,7 +4,10 @@ const log = require("electron-log");
const Nucleus = require("nucleus-nodejs"); const Nucleus = require("nucleus-nodejs");
const { default: ipcTypes } = require("../src/ipc.types"); const { default: ipcTypes } = require("../src/ipc.types");
Nucleus.init("5f91b569b95bac34eefdb63a", { debug: true }); Nucleus.init("5f91b569b95bac34eefdb63a", {
disableInDev: false,
debug: false,
});
Nucleus.setProps({ Nucleus.setProps({
version: app.getVersion().toString(), version: app.getVersion().toString(),

18
package-lock.json generated
View File

@@ -4227,6 +4227,15 @@
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz",
"integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==" "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ=="
}, },
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"block-stream": { "block-stream": {
"version": "0.0.9", "version": "0.0.9",
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
@@ -8218,6 +8227,12 @@
"schema-utils": "^2.5.0" "schema-utils": "^2.5.0"
} }
}, },
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"optional": true
},
"filelist": { "filelist": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz",
@@ -10665,6 +10680,7 @@
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true, "optional": true,
"requires": { "requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1" "nan": "^2.12.1"
} }
}, },
@@ -19376,6 +19392,7 @@
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true, "optional": true,
"requires": { "requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1" "nan": "^2.12.1"
} }
}, },
@@ -19780,6 +19797,7 @@
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true, "optional": true,
"requires": { "requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1" "nan": "^2.12.1"
} }
}, },

View File

@@ -53,8 +53,8 @@
"pack": "electron-builder --dir", "pack": "electron-builder --dir",
"dist": "npm run build && electron-builder", "dist": "npm run build && electron-builder",
"distp": "npm run build && electron-builder --publish always", "distp": "npm run build && electron-builder --publish always",
"distpnb": "npm run build && electron-builder --publish always", "distpnb": "lectron-builder --publish always",
"postinstall": "npm run build && electron-builder install-app-deps" "postinstall": "electron-builder install-app-deps"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"

View File

@@ -9,15 +9,16 @@ export default function IgnoreJobLineAtom({ ignore, lineId, line_desc }) {
const [updateJobLine] = useMutation(UPDATE_JOB_LINE); const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const handleChange = async (checked) => { const handleChange = async (checked) => {
console.log("handleChange -> checked", checked);
setLoading(true); setLoading(true);
ipcRenderer.send(ipcTypes.default.app.toMain.track, { ipcRenderer.send(ipcTypes.default.app.toMain.track, {
event: "TOGGLE_IGNORE_LINE", event: "TOGGLE_IGNORE_LINE",
line_desc: line_desc, line_desc: line_desc,
ignore: checked, ignore: !checked,
}); });
const result = await updateJobLine({ const result = await updateJobLine({
variables: { lineId: lineId, line: { ignore: checked } }, variables: { lineId: lineId, line: { ignore: !checked } },
}); });
if (result.errors) { if (result.errors) {
message.error("Error updating line."); message.error("Error updating line.");
@@ -27,5 +28,5 @@ export default function IgnoreJobLineAtom({ ignore, lineId, line_desc }) {
setLoading(false); setLoading(false);
}; };
return <Switch checked={ignore} onChange={handleChange} loading={loading} />; return <Switch checked={!ignore} onChange={handleChange} loading={loading} />;
} }

View File

@@ -48,9 +48,6 @@ export default function JobPartsGraphAtom({
alignItems: "center", alignItems: "center",
}} }}
> >
<Typography.Title level={4}>
{price === "act_price" ? "Actual Price" : "Database Price"}
</Typography.Title>
<ResponsiveContainer> <ResponsiveContainer>
<PieChart> <PieChart>
<Pie <Pie
@@ -71,6 +68,9 @@ export default function JobPartsGraphAtom({
</Pie> </Pie>
</PieChart> </PieChart>
</ResponsiveContainer> </ResponsiveContainer>
<Typography.Title level={4}>
{price === "act_price" ? "Actual Price" : "Database Price"}
</Typography.Title>
</div> </div>
); );
} }

View File

@@ -6,11 +6,12 @@ import CurrencyFormatterAtom from "../../atoms/currency-formatter/currency-forma
import IgnoreJobLine from "../../atoms/ignore-job-line/ignore-job-line.atom"; import IgnoreJobLine from "../../atoms/ignore-job-line/ignore-job-line.atom";
import partTypeConverterAtom from "../../atoms/part-type-converter/part-type-converter.atom"; import partTypeConverterAtom from "../../atoms/part-type-converter/part-type-converter.atom";
import PriceDiffPcFormatterAtom from "../../atoms/price-diff-pc-formatter/price-diff-pc-formatter.atom"; import PriceDiffPcFormatterAtom from "../../atoms/price-diff-pc-formatter/price-diff-pc-formatter.atom";
import { CalculatorOutlined } from "@ant-design/icons";
const { ipcRenderer } = window; const { ipcRenderer } = window;
export default function JobLinesTableMolecule({ loading, job }) { export default function JobLinesTableMolecule({ loading, job }) {
const [searchText, setSearchText] = useState(""); const [searchText, setSearchText] = useState("");
const [filters, setFilters] = useState({ ignore: ["false"] });
const { joblines } = job; const { joblines } = job;
const columns = [ const columns = [
@@ -19,23 +20,27 @@ export default function JobLinesTableMolecule({ loading, job }) {
dataIndex: "line_no", dataIndex: "line_no",
key: "line_no", key: "line_no",
sorter: (a, b) => a.line_no - b.line_no, sorter: (a, b) => a.line_no - b.line_no,
width: "5%",
}, },
{ {
title: "S#", title: "S#",
dataIndex: "line_ind", dataIndex: "line_ind",
key: "line_ind", key: "line_ind",
width: "5%",
sorter: (a, b) => alphaSort(a.line_ind, b.line_ind), sorter: (a, b) => alphaSort(a.line_ind, b.line_ind),
}, },
{ {
title: "Line Description", title: "Line Description",
dataIndex: "line_desc", dataIndex: "line_desc",
key: "line_desc", key: "line_desc",
width: "25%",
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc), sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
}, },
{ {
title: "Part Type", title: "Part Type",
dataIndex: "part_type", dataIndex: "part_type",
key: "part_type", key: "part_type",
width: "5%",
sorter: (a, b) => alphaSort(a.part_type, b.part_type), sorter: (a, b) => alphaSort(a.part_type, b.part_type),
render: (text, record) => partTypeConverterAtom(text), render: (text, record) => partTypeConverterAtom(text),
}, },
@@ -43,12 +48,14 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Part Number", title: "Part Number",
dataIndex: "oem_partno", dataIndex: "oem_partno",
key: "oem_partno", key: "oem_partno",
width: "15%",
sorter: (a, b) => alphaSort(a.oem_partno, b.oem_partno), sorter: (a, b) => alphaSort(a.oem_partno, b.oem_partno),
}, },
{ {
title: "Database Price", title: "Database Price",
dataIndex: "db_price", dataIndex: "db_price",
key: "db_price", key: "db_price",
width: "10%",
sorter: (a, b) => a.db_price - b.db_price, sorter: (a, b) => a.db_price - b.db_price,
render: (text, record) => ( render: (text, record) => (
<CurrencyFormatterAtom>{record.db_price}</CurrencyFormatterAtom> <CurrencyFormatterAtom>{record.db_price}</CurrencyFormatterAtom>
@@ -58,6 +65,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Actual Price", title: "Actual Price",
dataIndex: "act_price", dataIndex: "act_price",
key: "act_price", key: "act_price",
width: "10%",
sorter: (a, b) => a.act_price - b.act_price, sorter: (a, b) => a.act_price - b.act_price,
render: (text, record) => ( render: (text, record) => (
<CurrencyFormatterAtom>{record.act_price}</CurrencyFormatterAtom> <CurrencyFormatterAtom>{record.act_price}</CurrencyFormatterAtom>
@@ -67,6 +75,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Price Diff.", title: "Price Diff.",
dataIndex: "price_diff", dataIndex: "price_diff",
key: "price_diff", key: "price_diff",
width: "10%",
sorter: (a, b) => a.price_diff - b.price_diff, sorter: (a, b) => a.price_diff - b.price_diff,
render: (text, record) => ( render: (text, record) => (
<CurrencyFormatterAtom>{record.price_diff}</CurrencyFormatterAtom> <CurrencyFormatterAtom>{record.price_diff}</CurrencyFormatterAtom>
@@ -76,6 +85,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Price Diff. %", title: "Price Diff. %",
dataIndex: "price_diff_pc", dataIndex: "price_diff_pc",
key: "price_diff_pc", key: "price_diff_pc",
width: "10%",
sorter: (a, b) => a.price_diff_pc - b.price_diff_pc, sorter: (a, b) => a.price_diff_pc - b.price_diff_pc,
render: (text, record) => ( render: (text, record) => (
<PriceDiffPcFormatterAtom <PriceDiffPcFormatterAtom
@@ -86,13 +96,15 @@ export default function JobLinesTableMolecule({ loading, job }) {
), ),
}, },
{ {
title: "Ignore?", title: <CalculatorOutlined />,
dataIndex: "ignore", dataIndex: "ignore",
key: "ignore", key: "ignore",
filters: [ filters: [
{ text: "True", value: true }, { text: "Eligible for RPS Calculation", value: false },
{ text: "False", value: false }, { text: "Ineligible RPS Calculation", value: true },
], ],
width: "5%",
filteredValue: filters.ignore || null,
onFilter: (value, record) => value === record.ignore, onFilter: (value, record) => value === record.ignore,
render: (text, record) => ( render: (text, record) => (
<IgnoreJobLine <IgnoreJobLine
@@ -111,6 +123,11 @@ export default function JobLinesTableMolecule({ loading, job }) {
) )
: joblines; : joblines;
const handleChange = (pagination, filters, sorter) => {
console.log("Various parameters", pagination, filters, sorter);
setFilters(filters);
};
return ( return (
<div> <div>
<Table <Table
@@ -134,6 +151,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
size="small" size="small"
pagination={false} pagination={false}
dataSource={data} dataSource={data}
onChange={handleChange}
scroll={{ scroll={{
x: true, x: true,
y: "20rem", y: "20rem",

View File

@@ -43,7 +43,7 @@ export function JobsTargetsStatsMolecule({
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "space-around", justifyContent: "space-around",
marginTop: "1rem", marginTop: "2rem",
marginBottom: "1rem", marginBottom: "1rem",
}} }}
> >

View File

@@ -1,5 +1,5 @@
import { useQuery } from "@apollo/client"; import { useQuery } from "@apollo/client";
import { Result } from "antd"; import { Divider, Result } from "antd";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
@@ -78,7 +78,9 @@ export function JobsDetailOrganism({ selectedJobId, setSelectedJobTargetPc }) {
loading={loading} loading={loading}
/> />
</div> </div>
<DeleteJobAtom jobId={data ? data.jobs_by_pk.id : null} /> <DeleteJobAtom
jobId={data ? data.jobs_by_pk && data.jobs_by_pk.id : null}
/>
</div> </div>
); );
} }