Added temporary document handling IO-69
This commit is contained in:
@@ -127,12 +127,13 @@ export const uploadToCloudinary = async (
|
||||
variables: {
|
||||
docInput: [
|
||||
{
|
||||
jobid: jobId,
|
||||
...(jobId ? { jobid: jobId } : {}),
|
||||
...(billId ? { billid: billId } : {}),
|
||||
uploaded_by: uploaded_by,
|
||||
key: key,
|
||||
billid: billId,
|
||||
type: fileType,
|
||||
extension: extension,
|
||||
bodyshopid: bodyshop.id,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -163,7 +164,6 @@ export const uploadToCloudinary = async (
|
||||
};
|
||||
|
||||
export function DetermineFileType(filetype) {
|
||||
console.log("Checking Type", filetype, filetype.startsWith("video"));
|
||||
if (!filetype) return "auto";
|
||||
else if (filetype.startsWith("image")) return "image";
|
||||
else if (filetype.startsWith("video")) return "video";
|
||||
|
||||
@@ -265,7 +265,11 @@ function Header({
|
||||
<Menu.Item key="shop">
|
||||
<Link to="/manage/shop">{t("menus.header.shop_config")}</Link>
|
||||
</Menu.Item>
|
||||
|
||||
<Menu.Item key="temporarydocs">
|
||||
<Link to="/manage/temporarydocs">
|
||||
{t("menus.header.temporarydocs")}
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
<Menu.Item key="shop-templates">
|
||||
<Link to="/manage/shop/templates">
|
||||
{t("menus.header.shop_templates")}
|
||||
|
||||
@@ -113,6 +113,7 @@ export function JobDetailCards({ setPrintCenterContext }) {
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
id: data.jobs_by_pk.id,
|
||||
job: data.jobs_by_pk,
|
||||
type: "job",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -55,6 +55,7 @@ export function JobsDetailHeader({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
id: job.id,
|
||||
job: job,
|
||||
type: "job",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -102,6 +102,9 @@ export function JobsDetailTotals({
|
||||
name: TemplateList("payment").payment_receipt.key,
|
||||
variables: { id: p.id },
|
||||
}}
|
||||
messageObject={{
|
||||
to: job.ownr_ea,
|
||||
}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import { Button, Form, Popover, notification } from "antd";
|
||||
import React, { useState, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { UPDATE_DOCUMENT } from "../../graphql/documents.queries";
|
||||
import axios from "axios";
|
||||
|
||||
export default function JobsDocumentsGalleryReassign({ galleryImages }) {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const selectedImages = useMemo(() => {
|
||||
return [
|
||||
...galleryImages.images.filter((image) => image.isSelected),
|
||||
...galleryImages.other.filter((image) => image.isSelected),
|
||||
];
|
||||
}, [galleryImages]);
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updateDocument] = useMutation(UPDATE_DOCUMENT);
|
||||
|
||||
const updateImage = async (i, jobid) => {
|
||||
//Move the cloudinary image
|
||||
console.log(i);
|
||||
|
||||
//Update it in the database.
|
||||
const result = await updateDocument({
|
||||
variables: {
|
||||
id: i.id,
|
||||
document: {
|
||||
key: i.public_id,
|
||||
jobid: jobid,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("documents.errors.updating", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("documents.successes.updated"),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleFinish = async ({ jobid }) => {
|
||||
setLoading(true);
|
||||
|
||||
const res = await axios.post("/media/rename", {
|
||||
documents: selectedImages.map((i) => {
|
||||
return { id: i.id, from: i.key, to: i.key.replace("null", jobid) };
|
||||
}),
|
||||
});
|
||||
|
||||
console.log(res.data);
|
||||
|
||||
const proms = [];
|
||||
|
||||
res.data
|
||||
.filter((d) => !d.error)
|
||||
.forEach((d) => {
|
||||
proms.push(updateImage(d, jobid));
|
||||
});
|
||||
|
||||
await Promise.all(proms);
|
||||
|
||||
setVisible(false);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const popContent = (
|
||||
<div>
|
||||
<Form onFinish={handleFinish} layout="vertical" form={form}>
|
||||
<Form.Item
|
||||
label={t("documents.labels.newjobid")}
|
||||
style={{ width: "20rem" }}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={"jobid"}
|
||||
>
|
||||
<JobSearchSelect />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Button onClick={() => form.submit()}>
|
||||
{t("general.actions.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover content={popContent} visible={visible}>
|
||||
<Button
|
||||
disabled={selectedImages.length < 1}
|
||||
onClick={() => setVisible(true)}
|
||||
loading={loading}
|
||||
>
|
||||
{t("documents.actions.reassign")}
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
import { FileExcelFilled } from "@ant-design/icons";
|
||||
import { Card, Space } from "antd";
|
||||
import { Card } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Gallery from "react-grid-gallery";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import DocumentsUploadComponent from "../documents-upload/documents-upload.component";
|
||||
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
|
||||
import JobsDocumentsDownloadButton from "./jobs-document-gallery.download.component";
|
||||
import JobsDocumentsGalleryReassign from "./jobs-document-gallery.reassign.component";
|
||||
import JobsDocumentsDeleteButton from "./jobs-documents-gallery.delete.component";
|
||||
import JobsDocumentsGallerySelectAllComponent from "./jobs-documents-gallery.selectall.component";
|
||||
|
||||
function JobsDocumentsComponent({
|
||||
data,
|
||||
jobId,
|
||||
@@ -97,18 +99,17 @@ function JobsDocumentsComponent({
|
||||
|
||||
return (
|
||||
<div className="clearfix">
|
||||
<div>
|
||||
<Space>
|
||||
<JobsDocumentsGallerySelectAllComponent
|
||||
galleryImages={galleryImages}
|
||||
setGalleryImages={setgalleryImages}
|
||||
/>
|
||||
<JobsDocumentsDownloadButton galleryImages={galleryImages} />
|
||||
<JobsDocumentsDeleteButton
|
||||
galleryImages={galleryImages}
|
||||
deletionCallback={billsCallback || refetch}
|
||||
/>
|
||||
</Space>
|
||||
<div className="imex-flex-row">
|
||||
<JobsDocumentsGallerySelectAllComponent
|
||||
galleryImages={galleryImages}
|
||||
setGalleryImages={setgalleryImages}
|
||||
/>
|
||||
<JobsDocumentsDownloadButton galleryImages={galleryImages} />
|
||||
<JobsDocumentsDeleteButton
|
||||
galleryImages={galleryImages}
|
||||
deletionCallback={billsCallback || refetch}
|
||||
/>
|
||||
<JobsDocumentsGalleryReassign galleryImages={galleryImages} />
|
||||
</div>
|
||||
<DocumentsUploadComponent
|
||||
jobId={jobId}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Button } from "antd";
|
||||
import { Button, Space } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ export function PrintCenterItemComponent({
|
||||
bodyshop,
|
||||
disabled,
|
||||
}) {
|
||||
const { context } = printCenterModal;
|
||||
const renderToNewWindow = async () => {
|
||||
await GenerateDocument(
|
||||
{
|
||||
@@ -45,7 +46,7 @@ export function PrintCenterItemComponent({
|
||||
name: item.key,
|
||||
variables: { id: id },
|
||||
},
|
||||
{},
|
||||
{ to: context.job && context.job.ownr_ea },
|
||||
"e"
|
||||
);
|
||||
}}
|
||||
|
||||
@@ -50,6 +50,8 @@ const ret = {
|
||||
"shop:rbac": 5,
|
||||
"shop:templates": 4,
|
||||
|
||||
"temporarydocs:view": 2,
|
||||
|
||||
"timetickets:enter": 3,
|
||||
"timetickets:list": 3,
|
||||
"timetickets:edit": 4,
|
||||
|
||||
@@ -512,6 +512,18 @@ export default function ShopInfoRbacComponent({ form }) {
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.temporarydocs.view")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_rbac", "temporarydocs:view"]}
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -105,6 +105,7 @@ export function JobDetailCards({ setPrintCenterContext }) {
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
id: data.jobs_by_pk.id,
|
||||
job: data.jobs_by_pk,
|
||||
type: "job",
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user