@@ -30,15 +30,24 @@ import {
3030} from '../states/SettingsStates' ;
3131import { ProjectCodeHoverCard , TableHoverCard } from './TableHoverCard' ;
3232
33- // Render a Part instance within a table
34- export function PartColumn ( {
33+ export type PartColumnProps = TableColumnProps & {
34+ part ?: string ;
35+ full_name ?: boolean ;
36+ } ;
37+
38+ // Extract rendering function for Part column
39+ export function RenderPartColumn ( {
3540 part,
3641 full_name
3742} : {
3843 part : any ;
3944 full_name ?: boolean ;
4045} ) {
41- return part ? (
46+ if ( ! part ) {
47+ return < Skeleton /> ;
48+ }
49+
50+ return (
4251 < Group justify = 'space-between' wrap = 'nowrap' >
4352 < Thumbnail
4453 src = { part ?. thumbnail ?? part ?. image }
@@ -63,11 +72,32 @@ export function PartColumn({
6372 ) }
6473 </ Group >
6574 </ Group >
66- ) : (
67- < Skeleton />
6875 ) ;
6976}
7077
78+ // Render a Part instance within a table
79+ export function PartColumn ( props : PartColumnProps ) : TableColumn {
80+ return {
81+ accessor : 'part' ,
82+ title : t `Part` ,
83+ sortable : true ,
84+ switchable : false ,
85+ minWidth : '175px' ,
86+ render : ( record : any ) => {
87+ const part =
88+ props . part === ''
89+ ? record
90+ : resolveItem ( record , props . part ?? props . accessor ?? 'part_detail' ) ;
91+
92+ return RenderPartColumn ( {
93+ part : part ,
94+ full_name : props . full_name ?? false
95+ } ) ;
96+ } ,
97+ ...props
98+ } ;
99+ }
100+
71101export function CompanyColumn ( {
72102 company
73103} : {
@@ -146,6 +176,7 @@ export function LocationColumn(props: TableColumnProps): TableColumn {
146176 title : t `Location` ,
147177 sortable : true ,
148178 ordering : 'location' ,
179+ minWidth : '150px' ,
149180 ...props
150181 } ) ;
151182 } else {
@@ -154,6 +185,7 @@ export function LocationColumn(props: TableColumnProps): TableColumn {
154185 title : t `Location` ,
155186 sortable : true ,
156187 ordering : 'location' ,
188+ minWidth : '125px' ,
157189 ...props
158190 } ) ;
159191 }
@@ -192,6 +224,7 @@ export function CategoryColumn(props: TableColumnProps): TableColumn {
192224 title : t `Category` ,
193225 sortable : true ,
194226 ordering : 'category' ,
227+ minWidth : '150px' ,
195228 ...props
196229 } ) ;
197230 } else {
@@ -200,6 +233,7 @@ export function CategoryColumn(props: TableColumnProps): TableColumn {
200233 title : t `Category` ,
201234 sortable : true ,
202235 ordering : 'category' ,
236+ minWidth : '125px' ,
203237 ...props
204238 } ) ;
205239 }
@@ -209,6 +243,7 @@ export function BooleanColumn(props: TableColumn): TableColumn {
209243 return {
210244 sortable : true ,
211245 switchable : true ,
246+ minWidth : '75px' ,
212247 render : ( record : any ) => (
213248 < Center >
214249 < YesNoButton value = { resolveItem ( record , props . accessor ?? '' ) } />
@@ -234,7 +269,7 @@ export function DescriptionColumn(props: TableColumnProps): TableColumn {
234269 title : t `Description` ,
235270 sortable : false ,
236271 switchable : true ,
237- width : 300 ,
272+ minWidth : '200px' ,
238273 ...props
239274 } ;
240275}
@@ -291,17 +326,19 @@ export function NoteColumn(props: TableColumnProps): TableColumn {
291326 } ;
292327}
293328
294- export function LineItemsProgressColumn ( ) : TableColumn {
329+ export function LineItemsProgressColumn ( props : TableColumnProps ) : TableColumn {
295330 return {
296331 accessor : 'line_items' ,
297332 sortable : true ,
333+ minWidth : 125 ,
298334 render : ( record : any ) => (
299335 < ProgressBar
300336 progressLabel = { true }
301337 value = { record . completed_lines }
302338 maximum = { record . line_items }
303339 />
304- )
340+ ) ,
341+ ...props
305342 } ;
306343}
307344
@@ -326,31 +363,20 @@ export function ProjectCodeColumn(props: TableColumnProps): TableColumn {
326363 } ;
327364}
328365
329- export function StatusColumn ( {
330- model,
331- sortable,
332- switchable,
333- ordering,
334- accessor,
335- title,
336- hidden
337- } : {
366+ export type StatusColumnProps = TableColumnProps & {
338367 model : ModelType ;
339- sortable ?: boolean ;
340- switchable ?: boolean ;
341- accessor ?: string ;
342- ordering ?: string ;
343- hidden ?: boolean ;
344- title ?: string ;
345- } ) {
368+ } ;
369+
370+ export function StatusColumn ( props : StatusColumnProps ) : TableColumn {
371+ const accessor : string = props . accessor ?? 'status' ;
372+
346373 return {
347- accessor : accessor ?? 'status' ,
348- sortable : sortable ?? true ,
349- switchable : switchable ?? true ,
350- ordering : ordering ,
351- title : title ,
352- hidden : hidden ,
353- render : TableStatusRenderer ( model , accessor ?? 'status_custom_key' )
374+ accessor : 'status' ,
375+ sortable : true ,
376+ switchable : true ,
377+ minWidth : '50px' ,
378+ render : TableStatusRenderer ( props . model , accessor ?? 'status_custom_key' ) ,
379+ ...props
354380 } ;
355381}
356382
0 commit comments