All files / src/pages/flowsheet-page/flowsheet/PropertiesSidebar/PropertyPanel propertyState.ts

100% Statements 7/7
50% Branches 1/2
100% Functions 0/0
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 4376x                             21373x       21373x       21241x             15x   16x               78x    
const DEFAULT_INCOMPLETE_REASON = "Missing required inputs.";
 
type PropertyState = {
  can_edit?: boolean;
  can_edit_formula?: boolean;
  can_delete?: boolean;
  formula_incomplete?: boolean;
  formula_incomplete_reason?: string;
};
 
type FormulaValueState = {
  formula?: string | null;
};
 
export function canEditProperty(property: PropertyState): boolean {
  return property.can_edit !== false;
}
 
export function canEditPropertyFormula(property: PropertyState): boolean {
  return property.can_edit_formula !== false;
}
 
export function canDeleteProperty(property: PropertyState): boolean {
  return property.can_delete !== false;
}
 
export function objectiveDisabledReason(
  property: PropertyState,
): string | null {
  if (!property.formula_incomplete) {
    return null;
  }
  return (
    property.formula_incomplete_reason?.trim() || DEFAULT_INCOMPLETE_REASON
  );
}
 
export function isFormulaBackedValue(
  value?: FormulaValueState | null,
): boolean {
  return Boolean(value?.formula);
}