Added add to and remove from scoreboard functionality. BOD-91
This commit is contained in:
@@ -7930,6 +7930,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>addtoscoreboard</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>allocate</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -16212,6 +16233,27 @@
|
||||
<folder_node>
|
||||
<name>errors</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>adding</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>removing</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -16392,6 +16434,53 @@
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>successes</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>added</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>removed</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>
|
||||
</children>
|
||||
</folder_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
DatePicker,
|
||||
Form,
|
||||
InputNumber,
|
||||
notification,
|
||||
Popover,
|
||||
} from "antd";
|
||||
import moment from "moment";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { INSERT_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries";
|
||||
|
||||
export default function ScoreboardAddButton({ job, ...otherBtnProps }) {
|
||||
const { t } = useTranslation();
|
||||
const [insertScoreboardEntry] = useMutation(INSERT_SCOREBOARD_ENTRY);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
const [visibility, setVisibility] = useState(false);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setLoading(true);
|
||||
const result = await insertScoreboardEntry({
|
||||
variables: { sbInput: [{ jobid: job.id, ...values }] },
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("scoreboard.errors.adding", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("scoreboard.successes.added"),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
setVisibility(false);
|
||||
};
|
||||
|
||||
const overlay = (
|
||||
<Card>
|
||||
<div>
|
||||
<Form
|
||||
form={form}
|
||||
layout='vertical'
|
||||
onFinish={handleFinish}
|
||||
initialValues={{}}>
|
||||
<Form.Item
|
||||
label={t("scoreboard.fields.date")}
|
||||
name='date'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}>
|
||||
<DatePicker />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("scoreboard.fields.bodyhrs")}
|
||||
name='bodyhrs'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}>
|
||||
<InputNumber precision={1} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("scoreboard.fields.painthrs")}
|
||||
name='painthrs'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}>
|
||||
<InputNumber precision={1} />
|
||||
</Form.Item>
|
||||
|
||||
<Button type='primary' htmlType='submit'>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
</Form>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
|
||||
const handleClick = (e) => {
|
||||
setLoading(true);
|
||||
const v = job.joblines.reduce(
|
||||
(acc, val) => {
|
||||
if (val.mod_lbr_ty === "LAB")
|
||||
acc = { ...acc, bodyhrs: acc.bodyhrs + val.mod_lb_hrs };
|
||||
if (val.mod_lbr_ty === "LAR")
|
||||
acc = { ...acc, painthrs: acc.painthrs + val.mod_lb_hrs };
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
bodyhrs: 0,
|
||||
painthrs: 0,
|
||||
}
|
||||
);
|
||||
form.setFieldsValue({
|
||||
date: new moment(),
|
||||
bodyhrs: Math.round(v.bodyhrs * 10) / 10,
|
||||
painthrs: Math.round(v.painthrs * 10) / 10,
|
||||
});
|
||||
setVisibility(true);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover content={overlay} visible={visibility}>
|
||||
<Button loading={loading} onClick={handleClick} {...otherBtnProps}>
|
||||
{t("jobs.actions.addtoscoreboard")}
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -57,9 +57,9 @@ export function JobsCloseSaveButton({
|
||||
return (
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
type='primary'
|
||||
disabled={suspenseAmount > 0 || disabled}
|
||||
loading={loading}
|
||||
>
|
||||
loading={loading}>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ export default function ScoreboardJobsList({ scoreBoardlist }) {
|
||||
];
|
||||
|
||||
const overlay = (
|
||||
<div style={{ width: "30vw" }}>
|
||||
<div style={{ width: "50vw" }}>
|
||||
<Table
|
||||
size='small'
|
||||
pagination={false}
|
||||
|
||||
@@ -22,6 +22,10 @@ export default function ScoreboardRemoveButton({ scoreboardId }) {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("scoreboard.successes.removed"),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -23,3 +23,15 @@ export const DELETE_SCOREBOARD_ENTRY = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const INSERT_SCOREBOARD_ENTRY = gql`
|
||||
mutation INSERT_SCOREBOARD_ENTRY($sbInput: [scoreboard_insert_input!]!) {
|
||||
insert_scoreboard(objects: $sbInput) {
|
||||
returning {
|
||||
id
|
||||
date
|
||||
bodyhrs
|
||||
painthrs
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -9,6 +9,7 @@ import JobsCloseTotals from "../../components/jobs-close-totals/jobs-close-total
|
||||
import JobsCloseAutoAllocate from "../../components/jobs-close-auto-allocate/jobs-close-auto-allocate.component";
|
||||
import JobsCloseSaveButton from "../../components/jobs-close-save-button/jobs-close-save-button.component";
|
||||
import JobsCloseExportButton from "../../components/jobs-close-export-button/jobs-close-export-button.component";
|
||||
import JobsScoreboardAdd from "../../components/job-scoreboard-add-button/job-scoreboard-add-button.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -115,6 +116,7 @@ export function JobsCloseComponent({ job, bodyshop, jobTotals }) {
|
||||
.subtract(partsAllocatedTotal)
|
||||
.getAmount()}
|
||||
/>
|
||||
<JobsScoreboardAdd job={job} disabled={!invoiced} />
|
||||
<JobsCloseExportButton jobId={job.id} disabled={!invoiced} />
|
||||
<JobsCloseTotals
|
||||
jobTotals={jobTotals}
|
||||
|
||||
@@ -530,6 +530,7 @@
|
||||
"addDocuments": "Add Job Documents",
|
||||
"addNote": "Add Note",
|
||||
"addtoproduction": "Add to Production",
|
||||
"addtoscoreboard": "Add to Scoreboard",
|
||||
"allocate": "Allocate",
|
||||
"autoallocate": "Auto Allocate",
|
||||
"changestatus": "Change Status",
|
||||
@@ -1016,6 +1017,7 @@
|
||||
},
|
||||
"scoreboard": {
|
||||
"errors": {
|
||||
"adding": "Error adding job to scoreboard. {{message}}",
|
||||
"removing": "Error removing job from scoreboard. {{message}}"
|
||||
},
|
||||
"fields": {
|
||||
@@ -1028,6 +1030,10 @@
|
||||
"monthlytarget": "Monthly",
|
||||
"weeklytarget": "Weekly",
|
||||
"workingdays": "Working Days / Month"
|
||||
},
|
||||
"successes": {
|
||||
"added": "Job added to scoreboard.",
|
||||
"removed": "Job removed from scoreboard."
|
||||
}
|
||||
},
|
||||
"templates": {
|
||||
|
||||
@@ -530,6 +530,7 @@
|
||||
"addDocuments": "Agregar documentos de trabajo",
|
||||
"addNote": "Añadir la nota",
|
||||
"addtoproduction": "",
|
||||
"addtoscoreboard": "",
|
||||
"allocate": "",
|
||||
"autoallocate": "",
|
||||
"changestatus": "Cambiar Estado",
|
||||
@@ -1016,6 +1017,7 @@
|
||||
},
|
||||
"scoreboard": {
|
||||
"errors": {
|
||||
"adding": "",
|
||||
"removing": ""
|
||||
},
|
||||
"fields": {
|
||||
@@ -1028,6 +1030,10 @@
|
||||
"monthlytarget": "",
|
||||
"weeklytarget": "",
|
||||
"workingdays": ""
|
||||
},
|
||||
"successes": {
|
||||
"added": "",
|
||||
"removed": ""
|
||||
}
|
||||
},
|
||||
"templates": {
|
||||
|
||||
@@ -530,6 +530,7 @@
|
||||
"addDocuments": "Ajouter des documents de travail",
|
||||
"addNote": "Ajouter une note",
|
||||
"addtoproduction": "",
|
||||
"addtoscoreboard": "",
|
||||
"allocate": "",
|
||||
"autoallocate": "",
|
||||
"changestatus": "Changer le statut",
|
||||
@@ -1016,6 +1017,7 @@
|
||||
},
|
||||
"scoreboard": {
|
||||
"errors": {
|
||||
"adding": "",
|
||||
"removing": ""
|
||||
},
|
||||
"fields": {
|
||||
@@ -1028,6 +1030,10 @@
|
||||
"monthlytarget": "",
|
||||
"weeklytarget": "",
|
||||
"workingdays": ""
|
||||
},
|
||||
"successes": {
|
||||
"added": "",
|
||||
"removed": ""
|
||||
}
|
||||
},
|
||||
"templates": {
|
||||
|
||||
Reference in New Issue
Block a user