Added scoreboard edt for added entries BOD-365

This commit is contained in:
Patrick Fic
2020-08-28 16:34:48 -07:00
parent ab4262c238
commit 266b6b0dbb
14 changed files with 241 additions and 23 deletions

View File

@@ -19821,6 +19821,32 @@
<folder_node>
<name>scoreboard</name>
<children>
<folder_node>
<name>actions</name>
<children>
<concept_node>
<name>edit</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>
<folder_node>
<name>errors</name>
<children>
@@ -19866,6 +19892,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>updating</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>
<folder_node>
@@ -20091,6 +20138,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>updated</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>

View File

@@ -1,5 +1,6 @@
import React from "react";
import { Tag } from "antd";
import Dinero from "dinero.js";
export default function JobsCloseLabMatAllocationTags({
allocationKey,
allocation,
@@ -27,7 +28,7 @@ export default function JobsCloseLabMatAllocationTags({
});
}}
key={idx}
>{`${a.center} - ${a.amount.toFormat()}`}</Tag>
>{`${a.center} - ${Dinero(a.amount).toFormat()}`}</Tag>
))}
</div>
);

View File

@@ -5,7 +5,7 @@ import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { useTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils";
import Dinero from "dinero.js";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
@@ -28,7 +28,10 @@ export function JobsCloseAutoAllocate({
Object.keys(labmatAllocations).forEach((i) => {
const defaultProfitCenter = defaults.profits[i.toUpperCase()];
if (!!defaultProfitCenter && labmatAllocations[i].total.getAmount() > 0) {
if (
!!defaultProfitCenter &&
Dinero(labmatAllocations[i].total).getAmount() > 0
) {
setLabmatAllocations((st) => {
return {
...st,
@@ -49,7 +52,10 @@ export function JobsCloseAutoAllocate({
Object.keys(partsAllocations).forEach((i) => {
const defaultProfitCenter = defaults.profits[i.toUpperCase()];
if (!!defaultProfitCenter && partsAllocations[i].total.getAmount() > 0) {
if (
!!defaultProfitCenter &&
Dinero(partsAllocations[i].total).getAmount() > 0
) {
setPartsAllocations((st) => {
return {
...st,

View File

@@ -40,8 +40,7 @@ export default function JobCloseLabMatAllocation({
Dinero({
amount: labmatAllocations[alloc].allocations.reduce(
(acc, val) => {
console.log("val :>> ", val);
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),
@@ -58,7 +57,7 @@ export default function JobCloseLabMatAllocation({
Dinero({
amount: labmatAllocations[alloc].allocations.reduce(
(acc, val) => {
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),

View File

@@ -40,7 +40,7 @@ export default function JobsClosePartsAllocation({
Dinero({
amount: partsAllocations[alloc].allocations.reduce(
(acc, val) => {
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),
@@ -57,7 +57,7 @@ export default function JobsClosePartsAllocation({
Dinero({
amount: partsAllocations[alloc].allocations.reduce(
(acc, val) => {
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),

View File

@@ -100,7 +100,6 @@ export function ScheduleCalendarHeaderComponent({
</div>
</Popover>
) : null;
console.log("loadData", loadData);
return (
<div className="imex-calendar-load">

View File

@@ -0,0 +1,104 @@
import { Button, Card, Dropdown, Form, InputNumber, notification } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import FormDatePicker from "../form-date-picker/form-date-picker.component";
import { useMutation } from "react-apollo";
import { UPDATE_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries";
export default function ScoreboardEntryEdit({ entry }) {
const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false);
const { t } = useTranslation();
const [updateScoreboardentry] = useMutation(UPDATE_SCOREBOARD_ENTRY);
const handleFinish = async (values) => {
setLoading(true);
const result = await updateScoreboardentry({
variables: { sbId: entry.id, sbInput: values },
});
if (!!result.errors) {
notification["error"]({
message: t("scoreboard.errors.updating", {
message: JSON.stringify(result.errors),
}),
});
return;
} else {
notification["success"]({
message: t("scoredboard.successes.updated"),
});
setVisible(false);
}
setLoading(false);
};
const popContent = (
<Card style={{ padding: "1rem" }}>
<Form
layout="vertical"
initialValues={entry}
onFinish={handleFinish}
onClick={(e) => e.stopPropagation()}
>
<Form.Item
label={t("scoreboard.fields.date")}
name="date"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<FormDatePicker />
</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" loading={loading} htmlType="submit">
{t("general.actions.save")}
</Button>
<Button onClick={() => setVisible(false)}>
{t("general.actions.cancel")}
</Button>
</Form>
</Card>
);
return (
<div>
<Dropdown visible={visible} overlay={popContent}>
<Button
onClick={(e) => {
e.stopPropagation();
setVisible(true);
}}
>
{t("scoreboard.actions.edit")}
</Button>
</Dropdown>
</div>
);
}

View File

@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import ScoreboardRemoveButton from "../scoreboard-remove-button/scorebard-remove-button.component";
import { DateFormatter } from "../../utils/DateFormatter";
import ScoreboardEntryEdit from "../scoreboard-entry-edit/scoreboard-entry-edit.component";
export default function ScoreboardJobsList({ scoreBoardlist }) {
const { t } = useTranslation();
@@ -49,6 +50,7 @@ export default function ScoreboardJobsList({ scoreBoardlist }) {
key: "actions",
render: (text, record) => (
<div>
<ScoreboardEntryEdit entry={record} style={{ zIndex: 15 }} />
<ScoreboardRemoveButton scoreboardId={record.id} />
</div>
),
@@ -56,14 +58,16 @@ export default function ScoreboardJobsList({ scoreBoardlist }) {
];
const overlay = (
<div style={{ width: "50vw" }}>
<div style={{ width: "50vw", padding: "1rem" }}>
<Table
size='small'
size="small"
pagination={false}
columns={columns}
rowKey='id'
rowKey="id"
dataSource={scoreBoardlist}
scroll={{ x: true, y: "15rem" }}
style={{ padding: "1rem" }}
onClick={(e) => e.stopPropagation()}
/>
</div>
);

View File

@@ -35,3 +35,17 @@ export const INSERT_SCOREBOARD_ENTRY = gql`
}
}
`;
export const UPDATE_SCOREBOARD_ENTRY = gql`
mutation UPDATE_SCOREBOARD_ENTRY(
$sbId: uuid!
$sbInput: scoreboard_set_input!
) {
update_scoreboard_by_pk(_set: $sbInput, pk_columns: { id: $sbId }) {
id
date
bodyhrs
painthrs
}
}
`;

View File

@@ -87,7 +87,7 @@ export function JobsCloseComponent({ job, bodyshop, jobTotals }) {
const labmatAllocatedTotal = Dinero({
amount: labmatAllocatedTotalsArray.reduce((acc, val) => {
return (acc = acc + val.amount.getAmount());
return (acc = acc + Dinero(val.amount).getAmount());
}, 0),
});
@@ -97,7 +97,7 @@ export function JobsCloseComponent({ job, bodyshop, jobTotals }) {
const partsAllocatedTotal = Dinero({
amount: partsAllocatedTotalsArray.reduce((acc, val) => {
return (acc = acc + val.amount.getAmount());
return (acc = acc + Dinero(val.amount).getAmount());
}, 0),
});

View File

@@ -10,6 +10,8 @@ import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import { QUERY_JOB_CLOSE_DETAILS } from "../../graphql/jobs.queries";
import { setBreadcrumbs } from "../../redux/application/application.actions";
import JobsCloseComponent from "./jobs-close.component";
import { Result } from "antd";
import JobCalculateTotals from "../../components/job-calculate-totals/job-calculate-totals.component";
const mapDispatchToProps = (dispatch) => ({
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
@@ -47,13 +49,19 @@ export function JobsCloseContainer({ setBreadcrumbs }) {
if (loading) return <LoadingSpinner />;
if (error) return <AlertComponent message={error.message} type="error" />;
if (!!!data.jobs_by_pk) return <NotFound />;
if (!data.jobs_by_pk.job_totals)
return (
<Result
title={t("jobs.errors.nofinancial")}
extra={<JobCalculateTotals job={data.jobs_by_pk} />}
/>
);
return (
<RbacWrapper action="jobs:close">
<div>
<JobsCloseComponent
job={data ? data.jobs_by_pk : {}}
jobTotals={JSON.parse(data.jobs_by_pk.job_totals)}
jobTotals={data.jobs_by_pk.job_totals}
/>
</div>
</RbacWrapper>

View File

@@ -1224,9 +1224,13 @@
}
},
"scoreboard": {
"actions": {
"edit": "Edit"
},
"errors": {
"adding": "Error adding job to scoreboard. {{message}}",
"removing": "Error removing job from scoreboard. {{message}}"
"removing": "Error removing job from scoreboard. {{message}}",
"updating": "Error updating scoreboard. {{message}}"
},
"fields": {
"bodyhrs": "Body Hours",
@@ -1242,7 +1246,8 @@
},
"successes": {
"added": "Job added to scoreboard.",
"removed": "Job removed from scoreboard."
"removed": "Job removed from scoreboard.",
"updated": "Scoreboard updated."
}
},
"tech": {

View File

@@ -1224,9 +1224,13 @@
}
},
"scoreboard": {
"actions": {
"edit": ""
},
"errors": {
"adding": "",
"removing": ""
"removing": "",
"updating": ""
},
"fields": {
"bodyhrs": "",
@@ -1242,7 +1246,8 @@
},
"successes": {
"added": "",
"removed": ""
"removed": "",
"updated": ""
}
},
"tech": {

View File

@@ -1224,9 +1224,13 @@
}
},
"scoreboard": {
"actions": {
"edit": ""
},
"errors": {
"adding": "",
"removing": ""
"removing": "",
"updating": ""
},
"fields": {
"bodyhrs": "",
@@ -1242,7 +1246,8 @@
},
"successes": {
"added": "",
"removed": ""
"removed": "",
"updated": ""
}
},
"tech": {