diff --git a/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.styles.ts b/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.styles.ts index 5c85e220b0..8326f81c8b 100644 --- a/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.styles.ts +++ b/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.styles.ts @@ -45,6 +45,7 @@ export interface ICohortEditorStyles { cohortEditor: IStyle; saveAndDeleteDiv: IStyle; clearFilter: IStyle; + invalidValueError: IStyle; } export const cohortEditorStyles: () => IProcessedStyleSet = @@ -198,6 +199,11 @@ export const cohortEditorStyles: () => IProcessedStyleSet = textOverflow: "ellipsis", whiteSpace: "nowrap" }, + invalidValueError: { + color: theme.semanticColors.severeWarningIcon, + fontSize: "12px", + marginTop: "4px" + }, leftHalf: { height: "344px", marginLeft: "40px", diff --git a/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.tsx b/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.tsx index cd11cb125f..c8100e7a4d 100644 --- a/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.tsx +++ b/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditor.tsx @@ -57,6 +57,8 @@ export interface ICohortEditorState { selectedFilterCategory?: string; showConfirmation: boolean; showEmptyCohortError: boolean; + showInvalidMinMaxValueError: boolean; + showInvalidValueError: boolean; } export class CohortEditor extends React.PureComponent< @@ -97,7 +99,9 @@ export class CohortEditor extends React.PureComponent< openedFilter: undefined, selectedFilterCategory: undefined, showConfirmation: false, - showEmptyCohortError: false + showEmptyCohortError: false, + showInvalidMinMaxValueError: false, + showInvalidValueError: false }; this._isInitialized = true; } @@ -156,6 +160,10 @@ export class CohortEditor extends React.PureComponent< setComparison={this.setComparison} setNumericValue={this.setNumericValue} setSelectedProperty={this.setSelectedProperty} + showInvalidValueError={this.state.showInvalidValueError} + showInvalidMinMaxValueError={ + this.state.showInvalidMinMaxValueError + } filterIndex={this.state.filterIndex} /> )} @@ -450,21 +458,37 @@ export class CohortEditor extends React.PureComponent< numberVal > max || numberVal < min ) { + this.setState({ + showInvalidMinMaxValueError: false, + showInvalidValueError: true + }); return this.state.openedFilter.arg[index].toString(); } + this.setState({ showInvalidValueError: false }); openArg[index] = numberVal; } else { const prevVal = openArg[index]; const newVal = prevVal + delta; if (newVal > max || newVal < min) { + this.setState({ + showInvalidMinMaxValueError: false, + showInvalidValueError: true + }); return prevVal.toString(); } + this.setState({ showInvalidValueError: false }); openArg[index] = newVal; } // in the range validation if (openArg[1] <= openArg[0]) { openArg[1] = max; + this.setState({ + showInvalidMinMaxValueError: true, + showInvalidValueError: false + }); + } else { + this.setState({ showInvalidMinMaxValueError: false }); } this.setState({ diff --git a/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditorFilter.tsx b/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditorFilter.tsx index 56f9c85e05..d1328779c7 100644 --- a/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditorFilter.tsx +++ b/libs/core-ui/src/lib/Cohort/ManualCohortManagement/CohortEditorFilter.tsx @@ -21,11 +21,15 @@ import { FilterMethods, IFilter } from "../../Interfaces/IFilter"; import { FabricStyles } from "../../util/FabricStyles"; import { IJointMeta, JointDataset } from "../../util/JointDataset"; +import { cohortEditorStyles } from "./CohortEditor.styles"; + export interface ICohortEditorFilterProps { openedFilter: IFilter; jointDataset: JointDataset; filterIndex?: number; filters: IFilter[]; + showInvalidMinMaxValueError: boolean; + showInvalidValueError: boolean; setSelectedProperty( ev: React.FormEvent, item?: IComboBoxOption @@ -99,7 +103,7 @@ export class CohortEditorFilter extends React.Component + {this.props.showInvalidMinMaxValueError && + selectedMeta.featureRange && ( +

+ {localization.formatString( + localization.Interpret.CohortEditor + .minimumGreaterThanMaximum, + selectedMeta.featureRange.min, + selectedMeta.featureRange.max + )} +

+ )} ) : ( ))} + {this.props.showInvalidValueError && selectedMeta.featureRange && ( +

+ {localization.formatString( + localization.Interpret.CohortEditor.invalidValueError, + selectedMeta.featureRange.min, + selectedMeta.featureRange.max + )} +

+ )} )} diff --git a/libs/localization/src/lib/en.json b/libs/localization/src/lib/en.json index cf57f9b500..0ba0618aa8 100644 --- a/libs/localization/src/lib/en.json +++ b/libs/localization/src/lib/en.json @@ -82,7 +82,7 @@ "Unknown": "unknown" }, "ShiftCohort": { - "title": "Shift Cohort", + "title": "Switch Cohort", "subText": "Select a cohort from the cohort list. Apply the cohort to the dashboard." }, "PreBuiltCohort": { @@ -215,7 +215,7 @@ "fullscreen": "Fullscreen", "heatMap": "Heat map", "newCohort": "New cohort", - "shiftCohort": "Shift cohort", + "shiftCohort": "Switch cohort", "treeMap": "Tree map", "whatIf": "What-If" }, @@ -815,6 +815,8 @@ "clearAllFilters": "Clear all filters", "defaultFilterState": "Select a filter to add parameters to your dataset cohort. Filters from your current viewing cohort are pre-populated.", "delete": "Delete", + "invalidValueError": "Value should be between {0} and {1}", + "minimumGreaterThanMaximum": "Minimum value inputs must be less than maximum value inputs.", "noAddedFilters": "No filters", "placeholderName": "Cohort {0}", "save": "Save", @@ -1267,11 +1269,11 @@ "deleteCohort": "Deleting {0}?", "deleteConfirm": "Are you sure you want to delete this cohort?", "selectCohort": "Select a cohort", - "shiftCohort": "Shift cohort", + "shiftCohort": "Switch cohort", "shiftCohortDescription": "Select a cohort from the cohort list. Apply the cohort to the dashboard." }, "CohortInformation": { - "ShiftCohort": "Shift cohort", + "ShiftCohort": "Switch cohort", "NewCohort": "New cohort", "DataPoints": "Number of datapoints", "DefaultCohort": " (default)", @@ -1318,7 +1320,7 @@ "cohortList": "Cohort list", "cohortSettings": "Cohort settings", "createCohort": "Create cohort", - "shiftCohort": "Shift cohort" + "shiftCohort": "Switch cohort" }, "Navigation": { "modelStatistics": "Model statistics"