Rewrite SpecifiedValue as a read-only structure
This commit is contained in:
parent
8b4a72c60c
commit
84bfdefccb
4 changed files with 41 additions and 44 deletions
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
Regulator,
|
||||
RegulatorKey
|
||||
},
|
||||
specified::{SpecifiedValue, SpecifiedValue::{Absent, Present}}
|
||||
specified::SpecifiedValue
|
||||
};
|
||||
|
||||
// an editable view of a regulator
|
||||
|
|
@ -22,7 +22,7 @@ use crate::{
|
|||
fn RegulatorInput(regulator: Regulator) -> View {
|
||||
let valid = create_signal(true);
|
||||
let value = create_signal(
|
||||
regulator.set_point.with_untracked(|set_pt| set_pt.spec())
|
||||
regulator.set_point.with_untracked(|set_pt| set_pt.spec.clone())
|
||||
);
|
||||
|
||||
// this closure resets the input value to the regulator's set point
|
||||
|
|
@ -30,7 +30,7 @@ fn RegulatorInput(regulator: Regulator) -> View {
|
|||
let reset_value = move || {
|
||||
batch(|| {
|
||||
valid.set(true);
|
||||
value.set(regulator.set_point.with(|set_pt| set_pt.spec()));
|
||||
value.set(regulator.set_point.with(|set_pt| set_pt.spec.clone()));
|
||||
})
|
||||
};
|
||||
|
||||
|
|
@ -44,9 +44,10 @@ fn RegulatorInput(regulator: Regulator) -> View {
|
|||
class=move || {
|
||||
if valid.get() {
|
||||
regulator.set_point.with(|set_pt| {
|
||||
match set_pt {
|
||||
Absent => "regulator-input",
|
||||
Present { .. } => "regulator-input constraint"
|
||||
if set_pt.is_present() {
|
||||
"regulator-input constraint"
|
||||
} else {
|
||||
"regulator-input"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue