various display updates to use the custom grain name and colors
This commit is contained in:
parent
e2ad43975d
commit
be8dc1d11f
8 changed files with 64 additions and 46 deletions
|
|
@ -70,6 +70,7 @@ import Edit from "@mui/icons-material/Edit";
|
|||
import { makeStyles } from "@mui/styles";
|
||||
import ButtonGroup from "common/ButtonGroup";
|
||||
import ModeChangeDialog from "./conditioning/modeChangeDialog";
|
||||
import CustomGrainForm from "grain/CustomGrainForm";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => {
|
||||
return ({
|
||||
|
|
@ -286,6 +287,7 @@ export default function BinVisualizer(props: Props) {
|
|||
|
||||
const [openModeChange, setOpenModeChange] = useState(false)
|
||||
const [modeChangeInProgress, setModeChangeInProgress] = useState(false)
|
||||
const [newGrainSettings, setNewGrainSettings] = useState<pond.GrainSettings>()
|
||||
|
||||
useEffect(() => {
|
||||
setModeTime(moment(bin.status.lastModeChange));
|
||||
|
|
@ -327,6 +329,7 @@ export default function BinVisualizer(props: Props) {
|
|||
setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
|
||||
setGrainSubtype(bin.subtype());
|
||||
setNewBinMode(bin.settings.mode);
|
||||
setNewGrainSettings(bin.customGrain());
|
||||
}
|
||||
if (bin.settings) {
|
||||
let t = bin.settings.outdoorTemp;
|
||||
|
|
@ -515,18 +518,13 @@ export default function BinVisualizer(props: Props) {
|
|||
const capacity = bin.settings.specs?.bushelCapacity ?? 0;
|
||||
const grainBushels = bin.bushels();
|
||||
const isEmpty = bin.settings.inventory?.empty === true || !grainBushels || grainBushels <= 0;
|
||||
const grainType = bin.settings.inventory?.grainType;
|
||||
const grainTypeName = isEmpty || !grainType ? "" : GrainDescriber(grainType).name;
|
||||
const customTypeName = bin.settings.inventory?.customTypeName;
|
||||
const grainSubtype = bin.settings.inventory?.grainSubtype;
|
||||
return (
|
||||
<Box>
|
||||
{/* grain display */}
|
||||
<Box display="flex" justifyContent="space-between">
|
||||
<Typography variant="subtitle2" color="textPrimary" style={{ fontWeight: 800 }}>
|
||||
{bin.storage() === pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN
|
||||
? grainTypeName
|
||||
: customTypeName}
|
||||
{isEmpty ? "" : bin.grainName()}
|
||||
{grainSubtype !== "" ? " - " + grainSubtype : ""}
|
||||
</Typography>
|
||||
<Box
|
||||
|
|
@ -768,6 +766,7 @@ export default function BinVisualizer(props: Props) {
|
|||
setGrainType(bin.settings.inventory.grainType);
|
||||
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
|
||||
setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
|
||||
setNewGrainSettings(bin.customGrain())
|
||||
setGrainSubtype(bin.subtype());
|
||||
}
|
||||
setGrainChangeDialog(false);
|
||||
|
|
@ -799,11 +798,13 @@ export default function BinVisualizer(props: Props) {
|
|||
setCustomTypeName("");
|
||||
setGrainOption(ToGrainOption(pond.Grain.GRAIN_NONE));
|
||||
if (checked) {
|
||||
setStorageType(pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN);
|
||||
setGrainType(pond.Grain.GRAIN_CUSTOM);
|
||||
} else {
|
||||
setStorageType(pond.BinStorage.BIN_STORAGE_UNSUPPORTED_GRAIN);
|
||||
setGrainType(pond.Grain.GRAIN_CUSTOM);
|
||||
setNewGrainSettings(bin.customGrain())
|
||||
} else {
|
||||
setStorageType(pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN);
|
||||
setGrainType(pond.Grain.GRAIN_NONE);
|
||||
setNewGrainSettings(undefined)
|
||||
}
|
||||
}}
|
||||
name="storage"
|
||||
|
|
@ -834,7 +835,7 @@ export default function BinVisualizer(props: Props) {
|
|||
)}
|
||||
{isCustomInventory ? (
|
||||
<React.Fragment>
|
||||
<TextField
|
||||
{/* <TextField
|
||||
label="Type"
|
||||
value={customTypeName}
|
||||
type="text"
|
||||
|
|
@ -859,7 +860,8 @@ export default function BinVisualizer(props: Props) {
|
|||
variant="outlined"
|
||||
className={classes.bottomSpacing}
|
||||
/>
|
||||
)}
|
||||
)} */}
|
||||
<CustomGrainForm initialGrain={bin.customGrain()} onGrainSettingsChange={settings => {setNewGrainSettings(settings)}}/>
|
||||
</React.Fragment>
|
||||
) : (
|
||||
<TextField
|
||||
|
|
@ -1975,6 +1977,7 @@ export default function BinVisualizer(props: Props) {
|
|||
? 0
|
||||
: parseFloat(bushPerTonne);
|
||||
b.settings.inventory.grainSubtype = grainSubtype;
|
||||
b.settings.inventory.customGrain = newGrainSettings
|
||||
}
|
||||
|
||||
if (b.settings.outdoorTemp !== undefined) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue