From 90600cdff4677a54f4a54d9fa52d1523709a281e Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Fri, 13 May 2022 09:34:19 -0700
Subject: [PATCH] Local media server bugfixes.
---
...jobs-documents-local-gallery.container.jsx | 2 +
...ents-local-gallery.selectall.component.jsx | 53 +++++++++++++++++++
.../tech-lookup-jobs-drawer.component.jsx | 20 +++++--
client/src/redux/media/media.actions.js | 10 ++++
client/src/redux/media/media.reducer.js | 17 ++++++
client/src/redux/media/media.types.js | 5 +-
6 files changed, 101 insertions(+), 6 deletions(-)
create mode 100644 client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.selectall.component.jsx
diff --git a/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx b/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx
index cc7cbe31f..92ba94f17 100644
--- a/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx
+++ b/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx
@@ -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({
+
({
+ 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 (
+
+
+
+
+
+ );
+}
diff --git a/client/src/components/tech-lookup-jobs-drawer/tech-lookup-jobs-drawer.component.jsx b/client/src/components/tech-lookup-jobs-drawer/tech-lookup-jobs-drawer.component.jsx
index b668092a2..2d28099f0 100644
--- a/client/src/components/tech-lookup-jobs-drawer/tech-lookup-jobs-drawer.component.jsx
+++ b/client/src/components/tech-lookup-jobs-drawer/tech-lookup-jobs-drawer.component.jsx
@@ -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 }) {
/>
-
+ {bodyshop.uselocalmediaserver ? (
+
+ ) : (
+
+ )}
@@ -121,4 +132,7 @@ export function JobDetailCards({ setPrintCenterContext }) {
);
}
-export default connect(null, mapDispatchToProps)(JobDetailCards);
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(TechLookupJobsDrawer);
diff --git a/client/src/redux/media/media.actions.js b/client/src/redux/media/media.actions.js
index 09e660a9a..1ff5e943c 100644
--- a/client/src/redux/media/media.actions.js
+++ b/client/src/redux/media/media.actions.js
@@ -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 },
+});
diff --git a/client/src/redux/media/media.reducer.js b/client/src/redux/media/media.reducer.js
index 47c52a0f9..a220bcc93 100644
--- a/client/src/redux/media/media.reducer.js
+++ b/client/src/redux/media/media.reducer.js
@@ -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;
}
diff --git a/client/src/redux/media/media.types.js b/client/src/redux/media/media.types.js
index 91eaf3d1c..33b8e0cbb 100644
--- a/client/src/redux/media/media.types.js
+++ b/client/src/redux/media/media.types.js
@@ -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;