IO-777 Added employee select to report center.
This commit is contained in:
@@ -27410,6 +27410,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>employee</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>
|
<concept_node>
|
||||||
<name>generateasemail</name>
|
<name>generateasemail</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useLazyQuery } from "@apollo/client";
|
import { useLazyQuery } from "@apollo/client";
|
||||||
import { Button, DatePicker, Form, Select, Switch } from "antd";
|
import { Button, DatePicker, Form, Select, Switch } from "antd";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -11,6 +11,8 @@ import { GenerateDocument } from "../../utils/RenderTemplate";
|
|||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
||||||
import DatePIckerRanges from "../../utils/DatePickerRanges";
|
import DatePIckerRanges from "../../utils/DatePickerRanges";
|
||||||
|
import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component";
|
||||||
|
import { QUERY_ACTIVE_EMPLOYEES } from "../../graphql/employees.queries";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
reportCenterModal: selectReportCenter,
|
reportCenterModal: selectReportCenter,
|
||||||
@@ -25,11 +27,15 @@ export default connect(
|
|||||||
|
|
||||||
export function ReportCenterModalComponent({ reportCenterModal }) {
|
export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const Templates = TemplateList("report_center");
|
const Templates = TemplateList("report_center");
|
||||||
const { visible } = reportCenterModal;
|
const { visible } = reportCenterModal;
|
||||||
|
|
||||||
const [callVendorQuery, { data, called }] = useLazyQuery(QUERY_ALL_VENDORS, {
|
const [
|
||||||
|
callVendorQuery,
|
||||||
|
{ data: vendorData, called: vendorCalled },
|
||||||
|
] = useLazyQuery(QUERY_ALL_VENDORS, {
|
||||||
skip: !(
|
skip: !(
|
||||||
visible &&
|
visible &&
|
||||||
Templates[form.getFieldValue("key")] &&
|
Templates[form.getFieldValue("key")] &&
|
||||||
@@ -37,12 +43,24 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const [
|
||||||
|
callEmployeeQuery,
|
||||||
|
{ data: employeeData, called: employeeCalled },
|
||||||
|
] = useLazyQuery(QUERY_ACTIVE_EMPLOYEES, {
|
||||||
|
skip: !(
|
||||||
|
visible &&
|
||||||
|
Templates[form.getFieldValue("key")] &&
|
||||||
|
Templates[form.getFieldValue("key")].idtype
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleFinish = async (values) => {
|
||||||
|
setLoading(true);
|
||||||
const start = values.dates[0];
|
const start = values.dates[0];
|
||||||
const end = values.dates[1];
|
const end = values.dates[1];
|
||||||
const { id } = values;
|
const { id } = values;
|
||||||
console.log("values", values);
|
console.log("values", values);
|
||||||
GenerateDocument(
|
await GenerateDocument(
|
||||||
{
|
{
|
||||||
name: values.key,
|
name: values.key,
|
||||||
variables: {
|
variables: {
|
||||||
@@ -56,6 +74,7 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
|||||||
},
|
},
|
||||||
values.email ? "e" : "p"
|
values.email ? "e" : "p"
|
||||||
);
|
);
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -89,7 +108,8 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
|||||||
//Kind of Id
|
//Kind of Id
|
||||||
const idtype = Templates[key] && Templates[key].idtype;
|
const idtype = Templates[key] && Templates[key].idtype;
|
||||||
if (!idtype) return null;
|
if (!idtype) return null;
|
||||||
if (!called && idtype === "vendor") callVendorQuery();
|
if (!vendorCalled && idtype === "vendor") callVendorQuery();
|
||||||
|
if (!employeeCalled && idtype === "employee") callEmployeeQuery();
|
||||||
if (idtype === "vendor")
|
if (idtype === "vendor")
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -102,7 +122,26 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<VendorSearchSelect options={data ? data.vendors : []} />
|
<VendorSearchSelect
|
||||||
|
options={vendorData ? vendorData.vendors : []}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
if (idtype === "employee")
|
||||||
|
return (
|
||||||
|
<Form.Item
|
||||||
|
name="id"
|
||||||
|
label={t("reportcenter.labels.employee")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<EmployeeSearchSelect
|
||||||
|
options={employeeData ? employeeData.employees : []}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
else return null;
|
else return null;
|
||||||
@@ -138,7 +177,7 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
|||||||
marginTop: "1rem",
|
marginTop: "1rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button onClick={() => form.submit()} style={{}}>
|
<Button onClick={() => form.submit()} style={{}} loading={loading}>
|
||||||
{t("reportcenter.actions.generate")}
|
{t("reportcenter.actions.generate")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1662,6 +1662,7 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"dates": "Dates",
|
"dates": "Dates",
|
||||||
|
"employee": "Employee",
|
||||||
"generateasemail": "Generate as Email?",
|
"generateasemail": "Generate as Email?",
|
||||||
"key": "Report",
|
"key": "Report",
|
||||||
"vendor": "Vendor"
|
"vendor": "Vendor"
|
||||||
|
|||||||
@@ -1662,6 +1662,7 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"dates": "",
|
"dates": "",
|
||||||
|
"employee": "",
|
||||||
"generateasemail": "",
|
"generateasemail": "",
|
||||||
"key": "",
|
"key": "",
|
||||||
"vendor": ""
|
"vendor": ""
|
||||||
|
|||||||
@@ -1662,6 +1662,7 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"dates": "",
|
"dates": "",
|
||||||
|
"employee": "",
|
||||||
"generateasemail": "",
|
"generateasemail": "",
|
||||||
"key": "",
|
"key": "",
|
||||||
"vendor": ""
|
"vendor": ""
|
||||||
|
|||||||
@@ -326,13 +326,7 @@ export const TemplateList = (type, context) => {
|
|||||||
key: "schedule",
|
key: "schedule",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
timetickets: {
|
|
||||||
title: i18n.t("reportcenter.templates.timetickets"),
|
|
||||||
description: "Est Detail",
|
|
||||||
subject: i18n.t("reportcenter.templates.timetickets"),
|
|
||||||
key: "timetickets",
|
|
||||||
disabled: false,
|
|
||||||
},
|
|
||||||
purchases_by_vendor_detailed_date_range: {
|
purchases_by_vendor_detailed_date_range: {
|
||||||
title: i18n.t(
|
title: i18n.t(
|
||||||
"reportcenter.templates.purchases_by_vendor_detailed_date_range"
|
"reportcenter.templates.purchases_by_vendor_detailed_date_range"
|
||||||
@@ -357,12 +351,19 @@ export const TemplateList = (type, context) => {
|
|||||||
idtype: "vendor",
|
idtype: "vendor",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
|
timetickets: {
|
||||||
|
title: i18n.t("reportcenter.templates.timetickets"),
|
||||||
|
description: "Est Detail",
|
||||||
|
subject: i18n.t("reportcenter.templates.timetickets"),
|
||||||
|
key: "timetickets",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
timetickets_employee: {
|
timetickets_employee: {
|
||||||
title: i18n.t("reportcenter.templates.timetickets_employee"),
|
title: i18n.t("reportcenter.templates.timetickets_employee"),
|
||||||
description: "Est Detail",
|
description: "Est Detail",
|
||||||
subject: i18n.t("reportcenter.templates.timetickets_employee"),
|
subject: i18n.t("reportcenter.templates.timetickets_employee"),
|
||||||
key: "timetickets_employee",
|
key: "timetickets_employee",
|
||||||
idtype: "vendor",
|
idtype: "employee",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
timetickets_summary: {
|
timetickets_summary: {
|
||||||
@@ -370,7 +371,7 @@ export const TemplateList = (type, context) => {
|
|||||||
description: "Est Detail",
|
description: "Est Detail",
|
||||||
subject: i18n.t("reportcenter.templates.timetickets_summary"),
|
subject: i18n.t("reportcenter.templates.timetickets_summary"),
|
||||||
key: "timetickets_summary",
|
key: "timetickets_summary",
|
||||||
idtype: "vendor",
|
//idtype: "vendor",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user