- Updated App.css to refine styling for object display tags and introduced a border for better visual distinction. - Enhanced NewDocumentJob component by adding a default quantity value for improved user experience. - Introduced PrinterQueue component to manage and display printer job queues, enhancing the ControlPrinter functionality. - Improved MissingPlaceholder component with additional props for customizable border and padding options. - Adjusted ObjectDisplay and ObjectList components for better layout and interaction, including cursor changes for clickable elements. - Updated ThemeContext to manage new color variables for consistent theming across components.
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
import PropTypes from 'prop-types'
|
|
import ObjectDisplay from './ObjectDisplay'
|
|
import { Steps } from 'antd'
|
|
import MissingPlaceholder from './MissingPlaceholder'
|
|
|
|
const getId = (item) => {
|
|
if (!item) return null
|
|
if (typeof item === 'string') return item
|
|
if (typeof item._id === 'string') return item._id
|
|
if (typeof item._id === 'object' && item._id?._id) return item._id._id
|
|
return null
|
|
}
|
|
|
|
const toObject = (item) => {
|
|
if (!item) return null
|
|
if (typeof item === 'string') return { _id: item }
|
|
return item
|
|
}
|
|
|
|
const PrinterQueue = ({ queue, currentSubJob }) => {
|
|
const queueItems = Array.isArray(queue)
|
|
? queue.map(toObject).filter(Boolean)
|
|
: []
|
|
const current = toObject(currentSubJob)
|
|
const currentId = getId(current)
|
|
|
|
const items = []
|
|
if (current && !queueItems.some((item) => getId(item) === currentId)) {
|
|
items.push(current)
|
|
}
|
|
items.push(...queueItems)
|
|
|
|
if (items.length === 0) {
|
|
return (
|
|
<MissingPlaceholder
|
|
message='No sub jobs in queue.'
|
|
hasBackground={false}
|
|
hasBorder={false}
|
|
padding={0}
|
|
/>
|
|
)
|
|
}
|
|
|
|
const currentIndex = currentId
|
|
? items.findIndex((item) => getId(item) === currentId)
|
|
: -1
|
|
|
|
return (
|
|
<Steps
|
|
current={currentIndex}
|
|
direction='vertical'
|
|
size='small'
|
|
items={items.map((item) => ({
|
|
title: <ObjectDisplay object={item} objectType='subJob' showHyperlink />
|
|
}))}
|
|
/>
|
|
)
|
|
}
|
|
|
|
PrinterQueue.propTypes = {
|
|
queue: PropTypes.array,
|
|
currentSubJob: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
|
|
}
|
|
|
|
export default PrinterQueue
|