Cleaned up the L&F; Added table sorting; Cleaned up the table styling.
This commit is contained in:
@@ -95,7 +95,7 @@ const AddAssets = ({assetTypes}) => {
|
||||
</div>
|
||||
<div style={{marginLeft: '1rem', display: 'flex', flexDirection: 'column'}}>
|
||||
<div style={{display: 'flex', flexDirection: 'row'}}>
|
||||
<TextField style={cssEditorField} variant="standard" label="Asset ID" value={assetId} onChange={(e) => {setAssetId(e.target.value)}}/>
|
||||
<TextField style={cssEditorField} variant="standard" label="Asset ID" value={assetId} onChange={(e) => {setAssetId(e.target.value.toUpperCase())}}/>
|
||||
<TextField style={cssEditorField} variant="standard" label="Serial" value={serial} onChange={(e) => {setSerial(e.target.value)}}/>
|
||||
</div>
|
||||
<div style={{display: 'flex', flexDirection: 'row'}}>
|
||||
|
||||
@@ -105,18 +105,45 @@ export default () => {
|
||||
{
|
||||
name: "Asset ID",
|
||||
value: (row) => row.assetId,
|
||||
descendingComparator: (a, b) => {
|
||||
if(a.assetId === b.assetId) return 0
|
||||
else if(!a.assetId) return -1
|
||||
else if(!b.assetId) return 1
|
||||
else if(a.assetId.length < b.assetId.length) return 1
|
||||
else if(a.assetId.length > b.assetId.length) return -1
|
||||
else if(b.assetId < a.assetId) return -1
|
||||
else return 1
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Serial",
|
||||
value: (row) => row.serial,
|
||||
descendingComparator: (a, b) => {
|
||||
if(a.serial === b.serial) return 0
|
||||
else if(!a.serial) return -1
|
||||
else if(!b.serial) return 1
|
||||
else if(a.serial.length < b.serial.length) return 1
|
||||
else if(a.serial.length > b.serial.length) return -1
|
||||
else if(b.serial < a.serial) return -1
|
||||
else return 1
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Condition",
|
||||
value: (row) => row.condition,
|
||||
descendingComparator: (a, b) => {
|
||||
if(b.condition === a.condition) return 0 //Most common case
|
||||
// Find the first matching condition in order.
|
||||
for(let condition of conditions) {
|
||||
if(b.condition === condition) return -1
|
||||
else if(a.condition === condition) return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "AssetType",
|
||||
value: (row) => row.assetType.name,
|
||||
value: (row) => row.assetType ? row.assetType.name : "",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user