IO-2157 Added save to job notes button
This commit is contained in:
@@ -34,7 +34,7 @@ export function NoteUpsertModalContainer({
|
||||
const [updateNote] = useMutation(UPDATE_NOTE);
|
||||
|
||||
const { visible, context, actions } = noteUpsertModal;
|
||||
const { jobId, existingNote } = context;
|
||||
const { jobId, existingNote, text } = context;
|
||||
const { refetch } = actions;
|
||||
|
||||
const [form] = Form.useForm();
|
||||
@@ -45,8 +45,12 @@ export function NoteUpsertModalContainer({
|
||||
form.setFieldsValue(existingNote);
|
||||
} else if (!existingNote && visible) {
|
||||
form.resetFields();
|
||||
|
||||
if (text) {
|
||||
form.setFieldValue("text", text);
|
||||
}
|
||||
}
|
||||
}, [existingNote, form, visible]);
|
||||
}, [existingNote, form, visible, text]);
|
||||
|
||||
const handleFinish = async (formValues) => {
|
||||
const { relatedros, ...values } = formValues;
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
import Icon from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, Input, Popover } from "antd";
|
||||
import { Button, Input, Popover, Space } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaRegStickyNote } from "react-icons/fa";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
export default function ProductionListColumnProductionNote({ record }) {
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setNoteUpsertContext: (context) =>
|
||||
dispatch(setModalContext({ context: context, modal: "noteUpsert" })),
|
||||
});
|
||||
|
||||
function ProductionListColumnProductionNote({ record, setNoteUpsertContext }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [note, setNote] = useState(
|
||||
@@ -60,12 +71,26 @@ export default function ProductionListColumnProductionNote({ record }) {
|
||||
// onPressEnter={handleSaveNote}
|
||||
autoFocus
|
||||
allowClear
|
||||
style={{ marginBottom: "1em" }}
|
||||
/>
|
||||
<div>
|
||||
<Button onClick={handleSaveNote}>
|
||||
<Space>
|
||||
<Button onClick={handleSaveNote} type="primary">
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setVisible(false);
|
||||
setNoteUpsertContext({
|
||||
context: {
|
||||
jobId: record.jobId,
|
||||
text: note,
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
Save to Job Notes
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
}
|
||||
trigger={["click"]}
|
||||
@@ -85,3 +110,8 @@ export default function ProductionListColumnProductionNote({ record }) {
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ProductionListColumnProductionNote);
|
||||
|
||||
Reference in New Issue
Block a user