Skip to content

Commit

Permalink
M2-5989 feat: MultiSelectMatrix Config DTO was added
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Riabkov committed Mar 25, 2024
1 parent f10ab1e commit a1e63c4
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 6 deletions.
45 changes: 43 additions & 2 deletions src/entities/activity/lib/types/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export type AdditionalResponseConfig = {
};
};

export type DataMatrix = Array<{
rowId: string;
options: Array<{
optionId: string;
score: number;
alert: string | null;
}>;
}>;

export interface ActivityItemBase {
id: string;
name: string;
Expand All @@ -64,15 +73,17 @@ export type Config =
| DateItemConfig
| TimeItemItemConfig
| TimeRangeItemConfig
| AudioPlayerItemConfig;
| AudioPlayerItemConfig
| MultiSelectionRowsItemConfig;

export type ResponseValues =
| EmptyResponseValues
| CheckboxValues
| RadioValues
| SliderValues
| SelectorValues
| AudioPlayerItemValues;
| AudioPlayerItemValues
| MultiSelectionRowsItemResponseValues;

export type EmptyResponseValues = null;

Expand Down Expand Up @@ -253,3 +264,33 @@ export type AudioPlayerItemConfig = ButtonsConfig &
export type AudioPlayerItemValues = {
file: string;
};

export interface MultiSelectionRowsItem extends ActivityItemBase {
responseType: 'multiSelectRows';
config: MultiSelectionRowsItemConfig;
responseValues: MultiSelectionRowsItemResponseValues;
}

export type MultiSelectionRowsItemConfig = ButtonsConfig &
TimerConfig & {
addScores: boolean;
setAlerts: boolean;
addTooltip: boolean;
randomizeOptions: boolean;
};

export type MultiSelectionRowsItemResponseValues = {
rows: Array<{
id: string;
rowName: string;
rowImage: string | null;
tooltip: string | null;
}>;
options: Array<{
id: string;
text: string;
image: string | null;
tooltip: string | null;
}>;
dataMatrix: DataMatrix;
};
4 changes: 3 additions & 1 deletion src/entities/applet/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CheckboxItem,
DateItem,
MessageItem,
MultiSelectionRowsItem,
RadioItem,
SelectorItem,
SliderItem,
Expand Down Expand Up @@ -60,7 +61,8 @@ export type ItemRecord =
| DateItem
| TimeItem
| TimeRangeItem
| AudioPlayerItem;
| AudioPlayerItem
| MultiSelectionRowsItem;

export type ItemWithAdditionalResponse = Extract<
ItemRecord,
Expand Down
4 changes: 3 additions & 1 deletion src/shared/api/types/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CheckboxItemDTO,
DateItemDTO,
MessageItemDTO,
MultiSelectionRowsItemDTO,
RadioItemDTO,
SelectorItemDTO,
SliderItemDTO,
Expand Down Expand Up @@ -56,7 +57,8 @@ export type ActivityItemDetailsDTO =
| DateItemDTO
| TimeItemDTO
| TimeRangeItemDTO
| AudioPlayerItemDTO;
| AudioPlayerItemDTO
| MultiSelectionRowsItemDTO;

export type AnswerPayload = {
appletId: ID;
Expand Down
54 changes: 52 additions & 2 deletions src/shared/api/types/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,38 @@ export type ConfigDTO =
| DateItemConfigDTO
| TimeItemConfigDTO
| TimeRangeItemConfigDTO
| AudioPlayerItemConfigDTO;
| AudioPlayerItemConfigDTO
| MultiSelectionRowsItemConfigDTO;

export type ResponseValuesDTO =
| EmptyResponseValuesDTO
| CheckboxItemResponseValuesDTO
| RadioItemResponseValuesDTO
| SliderItemResponseValuesDTO
| SelectorItemResponseValues
| AudioPlayerItemResponseValuesDTO;
| AudioPlayerItemResponseValuesDTO
| MultiSelectionRowsItemResponseValuesDTO;

export type EmptyResponseValuesDTO = null;

export type DataMatrixDto = Array<{
rowId: string;
options: Array<{
optionId: string;
score: number;
alert: string | null;
}>;
}>;

export type ButtonsConfig = {
removeBackButton: boolean;
skippableItem: boolean;
};

export type TimerConfig = {
timer: number | null;
};

export type AdditionalResponseOptionConfigDTO = {
additionalResponseOption: {
textInputOption: boolean;
Expand Down Expand Up @@ -253,3 +273,33 @@ export type AudioPlayerItemConfigDTO = AdditionalResponseOptionConfigDTO & {
export type AudioPlayerItemResponseValuesDTO = {
file: string;
};

export interface MultiSelectionRowsItemDTO extends ItemDetailsBaseDTO {
responseType: 'multiSelectRows';
config: MultiSelectionRowsItemConfigDTO;
responseValues: MultiSelectionRowsItemResponseValuesDTO;
}

export type MultiSelectionRowsItemConfigDTO = ButtonsConfig &
TimerConfig & {
addScores: boolean;
setAlerts: boolean;
addTooltip: boolean;
randomizeOptions: boolean;
};

type MultiSelectionRowsItemResponseValuesDTO = {
rows: Array<{
id: string;
rowName: string;
rowImage: string | null;
tooltip: string | null;
}>;
options: Array<{
id: string;
text: string;
image: string | null;
tooltip: string | null;
}>;
dataMatrix: DataMatrixDto;
};

0 comments on commit a1e63c4

Please sign in to comment.