Skip to content

Commit

Permalink
feat: made Control.value mandatory in all controls
Browse files Browse the repository at this point in the history
  • Loading branch information
shreraju-amzn authored and Shreyas-vgr committed Feb 3, 2021
1 parent 9b917a3 commit 8a726c9
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/commonControls/DateControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class DateControlState implements ControlState {
/**
* The value, an ISO date string.
*/
value?: string;
value: string;

/**
* Tracks if the control is actively asking the user to set or change the value.
Expand Down
2 changes: 1 addition & 1 deletion src/commonControls/ValueControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class ValueControlState implements ControlState {
* If `erMatch = true` the value is a slot value ID for the slot type `this.slotType`.
* If `erMatch = false` the value may be an arbitrary string.
*/
value?: string;
value: string;

/**
* Tracks whether the value is an Entity Resolution match.
Expand Down
8 changes: 4 additions & 4 deletions src/commonControls/dateRangeControl/DateRangeControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,23 +794,23 @@ export class DateRangeControl extends ContainerControl implements InteractionMod
}
}

private getStartDateFromChild(): string | undefined {
private getStartDateFromChild(): string {
return this.startDateControl.state.value;
}

private getEndDateFromChild(): string | undefined {
private getEndDateFromChild(): string {
return this.endDateControl.state.value;
}

private setStartDate(date: string | undefined): void {
private setStartDate(date: string): void {
this.startDateControl.state.value = date;
this.state.startDate = date;

// Clean open question once a value set
this.state.isChangingRange = false;
}

private setEndDate(date: string | undefined): void {
private setEndDate(date: string): void {
this.endDateControl.state.value = date;
this.state.endDate = date;

Expand Down
2 changes: 1 addition & 1 deletion src/commonControls/listControl/ListControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class ListControlState implements ControlState {
* If `erMatch = true` the value is a slot value ID for the slot type `this.slotType`.
* If `erMatch = false` the value may be an arbitrary string.
*/
value?: string;
value: string;

/**
* Tracks whether the value is an Entity Resolution match.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class MultiValueListControlState implements ControlState {
/**
* The list of values as [ (id1, erMatch), (id2, erMatch) ]
*/
value?: MultiValueListStateValue[];
value: MultiValueListStateValue[];

/**
* Tracks the most recent elicitation action.
Expand Down Expand Up @@ -1213,7 +1213,7 @@ export class MultiValueListControl extends Control implements InteractionModelCo

// tsDoc - see ControlStateDiagramming
stringifyStateForDiagram(): string {
let text = this.state.value ? this.state.value.join(', ') : '<none>';
let text = this.state.value.length > 0 ? this.state.value.join(', ') : '<none>';
if (this.state.elicitationAction !== undefined) {
text += `[eliciting, ${this.state.elicitationAction}]`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commonControls/numberControl/NumberControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class NumberControlState implements ControlState {
/**
* The value, an integer.
*/
value?: number;
value: number;

/**
* Tracks whether the value has been explicitly confirmed by the user.
Expand Down
2 changes: 1 addition & 1 deletion src/controls/ContainerControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface ChildActivityRecord {
* Container state for use in arbitration
*/
export class ContainerControlState implements ControlState {
value?: any;
value: any;
lastHandlingControl?: ChildActivityRecord; // TODO: naming: change to lastHandlingControlInfo | lastHandlingControlRecord
lastInitiativeChild?: ChildActivityRecord; // ditto.
}
Expand Down
2 changes: 1 addition & 1 deletion src/controls/Control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface ControlState {
* controls and other consumers should `control.isReady()` to determine if the value
* is ready for use.
*/
value?: any; //TODO: make mandatory to tighten the convention.
value: any;
}

export interface ControlInputHandler {
Expand Down

0 comments on commit 8a726c9

Please sign in to comment.