Local media server bugfixes.

This commit is contained in:
Patrick Fic
2022-05-13 09:34:19 -07:00
parent cdcfea988f
commit 90600cdff4
6 changed files with 101 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
import { CreateExplorerLinkForJob } from "../../utils/localmedia";
import DocumentsLocalUploadComponent from "../documents-local-upload/documents-local-upload.component";
import JobsDocumentsLocalGalleryReassign from "./jobs-documents-local-gallery.reassign.component";
import JobsDocumentsLocalGallerySelectAllComponent from "./jobs-documents-local-gallery.selectall.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -76,6 +77,7 @@ export function JobsDocumentsLocalGallery({
<Button>{t("documents.labels.openinexplorer")}</Button>
</a>
<JobsDocumentsLocalGalleryReassign jobid={job.id} />
<JobsDocumentsLocalGallerySelectAllComponent jobid={job.id} />
</Space>
<Card>
<DocumentsLocalUploadComponent

View File

@@ -0,0 +1,53 @@
import { Button, Space } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import {
selectAllmediaForJob,
deselectAllMediaForJob,
} from "../../redux/media/media.actions";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
});
const mapDispatchToProps = (dispatch) => ({
selectAllmediaForJob: (jobid) => dispatch(selectAllmediaForJob(jobid)),
deselectAllmediaForJob: (jobid) => dispatch(deselectAllMediaForJob(jobid)),
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(JobsDocumentsLocalGallerySelectAllComponent);
export function JobsDocumentsLocalGallerySelectAllComponent({
jobid,
selectAllmediaForJob,
deselectAllmediaForJob,
}) {
const { t } = useTranslation();
// onSelectImage={(index, image) => {
// toggleMediaSelected({ jobid: job.id, filename: image.filename });
// }}
const handleSelectAll = () => {
selectAllmediaForJob({ jobid });
};
const handleDeselectAll = () => {
deselectAllmediaForJob({ jobid });
};
return (
<Space wrap>
<Button onClick={handleSelectAll}>
{t("general.actions.selectall")}
</Button>
<Button onClick={handleDeselectAll}>
{t("general.actions.deselectall")}
</Button>
</Space>
);
}

View File

@@ -6,15 +6,20 @@ import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { useHistory, useLocation } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { GET_JOB_BY_PK } from "../../graphql/jobs.queries";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import AlertComponent from "../alert/alert.component";
import JobLinesContainer from "../job-detail-lines/job-lines.container";
import JobsDetailHeader from "../jobs-detail-header/jobs-detail-header.component";
import JobsDocumentsGalleryContainer from "../jobs-documents-gallery/jobs-documents-gallery.container";
import JobsDocumentsLocalGallery from "../jobs-documents-local-gallery/jobs-documents-local-gallery.container";
import JobNotesContainer from "../jobs-notes/jobs-notes.container";
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop });
const mapDispatchToProps = (dispatch) => ({
setPrintCenterContext: (context) =>
dispatch(setModalContext({ context: context, modal: "printCenter" })),
@@ -29,7 +34,7 @@ const mapDispatchToProps = (dispatch) => ({
// },
// };
export function JobDetailCards({ setPrintCenterContext }) {
export function TechLookupJobsDrawer({ bodyshop, setPrintCenterContext }) {
const selectedBreakpoint = Object.entries(Grid.useBreakpoint())
.filter((screen) => !!screen[1])
.slice(-1)[0];
@@ -110,7 +115,13 @@ export function JobDetailCards({ setPrintCenterContext }) {
/>
</Tabs.TabPane>
<Tabs.TabPane key="documents" tab={t("jobs.labels.documents")}>
<JobsDocumentsGalleryContainer jobId={searchParams.selected} />
{bodyshop.uselocalmediaserver ? (
<JobsDocumentsLocalGallery
job={data ? data.jobs_by_pk : null}
/>
) : (
<JobsDocumentsGalleryContainer jobId={searchParams.selected} />
)}
</Tabs.TabPane>
<Tabs.TabPane key="notes" tab={t("jobs.labels.notes")}>
<JobNotesContainer jobId={searchParams.selected} />
@@ -121,4 +132,7 @@ export function JobDetailCards({ setPrintCenterContext }) {
</Drawer>
);
}
export default connect(null, mapDispatchToProps)(JobDetailCards);
export default connect(
mapStateToProps,
mapDispatchToProps
)(TechLookupJobsDrawer);

View File

@@ -32,3 +32,13 @@ export const toggleMediaSelected = ({ jobid, filename }) => ({
type: MediaActionTypes.TOGGLE_MEDIA_SELECTED,
payload: { jobid, filename },
});
export const deselectAllMediaForJob = ({ jobid }) => ({
type: MediaActionTypes.DESELECT_ALL_MEDIA_FOR_JOB,
payload: { jobid },
});
export const selectAllmediaForJob = ({ jobid }) => ({
type: MediaActionTypes.SELECT_ALL_MEDIA_FOR_JOB,
payload: { jobid },
});

View File

@@ -26,6 +26,23 @@ const mediaReducer = (state = INITIAL_STATE, action) => {
return p;
}),
};
case MediaActionTypes.SELECT_ALL_MEDIA_FOR_JOB:
return {
...state,
[action.payload.jobid]: state[action.payload.jobid].map((p) => {
p.isSelected = true;
return p;
}),
};
case MediaActionTypes.DESELECT_ALL_MEDIA_FOR_JOB:
return {
...state,
[action.payload.jobid]: state[action.payload.jobid].map((p) => {
p.isSelected = false;
return p;
}),
};
default:
return state;
}

View File

@@ -4,9 +4,8 @@ const MediaActionTypes = {
GET_MEDIA_FOR_JOB_ERROR: "GET_MEDIA_FOR_JOB_ERROR",
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_SUCCESS: "POST_MEDIA_FOR_JOB_SUCCESS",
POST_MEDIA_FOR_JOB_ERROR: "POST_MEDIA_FOR_JOB_ERROR",
GET_MEDIA_FOR_BILL: "GET_MEDIA_FOR_BILL",
SELECT_ALL_MEDIA_FOR_JOB: "SELECT_ALL_MEDIA_FOR_JOB",
DESELECT_ALL_MEDIA_FOR_JOB: "DESELECT_ALL_MEDIA_FOR_JOB",
};
export default MediaActionTypes;