feature/IO-3255-simplified-parts-management - Favor isPartsEntry over isPartsManagementOnly

This commit is contained in:
Dave
2025-08-13 16:52:08 -04:00
parent 766b4b950a
commit 67a8c13bad
7 changed files with 51 additions and 56 deletions

View File

@@ -17,7 +17,7 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { DELETE_JOB_LINE_BY_PK } from "../../graphql/jobs-lines.queries";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { selectIsPartsEntry, selectJobReadOnly } from "../../redux/application/application.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectTechnician } from "../../redux/tech/tech.selectors";
import { onlyUnique } from "../../utils/arrayHelper";
@@ -32,7 +32,7 @@ import JobLinesBillRefernece from "../job-lines-bill-reference/job-lines-bill-re
import { useSplitTreatments } from "@splitsoftware/splitio-react";
import _ from "lodash";
import { FaTasks } from "react-icons/fa";
import { selectBodyshop, selectPartsManagementOnly } from "../../redux/user/user.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import dayjs from "../../utils/day";
import InstanceRenderManager from "../../utils/instanceRenderMgr";
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
@@ -51,7 +51,7 @@ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
jobRO: selectJobReadOnly,
technician: selectTechnician,
partsManagementOnly: selectPartsManagementOnly
isPartsEntry: selectIsPartsEntry
});
const mapDispatchToProps = (dispatch) => ({
@@ -78,10 +78,8 @@ export function JobLinesComponent({
setBillEnterContext,
setTaskUpsertContext,
billsQuery,
handleBillOnRowClick,
handlePartsOrderOnRowClick,
handlePartsDispatchOnRowClick,
partsManagementOnly
isPartsEntry
}) {
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
const {
@@ -96,7 +94,7 @@ export function JobLinesComponent({
const [state, setState] = useState({
sortedInfo: {},
filteredInfo: {
...(partsManagementOnly
...(isPartsEntry
? {
part_type: ["PAN", "PAC", "PAR", "PAL", "PAA", "PAM", "PAP", "PAS", "PASL", "PAG"]
}
@@ -229,7 +227,7 @@ export function JobLinesComponent({
sorter: (a, b) => a.part_qty - b.part_qty,
sortOrder: state.sortedInfo.columnKey === "part_qty" && state.sortedInfo.order
},
...(!partsManagementOnly
...(!isPartsEntry
? [
{
title: t("joblines.fields.mod_lbr_ty"),
@@ -281,7 +279,7 @@ export function JobLinesComponent({
key: "location",
render: (text, record) => <JobLineLocationPopup jobline={record} disabled={jobRO} />
},
...(!partsManagementOnly && HasFeatureAccess({ featureName: "bills", bodyshop })
...(!isPartsEntry && HasFeatureAccess({ featureName: "bills", bodyshop })
? [
{
title: t("joblines.labels.billref"),
@@ -315,7 +313,7 @@ export function JobLinesComponent({
onFilter: (value, record) => value.includes(record.status),
render: (text, record) => <JobLineStatusPopup jobline={record} disabled={jobRO} />
},
...!partsManagementOnly
...(!isPartsEntry
? [
{
title: t("general.labels.actions"),
@@ -382,7 +380,7 @@ export function JobLinesComponent({
)
}
]
: []
: [])
];
const handleTableChange = (pagination, filters, sorter) => {
@@ -555,7 +553,7 @@ export function JobLinesComponent({
<Dropdown menu={markMenu} trigger={["click"]}>
<Button id="repair-data-mark-button">{t("jobs.actions.mark")}</Button>
</Dropdown>
{!partsManagementOnly && (
{!isPartsEntry && (
<Button
disabled={jobRO || technician}
onClick={() => {
@@ -592,12 +590,12 @@ export function JobLinesComponent({
}}
expandable={{
expandedRowRender: (record) =>
partsManagementOnly ? (
isPartsEntry ? (
<JobLinesExpanderSimple jobline={record} jobid={job.id} />
) : (
<JobLinesExpander jobline={record} jobid={job.id} />
),
rowExpandable: (record) => true,
rowExpandable: () => true,
//expandRowByClick: true,
expandIcon: ({ expanded, onExpand, record }) =>
expanded ? (
@@ -606,9 +604,9 @@ export function JobLinesComponent({
<PlusCircleTwoTone onClick={(e) => onExpand(record, e)} />
)
}}
onRow={(record, rowIndex) => {
onRow={(record) => {
return {
onDoubleClick: (event) => {
onDoubleClick: () => {
const notMatchingLines = selectedLines.filter((i) => i.id !== record.id);
notMatchingLines.length !== selectedLines.length
? setSelectedLines(notMatchingLines)
@@ -618,10 +616,10 @@ export function JobLinesComponent({
}}
rowSelection={{
selectedRowKeys: selectedLines.map((item) => item && item.id),
onSelectAll: (selected, selectedRows, changeRows) => {
onSelectAll: (selected, selectedRows) => {
setSelectedLines(selectedRows);
},
onSelect: (record, selected, selectedRows, nativeEvent) => {
onSelect: (record, selected) => {
if (selected) {
setSelectedLines((selectedLines) => _.uniqBy([...selectedLines, record], "id"));
} else {