Added remove from scoreboard functionality BOD-91
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<babeledit_project version="1.2" be_version="2.6.1">
|
||||
<babeledit_project be_version="2.6.1" version="1.2">
|
||||
<!--
|
||||
|
||||
BabelEdit project file
|
||||
@@ -16209,6 +16209,79 @@
|
||||
<folder_node>
|
||||
<name>scoreboard</name>
|
||||
<children>
|
||||
<folder_node>
|
||||
<name>errors</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>removing</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>fields</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>bodyhrs</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>painthrs</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>labels</name>
|
||||
<children>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from "react";
|
||||
|
||||
import ScoreboardTargetsTable from "../scoreboard-targets-table/scoreboard-targets-table.component";
|
||||
import ScoreboardLastDays from "../scoreboard-last-days/scoreboard-last-days.component";
|
||||
import ScoreboardChart from "../scoreboard-chart/scoreboard-chart.component";
|
||||
import ScoreboardJobsList from "../scoreboard-jobs-list/scoreboard-jobs-list.component";
|
||||
import ScoreboardLastDays from "../scoreboard-last-days/scoreboard-last-days.component";
|
||||
import ScoreboardTargetsTable from "../scoreboard-targets-table/scoreboard-targets-table.component";
|
||||
|
||||
export default function ScoreboardDisplayComponent({ scoreboardSubscription }) {
|
||||
const { loading, error, data } = scoreboardSubscription;
|
||||
@@ -24,6 +24,7 @@ export default function ScoreboardDisplayComponent({ scoreboardSubscription }) {
|
||||
return (
|
||||
<div>
|
||||
<ScoreboardTargetsTable />
|
||||
<ScoreboardJobsList scoreBoardlist={scoreBoardlist} />
|
||||
<ScoreboardLastDays sbEntriesByDate={sbEntriesByDate} />
|
||||
<ScoreboardChart sbEntriesByDate={sbEntriesByDate} />
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
import React from "react";
|
||||
import { Dropdown, Button, Table } from "antd";
|
||||
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";
|
||||
|
||||
export default function ScoreboardJobsList({ scoreBoardlist }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("jobs.fields.ro_number"),
|
||||
dataIndex: "ro_number",
|
||||
key: "ro_number",
|
||||
render: (text, record) => (
|
||||
<Link to={"/manage/jobs/" + record.job.id}>{record.job.ro_number}</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.est_number"),
|
||||
dataIndex: "est_number",
|
||||
key: "est_number",
|
||||
render: (text, record) => (
|
||||
<Link to={"/manage/jobs/" + record.job.id}>
|
||||
{record.job.est_number}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("scoreboard.fields.date"),
|
||||
dataIndex: "date",
|
||||
key: "date",
|
||||
render: (text, record) => <DateFormatter>{record.date}</DateFormatter>,
|
||||
},
|
||||
{
|
||||
title: t("scoreboard.fields.painthrs"),
|
||||
dataIndex: "painthrs",
|
||||
key: "painthrs",
|
||||
},
|
||||
{
|
||||
title: t("scoreboard.fields.bodyhrs"),
|
||||
dataIndex: "bodyhrs",
|
||||
key: "bodyhrs",
|
||||
},
|
||||
{
|
||||
title: t("general.labels.actions"),
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<div>
|
||||
<ScoreboardRemoveButton scoreboardId={record.id} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const overlay = (
|
||||
<div style={{ width: "30vw" }}>
|
||||
<Table
|
||||
size='small'
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
rowKey='id'
|
||||
dataSource={scoreBoardlist}
|
||||
scroll={{ x: true, y: "15rem" }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Dropdown trigger={["click"]} overlay={overlay}>
|
||||
<Button>Jobs</Button>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, notification } from "antd";
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { DELETE_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries";
|
||||
|
||||
export default function ScoreboardRemoveButton({ scoreboardId }) {
|
||||
const { t } = useTranslation();
|
||||
const [deleteScoreboardEntry] = useMutation(DELETE_SCOREBOARD_ENTRY);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const handleDelete = async (e) => {
|
||||
e.stopPropagation();
|
||||
setLoading(true);
|
||||
const result = await deleteScoreboardEntry({
|
||||
variables: { sbId: scoreboardId },
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("scoreboard.errors.removing", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
return (
|
||||
<Button onClick={handleDelete} loading={loading}>
|
||||
<DeleteFilled />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,16 @@ export const SUBSCRIPTION_SCOREBOARD = gql`
|
||||
job {
|
||||
id
|
||||
ro_number
|
||||
est_number
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_SCOREBOARD_ENTRY = gql`
|
||||
mutation DELETE_SCOREBOARD_ENTRY($sbId: uuid!) {
|
||||
delete_scoreboard_by_pk(id: $sbId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1015,6 +1015,13 @@
|
||||
}
|
||||
},
|
||||
"scoreboard": {
|
||||
"errors": {
|
||||
"removing": "Error removing job from scoreboard. {{message}}"
|
||||
},
|
||||
"fields": {
|
||||
"bodyhrs": "Body Hours",
|
||||
"painthrs": "Paint Hours"
|
||||
},
|
||||
"labels": {
|
||||
"asoftodaytarget": "As of Today",
|
||||
"dailytarget": "Daily",
|
||||
|
||||
@@ -1015,6 +1015,13 @@
|
||||
}
|
||||
},
|
||||
"scoreboard": {
|
||||
"errors": {
|
||||
"removing": ""
|
||||
},
|
||||
"fields": {
|
||||
"bodyhrs": "",
|
||||
"painthrs": ""
|
||||
},
|
||||
"labels": {
|
||||
"asoftodaytarget": "",
|
||||
"dailytarget": "",
|
||||
|
||||
@@ -1015,6 +1015,13 @@
|
||||
}
|
||||
},
|
||||
"scoreboard": {
|
||||
"errors": {
|
||||
"removing": ""
|
||||
},
|
||||
"fields": {
|
||||
"bodyhrs": "",
|
||||
"painthrs": ""
|
||||
},
|
||||
"labels": {
|
||||
"asoftodaytarget": "",
|
||||
"dailytarget": "",
|
||||
|
||||
Reference in New Issue
Block a user