Uploads and viewing from bills.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project version="1.2" be_version="2.7.1">
|
<babeledit_project be_version="2.7.1" version="1.2">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -13211,6 +13211,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>openinexplorer</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>reassign_limitexceeded</name>
|
<name>reassign_limitexceeded</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -12,27 +12,29 @@ import moment from "moment";
|
|||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useLocation, useHistory } from "react-router-dom";
|
import { connect } from "react-redux";
|
||||||
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
import {
|
import {
|
||||||
DELETE_BILL_LINE,
|
DELETE_BILL_LINE,
|
||||||
INSERT_NEW_BILL_LINES,
|
INSERT_NEW_BILL_LINES,
|
||||||
UPDATE_BILL_LINE,
|
UPDATE_BILL_LINE,
|
||||||
} from "../../graphql/bill-lines.queries";
|
} from "../../graphql/bill-lines.queries";
|
||||||
import { QUERY_BILL_BY_PK, UPDATE_BILL } from "../../graphql/bills.queries";
|
import { QUERY_BILL_BY_PK, UPDATE_BILL } from "../../graphql/bills.queries";
|
||||||
|
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||||
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import BillFormContainer from "../bill-form/bill-form.container";
|
import BillFormContainer from "../bill-form/bill-form.container";
|
||||||
import JobDocumentsGallery from "../jobs-documents-gallery/jobs-documents-gallery.container";
|
|
||||||
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
|
||||||
import BillReeportButtonComponent from "../bill-reexport-button/bill-reexport-button.component";
|
|
||||||
import { connect } from "react-redux";
|
|
||||||
import { createStructuredSelector } from "reselect";
|
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
|
||||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
|
||||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
|
||||||
import BillMarkExportedButton from "../bill-mark-exported-button/bill-mark-exported-button.component";
|
import BillMarkExportedButton from "../bill-mark-exported-button/bill-mark-exported-button.component";
|
||||||
|
import BillReeportButtonComponent from "../bill-reexport-button/bill-reexport-button.component";
|
||||||
|
import JobDocumentsGallery from "../jobs-documents-gallery/jobs-documents-gallery.container";
|
||||||
|
import JobsDocumentsLocalGallery from "../jobs-documents-local-gallery/jobs-documents-local-gallery.container";
|
||||||
|
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setPartsOrderContext: (context) =>
|
setPartsOrderContext: (context) =>
|
||||||
@@ -49,6 +51,7 @@ export default connect(
|
|||||||
export function BillDetailEditcontainer({
|
export function BillDetailEditcontainer({
|
||||||
setPartsOrderContext,
|
setPartsOrderContext,
|
||||||
insertAuditTrail,
|
insertAuditTrail,
|
||||||
|
bodyshop,
|
||||||
}) {
|
}) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -265,12 +268,21 @@ export function BillDetailEditcontainer({
|
|||||||
layout="vertical"
|
layout="vertical"
|
||||||
>
|
>
|
||||||
<BillFormContainer form={form} billEdit disabled={exported} />
|
<BillFormContainer form={form} billEdit disabled={exported} />
|
||||||
<JobDocumentsGallery
|
|
||||||
jobId={data ? data.bills_by_pk.jobid : null}
|
{bodyshop.uselocalmediaserver ? (
|
||||||
billId={search.billid}
|
<JobsDocumentsLocalGallery
|
||||||
documentsList={data ? data.bills_by_pk.documents : []}
|
job={{ id: data ? data.bills_by_pk.jobid : null }}
|
||||||
billsCallback={refetch}
|
invoice_number={data ? data.bills_by_pk.invoice_number : null}
|
||||||
/>
|
vendorid={data ? data.bills_by_pk.vendorid : null}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<JobDocumentsGallery
|
||||||
|
jobId={data ? data.bills_by_pk.jobid : null}
|
||||||
|
billId={search.billid}
|
||||||
|
documentsList={data ? data.bills_by_pk.documents : []}
|
||||||
|
billsCallback={refetch}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Form>
|
</Form>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
|||||||
import BillFormContainer from "../bill-form/bill-form.container";
|
import BillFormContainer from "../bill-form/bill-form.container";
|
||||||
import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility";
|
import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility";
|
||||||
import { handleUpload } from "../documents-upload/documents-upload.utility";
|
import { handleUpload } from "../documents-upload/documents-upload.utility";
|
||||||
|
import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
billEnterModal: selectBillEnterModal,
|
billEnterModal: selectBillEnterModal,
|
||||||
@@ -210,19 +211,33 @@ function BillEnterModalContainer({
|
|||||||
/////////////////////////
|
/////////////////////////
|
||||||
if (upload && upload.length > 0) {
|
if (upload && upload.length > 0) {
|
||||||
//insert Each of the documents?
|
//insert Each of the documents?
|
||||||
upload.forEach((u) => {
|
|
||||||
handleUpload(
|
if (bodyshop.uselocalmediaserver) {
|
||||||
{ file: u.originFileObj },
|
upload.forEach((u) => {
|
||||||
{
|
handleLocalUpload({
|
||||||
bodyshop: bodyshop,
|
ev: { file: u.originFileObj },
|
||||||
uploaded_by: currentUser.email,
|
context: {
|
||||||
jobId: values.jobid,
|
jobid: values.jobid,
|
||||||
billId: billId,
|
invoice_number: remainingValues.invoice_number,
|
||||||
tagsArray: null,
|
vendorid: remainingValues.vendorid,
|
||||||
callback: null,
|
},
|
||||||
}
|
});
|
||||||
);
|
});
|
||||||
});
|
} else {
|
||||||
|
upload.forEach((u) => {
|
||||||
|
handleUpload(
|
||||||
|
{ file: u.originFileObj },
|
||||||
|
{
|
||||||
|
bodyshop: bodyshop,
|
||||||
|
uploaded_by: currentUser.email,
|
||||||
|
jobId: values.jobid,
|
||||||
|
billId: billId,
|
||||||
|
tagsArray: null,
|
||||||
|
callback: null,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export function DocumentsLocalUploadComponent({
|
|||||||
currentUser,
|
currentUser,
|
||||||
bodyshop,
|
bodyshop,
|
||||||
job,
|
job,
|
||||||
|
vendorid,
|
||||||
|
invoice_number,
|
||||||
callbackAfterUpload,
|
callbackAfterUpload,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -45,6 +47,8 @@ export function DocumentsLocalUploadComponent({
|
|||||||
ev,
|
ev,
|
||||||
context: {
|
context: {
|
||||||
jobid: job.id,
|
jobid: job.id,
|
||||||
|
vendorid,
|
||||||
|
invoice_number,
|
||||||
callback: callbackAfterUpload,
|
callback: callbackAfterUpload,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import normalizeUrl from "normalize-url";
|
|||||||
|
|
||||||
export const handleUpload = async ({ ev, context }) => {
|
export const handleUpload = async ({ ev, context }) => {
|
||||||
const { onError, onSuccess, onProgress, file } = ev;
|
const { onError, onSuccess, onProgress, file } = ev;
|
||||||
const { jobid, callbackAfterUpload } = context;
|
const { jobid, invoice_number, vendorid, callbackAfterUpload } = context;
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
headers: { "X-Requested-With": "XMLHttpRequest" },
|
headers: { "X-Requested-With": "XMLHttpRequest" },
|
||||||
@@ -17,11 +17,19 @@ export const handleUpload = async ({ ev, context }) => {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
formData.append("jobid", jobid);
|
formData.append("jobid", jobid);
|
||||||
|
if (invoice_number) {
|
||||||
|
formData.append("invoice_number", invoice_number);
|
||||||
|
formData.append("vendorid", vendorid);
|
||||||
|
}
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
const bodyshop = store.getState().user.bodyshop;
|
const bodyshop = store.getState().user.bodyshop;
|
||||||
|
|
||||||
const imexMediaServerResponse = await cleanAxios.post(
|
const imexMediaServerResponse = await cleanAxios.post(
|
||||||
normalizeUrl(`${bodyshop.localmediaserverhttp}/jobs/upload`),
|
normalizeUrl(
|
||||||
|
`${bodyshop.localmediaserverhttp}/${
|
||||||
|
invoice_number ? "bills" : "jobs"
|
||||||
|
}/upload`
|
||||||
|
),
|
||||||
formData,
|
formData,
|
||||||
{
|
{
|
||||||
...options,
|
...options,
|
||||||
@@ -33,13 +41,14 @@ export const handleUpload = async ({ ev, context }) => {
|
|||||||
onError(imexMediaServerResponse.statusText);
|
onError(imexMediaServerResponse.statusText);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onSuccess(file);
|
onSuccess && onSuccess(file);
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
addMediaForJob({
|
addMediaForJob({
|
||||||
jobid,
|
jobid,
|
||||||
media: imexMediaServerResponse.data.map((d) => {
|
media: imexMediaServerResponse.data.map((d) => {
|
||||||
return {
|
return {
|
||||||
...d,
|
...d,
|
||||||
|
selected: false,
|
||||||
src: normalizeUrl(`${bodyshop.localmediaserverhttp}/${d.src}`),
|
src: normalizeUrl(`${bodyshop.localmediaserverhttp}/${d.src}`),
|
||||||
thumbnail: normalizeUrl(
|
thumbnail: normalizeUrl(
|
||||||
`${bodyshop.localmediaserverhttp}/${d.thumbnail}`
|
`${bodyshop.localmediaserverhttp}/${d.thumbnail}`
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FileExcelFilled, EditFilled, SyncOutlined } from "@ant-design/icons";
|
import { EditFilled, FileExcelFilled, SyncOutlined } from "@ant-design/icons";
|
||||||
import { Card, Col, Row, Space, Button } from "antd";
|
import { Button, Card, Col, Row, Space } from "antd";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import Gallery from "react-grid-gallery";
|
import Gallery from "react-grid-gallery";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|||||||
@@ -1,22 +1,35 @@
|
|||||||
import React, { useEffect } from "react";
|
|
||||||
import { SyncOutlined } from "@ant-design/icons";
|
import { SyncOutlined } from "@ant-design/icons";
|
||||||
|
import { Button, Card, Space } from "antd";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
|
import Gallery from "react-grid-gallery";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import {
|
||||||
|
getBillMedia,
|
||||||
|
getJobMedia,
|
||||||
|
toggleMediaSelected,
|
||||||
|
} from "../../redux/media/media.actions";
|
||||||
import { selectAllMedia } from "../../redux/media/media.selectors";
|
import { selectAllMedia } from "../../redux/media/media.selectors";
|
||||||
import { getJobMedia } from "../../redux/media/media.actions";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import { Button, Card, Space } from "antd";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import Gallery from "react-grid-gallery";
|
|
||||||
import DocumentsLocalUploadComponent from "../documents-local-upload/documents-local-upload.component";
|
import DocumentsLocalUploadComponent from "../documents-local-upload/documents-local-upload.component";
|
||||||
import { Link } from "react-router-dom";
|
import JobsDocumentsLocalGalleryReassign from "./jobs-documents-local-gallery.reassign.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
allMedia: selectAllMedia,
|
allMedia: selectAllMedia,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
getJobMedia: (id) => dispatch(getJobMedia(id)),
|
getJobMedia: (id) => dispatch(getJobMedia(id)),
|
||||||
|
getBillMedia: ({ jobid, invoice_number }) => {
|
||||||
|
console.log(jobid);
|
||||||
|
dispatch(getBillMedia({ jobid, invoice_number }));
|
||||||
|
},
|
||||||
|
toggleMediaSelected: ({ jobid, filename }) =>
|
||||||
|
dispatch(toggleMediaSelected({ jobid, filename })),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
@@ -24,23 +37,39 @@ export default connect(
|
|||||||
|
|
||||||
export function JobsDocumentsLocalGallery({
|
export function JobsDocumentsLocalGallery({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
|
toggleMediaSelected,
|
||||||
getJobMedia,
|
getJobMedia,
|
||||||
|
getBillMedia,
|
||||||
allMedia,
|
allMedia,
|
||||||
job,
|
job,
|
||||||
|
invoice_number,
|
||||||
|
vendorid,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (job) {
|
if (job) {
|
||||||
getJobMedia(job.id);
|
if (invoice_number) {
|
||||||
|
getBillMedia({ jobid: job.id, invoice_number });
|
||||||
|
} else {
|
||||||
|
getJobMedia(job.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [job, getJobMedia]);
|
}, [job, invoice_number, getJobMedia, getBillMedia]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
|
{JSON.stringify({ jobid: job.id, invoice_number, vendorid }, null, 4) ||
|
||||||
|
"NO JOB ID"}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
getJobMedia(job.id);
|
if (job) {
|
||||||
|
if (invoice_number) {
|
||||||
|
getBillMedia({ jobid: job.id, invoice_number });
|
||||||
|
} else {
|
||||||
|
getJobMedia(job.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SyncOutlined />
|
<SyncOutlined />
|
||||||
@@ -50,15 +79,22 @@ export function JobsDocumentsLocalGallery({
|
|||||||
>
|
>
|
||||||
<Button>{t("documents.labels.openinexplorer")}</Button>
|
<Button>{t("documents.labels.openinexplorer")}</Button>
|
||||||
</a>
|
</a>
|
||||||
|
<JobsDocumentsLocalGalleryReassign jobid={job.id} />
|
||||||
</Space>
|
</Space>
|
||||||
<Card>
|
<Card>
|
||||||
<DocumentsLocalUploadComponent job={job} />
|
<DocumentsLocalUploadComponent
|
||||||
|
job={job}
|
||||||
|
invoice_number={invoice_number}
|
||||||
|
vendorid={vendorid}
|
||||||
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
<Card title={t("jobs.labels.documents-images")}>
|
<Card title={t("jobs.labels.documents-images")}>
|
||||||
<Gallery
|
<Gallery
|
||||||
images={(allMedia && allMedia[job.id]) || []}
|
images={(allMedia && allMedia[job.id]) || []}
|
||||||
enableImageSelection={false}
|
|
||||||
backdropClosesModal={true}
|
backdropClosesModal={true}
|
||||||
|
onSelectImage={(index, image) => {
|
||||||
|
toggleMediaSelected({ jobid: job.id, filename: image.filename });
|
||||||
|
}}
|
||||||
onClickImage={(props) => {
|
onClickImage={(props) => {
|
||||||
window.open(
|
window.open(
|
||||||
props.target.src,
|
props.target.src,
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import { Button, Form, Popover, Space } from "antd";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { getJobMedia } from "../../redux/media/media.actions";
|
||||||
|
import { selectAllMedia } from "../../redux/media/media.selectors";
|
||||||
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
import cleanAxios from "../../utils/CleanAxios";
|
||||||
|
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
allMedia: selectAllMedia,
|
||||||
|
bodyshop: selectBodyshop,
|
||||||
|
});
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
getJobMedia: (id) => dispatch(getJobMedia(id)),
|
||||||
|
|
||||||
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
|
});
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(JobsDocumentsLocalGalleryReassign);
|
||||||
|
|
||||||
|
export function JobsDocumentsLocalGalleryReassign({
|
||||||
|
bodyshop,
|
||||||
|
jobid,
|
||||||
|
allMedia,
|
||||||
|
getJobMedia,
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleFinish = async ({ jobid: newJobid }) => {
|
||||||
|
setLoading(true);
|
||||||
|
const selectedDocuments = allMedia[jobid].filter((m) => m.isSelected);
|
||||||
|
|
||||||
|
await cleanAxios.post(`${bodyshop.localmediaserverhttp}/jobs/move`, {
|
||||||
|
from_jobid: jobid,
|
||||||
|
jobid: newJobid,
|
||||||
|
files: selectedDocuments.map((f) => f.filename),
|
||||||
|
});
|
||||||
|
|
||||||
|
getJobMedia(jobid);
|
||||||
|
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>
|
||||||
|
<Space>
|
||||||
|
<Button type="primary" onClick={() => form.submit()}>
|
||||||
|
{t("general.actions.submit")}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => setVisible(false)}>
|
||||||
|
{t("general.actions.cancel")}
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover content={popContent} visible={visible}>
|
||||||
|
<Button
|
||||||
|
//disabled={selectedImages.length < 1}
|
||||||
|
onClick={() => setVisible(true)}
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
|
{t("documents.actions.reassign")}
|
||||||
|
</Button>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -5,15 +5,34 @@ import JobsDocumentsComponent from "../../components/jobs-documents-gallery/jobs
|
|||||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||||
import { QUERY_TEMPORARY_DOCS } from "../../graphql/documents.queries";
|
import { QUERY_TEMPORARY_DOCS } from "../../graphql/documents.queries";
|
||||||
|
|
||||||
export default function TemporaryDocsComponent() {
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
import JobsDocumentsLocalGallery from "../../components/jobs-documents-local-gallery/jobs-documents-local-gallery.container";
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
bodyshop: selectBodyshop,
|
||||||
|
});
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
|
});
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(TemporaryDocsComponent);
|
||||||
|
|
||||||
|
export function TemporaryDocsComponent({ bodyshop }) {
|
||||||
const { loading, error, data, refetch } = useQuery(QUERY_TEMPORARY_DOCS, {
|
const { loading, error, data, refetch } = useQuery(QUERY_TEMPORARY_DOCS, {
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only",
|
||||||
nextFetchPolicy: "network-only",
|
nextFetchPolicy: "network-only",
|
||||||
|
skip: bodyshop.uselocalmediaserver,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (loading) return <LoadingSpinner />;
|
if (loading) return <LoadingSpinner />;
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
|
|
||||||
|
if (bodyshop.uselocalmediaserver) {
|
||||||
|
return <JobsDocumentsLocalGallery job={{ id: "temporary" }} />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<JobsDocumentsComponent
|
<JobsDocumentsComponent
|
||||||
data={data ? data.documents : []}
|
data={data ? data.documents : []}
|
||||||
|
|||||||
@@ -4,15 +4,31 @@ export const getJobMedia = (jobid) => ({
|
|||||||
type: MediaActionTypes.GET_MEDIA_FOR_JOB,
|
type: MediaActionTypes.GET_MEDIA_FOR_JOB,
|
||||||
payload: jobid,
|
payload: jobid,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getBillMedia = ({ jobid, invoice_number }) => {
|
||||||
|
console.log("in the action");
|
||||||
|
return {
|
||||||
|
type: MediaActionTypes.GET_MEDIA_FOR_BILL,
|
||||||
|
payload: { jobid, invoice_number },
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const setJobMedia = ({ jobid, media }) => ({
|
export const setJobMedia = ({ jobid, media }) => ({
|
||||||
type: MediaActionTypes.SET_MEDIA_FOR_JOB,
|
type: MediaActionTypes.SET_MEDIA_FOR_JOB,
|
||||||
payload: { jobid, media },
|
payload: { jobid, media },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const addMediaForJob = ({ jobid, media }) => ({
|
export const addMediaForJob = ({ jobid, media }) => ({
|
||||||
type: MediaActionTypes.ADD_MEDIA_FOR_JOB,
|
type: MediaActionTypes.ADD_MEDIA_FOR_JOB,
|
||||||
payload: { jobid, media },
|
payload: { jobid, media },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getJobMediaError = ({ error, message }) => ({
|
export const getJobMediaError = ({ error, message }) => ({
|
||||||
type: MediaActionTypes.GET_MEDIA_FOR_JOB_ERROR,
|
type: MediaActionTypes.GET_MEDIA_FOR_JOB_ERROR,
|
||||||
payload: { error, message },
|
payload: { error, message },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const toggleMediaSelected = ({ jobid, filename }) => ({
|
||||||
|
type: MediaActionTypes.TOGGLE_MEDIA_SELECTED,
|
||||||
|
payload: { jobid, filename },
|
||||||
|
});
|
||||||
|
|||||||
@@ -12,10 +12,20 @@ const mediaReducer = (state = INITIAL_STATE, action) => {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
[action.payload.jobid]: [
|
[action.payload.jobid]: [
|
||||||
...state[action.payload.jobid],
|
...(state[action.payload.jobid] ? state[action.payload.jobid] : []),
|
||||||
...(action.payload.media || []),
|
...(action.payload.media || []),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
case MediaActionTypes.TOGGLE_MEDIA_SELECTED:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
[action.payload.jobid]: state[action.payload.jobid].map((p) => {
|
||||||
|
if (p.filename === action.payload.filename) {
|
||||||
|
p.isSelected = !p.isSelected;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}),
|
||||||
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { getJobMediaError, setJobMedia } from "./media.actions";
|
|||||||
import MediaActionTypes from "./media.types";
|
import MediaActionTypes from "./media.types";
|
||||||
import cleanAxios from "../../utils/CleanAxios";
|
import cleanAxios from "../../utils/CleanAxios";
|
||||||
import normalizeUrl from "normalize-url";
|
import normalizeUrl from "normalize-url";
|
||||||
|
|
||||||
export function* onSetJobMedia() {
|
export function* onSetJobMedia() {
|
||||||
yield takeLatest(MediaActionTypes.GET_MEDIA_FOR_JOB, getJobMedia);
|
yield takeLatest(MediaActionTypes.GET_MEDIA_FOR_JOB, getJobMedia);
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ export function* getJobMedia({ payload: jobid }) {
|
|||||||
thumbnail: normalizeUrl(
|
thumbnail: normalizeUrl(
|
||||||
`${localmediaserverhttp}/${d.thumbnail}`
|
`${localmediaserverhttp}/${d.thumbnail}`
|
||||||
),
|
),
|
||||||
|
isSelected: false,
|
||||||
key: idx,
|
key: idx,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
@@ -48,7 +49,48 @@ export function* getJobMedia({ payload: jobid }) {
|
|||||||
thumbnail: normalizeUrl(
|
thumbnail: normalizeUrl(
|
||||||
`${localmediaserverhttp}/${d.thumbnail}`
|
`${localmediaserverhttp}/${d.thumbnail}`
|
||||||
),
|
),
|
||||||
|
isSelected: false,
|
||||||
|
key: idx,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
yield put(getJobMediaError(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export function* onSetBillMedia() {
|
||||||
|
yield takeLatest(MediaActionTypes.GET_MEDIA_FOR_BILL, getBillMedia);
|
||||||
|
}
|
||||||
|
export function* getBillMedia({ payload: { jobid, invoice_number } }) {
|
||||||
|
try {
|
||||||
|
const localmediaserverhttp = (yield select(
|
||||||
|
(state) => state.user.bodyshop.localmediaserverhttp
|
||||||
|
)).trim();
|
||||||
|
|
||||||
|
if (localmediaserverhttp && localmediaserverhttp !== "") {
|
||||||
|
const documentsFetch = yield cleanAxios.post(
|
||||||
|
`${localmediaserverhttp}/bills/list`,
|
||||||
|
{
|
||||||
|
jobid,
|
||||||
|
invoice_number,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
yield put(
|
||||||
|
setJobMedia({
|
||||||
|
jobid,
|
||||||
|
media: [
|
||||||
|
...documentsFetch.data.map((d, idx) => {
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
src: normalizeUrl(`${localmediaserverhttp}/${d.src}`),
|
||||||
|
thumbnail: normalizeUrl(
|
||||||
|
`${localmediaserverhttp}/${d.thumbnail}`
|
||||||
|
),
|
||||||
|
isSelected: false,
|
||||||
key: idx,
|
key: idx,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
@@ -62,5 +104,5 @@ export function* getJobMedia({ payload: jobid }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function* mediaSagas() {
|
export function* mediaSagas() {
|
||||||
yield all([call(onSetJobMedia)]);
|
yield all([call(onSetJobMedia), call(onSetBillMedia)]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ const MediaActionTypes = {
|
|||||||
GET_MEDIA_FOR_JOB: "GET_MEDIA_FOR_JOB",
|
GET_MEDIA_FOR_JOB: "GET_MEDIA_FOR_JOB",
|
||||||
GET_MEDIA_FOR_JOB_ERROR: "GET_MEDIA_FOR_JOB_ERROR",
|
GET_MEDIA_FOR_JOB_ERROR: "GET_MEDIA_FOR_JOB_ERROR",
|
||||||
ADD_MEDIA_FOR_JOB: "ADD_MEDIA_FOR_JOB",
|
ADD_MEDIA_FOR_JOB: "ADD_MEDIA_FOR_JOB",
|
||||||
|
TOGGLE_MEDIA_SELECTED: "TOGGLE_MEDIA_SELECTED",
|
||||||
POST_MEDIA_FOR_JOB: "POST_MEDIA_FOR_JOB",
|
POST_MEDIA_FOR_JOB: "POST_MEDIA_FOR_JOB",
|
||||||
POST_MEDIA_FOR_JOB_SUCCESS: "POST_MEDIA_FOR_JOB_SUCCESS",
|
POST_MEDIA_FOR_JOB_SUCCESS: "POST_MEDIA_FOR_JOB_SUCCESS",
|
||||||
POST_MEDIA_FOR_JOB_ERROR: "POST_MEDIA_FOR_JOB_ERROR",
|
POST_MEDIA_FOR_JOB_ERROR: "POST_MEDIA_FOR_JOB_ERROR",
|
||||||
|
GET_MEDIA_FOR_BILL: "GET_MEDIA_FOR_BILL",
|
||||||
};
|
};
|
||||||
export default MediaActionTypes;
|
export default MediaActionTypes;
|
||||||
|
|||||||
@@ -97,7 +97,15 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
case UserActionTypes.SET_SHOP_DETAILS:
|
case UserActionTypes.SET_SHOP_DETAILS:
|
||||||
return { ...state, bodyshop: action.payload };
|
return {
|
||||||
|
...state,
|
||||||
|
bodyshop: {
|
||||||
|
uselocalmediaserver: true,
|
||||||
|
localmediaserverhttp: "http://localhost:8000", //TODO: ENSURE THAT THIS HAS BEEN REMOVED POST TESTING.
|
||||||
|
localmediaservernetwork: "\\localhost:8000", //TODO: ENSURE THAT THIS HAS BEEN REMOVED POST TESTING.
|
||||||
|
...action.payload,
|
||||||
|
},
|
||||||
|
};
|
||||||
case UserActionTypes.SIGN_IN_FAILURE:
|
case UserActionTypes.SIGN_IN_FAILURE:
|
||||||
case UserActionTypes.SIGN_OUT_FAILURE:
|
case UserActionTypes.SIGN_OUT_FAILURE:
|
||||||
case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
|
case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
|
||||||
|
|||||||
@@ -822,6 +822,7 @@
|
|||||||
"confirmdelete": "Are you sure you want to delete these documents. This CANNOT be undone.",
|
"confirmdelete": "Are you sure you want to delete these documents. This CANNOT be undone.",
|
||||||
"doctype": "Document Type",
|
"doctype": "Document Type",
|
||||||
"newjobid": "Assign to Job",
|
"newjobid": "Assign to Job",
|
||||||
|
"openinexplorer": "Open in Explorer",
|
||||||
"reassign_limitexceeded": "Reassigning all selected documents will exceed the job storage limit for your shop. ",
|
"reassign_limitexceeded": "Reassigning all selected documents will exceed the job storage limit for your shop. ",
|
||||||
"reassign_limitexceeded_title": "Unable to reassign document(s)",
|
"reassign_limitexceeded_title": "Unable to reassign document(s)",
|
||||||
"storageexceeded": "You've exceeded your storage limit for this job. Please remove documents, or increase your storage plan.",
|
"storageexceeded": "You've exceeded your storage limit for this job. Please remove documents, or increase your storage plan.",
|
||||||
|
|||||||
@@ -822,6 +822,7 @@
|
|||||||
"confirmdelete": "",
|
"confirmdelete": "",
|
||||||
"doctype": "",
|
"doctype": "",
|
||||||
"newjobid": "",
|
"newjobid": "",
|
||||||
|
"openinexplorer": "",
|
||||||
"reassign_limitexceeded": "",
|
"reassign_limitexceeded": "",
|
||||||
"reassign_limitexceeded_title": "",
|
"reassign_limitexceeded_title": "",
|
||||||
"storageexceeded": "",
|
"storageexceeded": "",
|
||||||
|
|||||||
@@ -822,6 +822,7 @@
|
|||||||
"confirmdelete": "",
|
"confirmdelete": "",
|
||||||
"doctype": "",
|
"doctype": "",
|
||||||
"newjobid": "",
|
"newjobid": "",
|
||||||
|
"openinexplorer": "",
|
||||||
"reassign_limitexceeded": "",
|
"reassign_limitexceeded": "",
|
||||||
"reassign_limitexceeded_title": "",
|
"reassign_limitexceeded_title": "",
|
||||||
"storageexceeded": "",
|
"storageexceeded": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user