IO-1430 Add note on last contacted update.
This commit is contained in:
@@ -29415,6 +29415,32 @@
|
|||||||
</concept_node>
|
</concept_node>
|
||||||
</children>
|
</children>
|
||||||
</folder_node>
|
</folder_node>
|
||||||
|
<folder_node>
|
||||||
|
<name>errors</name>
|
||||||
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>inserting</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>
|
<folder_node>
|
||||||
<name>fields</name>
|
<name>fields</name>
|
||||||
<children>
|
<children>
|
||||||
@@ -29549,6 +29575,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>notetoadd</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>
|
</children>
|
||||||
</folder_node>
|
</folder_node>
|
||||||
<folder_node>
|
<folder_node>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import ProductionListColumnPaintPriority from "./production-list-columns.paintpr
|
|||||||
import ProductionListColumnNote from "./production-list-columns.productionnote.component";
|
import ProductionListColumnNote from "./production-list-columns.productionnote.component";
|
||||||
import ProductionListColumnStatus from "./production-list-columns.status.component";
|
import ProductionListColumnStatus from "./production-list-columns.status.component";
|
||||||
import ProductionlistColumnTouchTime from "./prodution-list-columns.touchtime.component";
|
import ProductionlistColumnTouchTime from "./prodution-list-columns.touchtime.component";
|
||||||
|
import ProductionListLastContacted from "./production-list-columns.lastcontacted.component";
|
||||||
|
|
||||||
const r = ({ technician, state }) => {
|
const r = ({ technician, state }) => {
|
||||||
return [
|
return [
|
||||||
@@ -106,9 +107,7 @@ const r = ({ technician, state }) => {
|
|||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "date_last_contacted" &&
|
state.sortedInfo.columnKey === "date_last_contacted" &&
|
||||||
state.sortedInfo.order,
|
state.sortedInfo.order,
|
||||||
render: (text, record) => (
|
render: (text, record) => <ProductionListLastContacted record={record} />,
|
||||||
<ProductionListDate time record={record} field="date_last_contacted" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: i18n.t("jobs.fields.scheduled_delivery"),
|
title: i18n.t("jobs.fields.scheduled_delivery"),
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
import { useMutation } from "@apollo/client";
|
||||||
|
import { Button, Card, Dropdown, Form, Input, notification, Space } from "antd";
|
||||||
|
import moment from "moment";
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
|
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
|
import { INSERT_NEW_NOTE } from "../../graphql/notes.queries";
|
||||||
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
|
import { DateFormatter } from "../../utils/DateFormatter";
|
||||||
|
import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
currentUser: selectCurrentUser,
|
||||||
|
});
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
|
});
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(ProductionLastContacted);
|
||||||
|
|
||||||
|
export function ProductionLastContacted({ currentUser, record }) {
|
||||||
|
const [updateAlert] = useMutation(UPDATE_JOB);
|
||||||
|
const [insertNote] = useMutation(INSERT_NEW_NOTE);
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const handleFinish = async ({ date_last_contacted, note }) => {
|
||||||
|
logImEXEvent("production_last_contacted");
|
||||||
|
|
||||||
|
//e.stopPropagation();
|
||||||
|
const res = await updateAlert({
|
||||||
|
variables: {
|
||||||
|
jobId: record.id,
|
||||||
|
job: {
|
||||||
|
date_last_contacted,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res.errors) {
|
||||||
|
notification.open({
|
||||||
|
type: "error",
|
||||||
|
message: t("jobs.errors.saving", {
|
||||||
|
error: JSON.stringify(res.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (note && note.trim() !== "") {
|
||||||
|
//Insert a note.
|
||||||
|
const res2 = await insertNote({
|
||||||
|
variables: {
|
||||||
|
noteInput: {
|
||||||
|
jobid: record.id,
|
||||||
|
text: note,
|
||||||
|
created_by: currentUser.email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res2.errors) {
|
||||||
|
notification.open({
|
||||||
|
type: "error",
|
||||||
|
message: t("notes.errors.inserting", {
|
||||||
|
error: JSON.stringify(res.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (record.refetch) record.refetch();
|
||||||
|
|
||||||
|
setVisible(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
note: null,
|
||||||
|
date_last_contacted:
|
||||||
|
record.date_last_contacted && moment(record.date_last_contacted),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [visible, form, record.date_last_contacted]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Dropdown
|
||||||
|
//trigger={["click"]}
|
||||||
|
visible={visible}
|
||||||
|
style={{
|
||||||
|
height: "19px",
|
||||||
|
}}
|
||||||
|
overlay={
|
||||||
|
<Card
|
||||||
|
style={{ padding: "1rem" }}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<Form form={form} onFinish={handleFinish} layout="vertical">
|
||||||
|
<Form.Item name="date_last_contacted">
|
||||||
|
<FormDateTimePickerComponent />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label={t("notes.labels.notetoadd")} name="note">
|
||||||
|
<Input.TextArea rows={4} />
|
||||||
|
</Form.Item>
|
||||||
|
<Space>
|
||||||
|
<Button type="primary" htmlType="submit">
|
||||||
|
{t("general.actions.save")}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => setVisible(false)}>
|
||||||
|
{t("general.actions.close")}
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Form>
|
||||||
|
</Card>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
onClick={() => setVisible(true)}
|
||||||
|
style={{
|
||||||
|
height: "19px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DateFormatter bordered={false}>
|
||||||
|
{record.date_last_contacted}
|
||||||
|
</DateFormatter>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1739,6 +1739,9 @@
|
|||||||
"edit": "Edit Note",
|
"edit": "Edit Note",
|
||||||
"new": "New Note"
|
"new": "New Note"
|
||||||
},
|
},
|
||||||
|
"errors": {
|
||||||
|
"inserting": "Error inserting note. {{error}}"
|
||||||
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"createdby": "Created By",
|
"createdby": "Created By",
|
||||||
"critical": "Critical",
|
"critical": "Critical",
|
||||||
@@ -1747,7 +1750,8 @@
|
|||||||
"updatedat": "Updated At"
|
"updatedat": "Updated At"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"newnoteplaceholder": "Add a note..."
|
"newnoteplaceholder": "Add a note...",
|
||||||
|
"notetoadd": "Note to Add"
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"create": "Note created successfully.",
|
"create": "Note created successfully.",
|
||||||
|
|||||||
@@ -1739,6 +1739,9 @@
|
|||||||
"edit": "Editar nota",
|
"edit": "Editar nota",
|
||||||
"new": "Nueva nota"
|
"new": "Nueva nota"
|
||||||
},
|
},
|
||||||
|
"errors": {
|
||||||
|
"inserting": ""
|
||||||
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"createdby": "Creado por",
|
"createdby": "Creado por",
|
||||||
"critical": "Crítico",
|
"critical": "Crítico",
|
||||||
@@ -1747,7 +1750,8 @@
|
|||||||
"updatedat": "Actualizado en"
|
"updatedat": "Actualizado en"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"newnoteplaceholder": "Agrega una nota..."
|
"newnoteplaceholder": "Agrega una nota...",
|
||||||
|
"notetoadd": ""
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"create": "Nota creada con éxito.",
|
"create": "Nota creada con éxito.",
|
||||||
|
|||||||
@@ -1739,6 +1739,9 @@
|
|||||||
"edit": "Note éditée",
|
"edit": "Note éditée",
|
||||||
"new": "Nouvelle note"
|
"new": "Nouvelle note"
|
||||||
},
|
},
|
||||||
|
"errors": {
|
||||||
|
"inserting": ""
|
||||||
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"createdby": "Créé par",
|
"createdby": "Créé par",
|
||||||
"critical": "Critique",
|
"critical": "Critique",
|
||||||
@@ -1747,7 +1750,8 @@
|
|||||||
"updatedat": "Mis à jour à"
|
"updatedat": "Mis à jour à"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"newnoteplaceholder": "Ajouter une note..."
|
"newnoteplaceholder": "Ajouter une note...",
|
||||||
|
"notetoadd": ""
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"create": "Remarque créée avec succès.",
|
"create": "Remarque créée avec succès.",
|
||||||
|
|||||||
Reference in New Issue
Block a user