mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 16:28:51 -06:00
web: ProfiledUnits: Add data change and rename functionality
This commit is contained in:
@@ -4,10 +4,15 @@
|
||||
* Released under the modified BSD license. See COPYING.md for more details.
|
||||
*/
|
||||
|
||||
import { UnitCommitmentScenario } from "../fixtures";
|
||||
import { Generators, UnitCommitmentScenario } from "../fixtures";
|
||||
import { generateTimeslots } from "../../components/Common/Forms/DataTable";
|
||||
import { ValidationError } from "../Validation/validate";
|
||||
import { generateUniqueName, renameItemInObject } from "./commonOps";
|
||||
import {
|
||||
changeData,
|
||||
generateUniqueName,
|
||||
renameItemInObject,
|
||||
} from "./commonOps";
|
||||
import { ProfiledUnitsColumnSpec } from "../../components/CaseBuilder/ProfiledUnits/ProfiledUnits";
|
||||
|
||||
export const createProfiledUnit = (
|
||||
scenario: UnitCommitmentScenario,
|
||||
@@ -36,6 +41,32 @@ export const createProfiledUnit = (
|
||||
];
|
||||
};
|
||||
|
||||
export const changeProfiledUnitData = (
|
||||
generator: string,
|
||||
field: string,
|
||||
newValueStr: string,
|
||||
scenario: UnitCommitmentScenario,
|
||||
): [UnitCommitmentScenario, ValidationError | null] => {
|
||||
const [newGen, err] = changeData(
|
||||
field,
|
||||
newValueStr,
|
||||
scenario.Generators[generator]!,
|
||||
ProfiledUnitsColumnSpec,
|
||||
scenario,
|
||||
);
|
||||
if (err) return [scenario, err];
|
||||
return [
|
||||
{
|
||||
...scenario,
|
||||
Generators: {
|
||||
...scenario.Generators,
|
||||
[generator]: newGen,
|
||||
} as Generators,
|
||||
},
|
||||
null,
|
||||
];
|
||||
};
|
||||
|
||||
export const deleteGenerator = (
|
||||
name: string,
|
||||
scenario: UnitCommitmentScenario,
|
||||
|
||||
Reference in New Issue
Block a user