|
@@ -25,75 +25,84 @@ export default async function (viewId: string, fieldInfo: FieldInfo, dispatch?:
|
|
const field = fieldInfo.field;
|
|
const field = fieldInfo.field;
|
|
const typeOptionController = new TypeOptionController(viewId, Some(fieldInfo));
|
|
const typeOptionController = new TypeOptionController(viewId, Some(fieldInfo));
|
|
|
|
|
|
- let selectOptions: ISelectOption[] | undefined;
|
|
|
|
- let numberFormat: NumberFormat | undefined;
|
|
|
|
- let dateFormat: DateFormat | undefined;
|
|
|
|
- let timeFormat: TimeFormat | undefined;
|
|
|
|
- let includeTime: boolean | undefined;
|
|
|
|
-
|
|
|
|
// temporary hack to set grouping field
|
|
// temporary hack to set grouping field
|
|
let groupingFieldSelected = false;
|
|
let groupingFieldSelected = false;
|
|
|
|
|
|
switch (field.field_type) {
|
|
switch (field.field_type) {
|
|
case FieldType.SingleSelect:
|
|
case FieldType.SingleSelect:
|
|
case FieldType.MultiSelect:
|
|
case FieldType.MultiSelect:
|
|
- case FieldType.Checklist:
|
|
|
|
- {
|
|
|
|
- let typeOption: SingleSelectTypeOptionPB | MultiSelectTypeOptionPB | ChecklistTypeOptionPB | undefined;
|
|
|
|
|
|
+ case FieldType.Checklist: {
|
|
|
|
+ let selectOptions: ISelectOption[] = [];
|
|
|
|
+ let typeOption: SingleSelectTypeOptionPB | MultiSelectTypeOptionPB | ChecklistTypeOptionPB | undefined;
|
|
|
|
|
|
- if (field.field_type === FieldType.SingleSelect) {
|
|
|
|
- typeOption = (await makeSingleSelectTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
- if (!groupingFieldSelected) {
|
|
|
|
- if (dispatch) {
|
|
|
|
- dispatch(boardActions.setGroupingFieldId({ fieldId: field.id }));
|
|
|
|
- }
|
|
|
|
- groupingFieldSelected = true;
|
|
|
|
|
|
+ if (field.field_type === FieldType.SingleSelect) {
|
|
|
|
+ typeOption = (await makeSingleSelectTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
+ if (!groupingFieldSelected) {
|
|
|
|
+ if (dispatch) {
|
|
|
|
+ dispatch(boardActions.setGroupingFieldId({ fieldId: field.id }));
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (field.field_type === FieldType.MultiSelect) {
|
|
|
|
- typeOption = (await makeMultiSelectTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
- }
|
|
|
|
- if (field.field_type === FieldType.Checklist) {
|
|
|
|
- typeOption = (await makeChecklistTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (typeOption) {
|
|
|
|
- selectOptions = typeOption.options.map<ISelectOption>((option) => {
|
|
|
|
- return {
|
|
|
|
- selectOptionId: option.id,
|
|
|
|
- title: option.name,
|
|
|
|
- color: option.color,
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
|
|
+ groupingFieldSelected = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- case FieldType.Number:
|
|
|
|
- {
|
|
|
|
- const typeOption = (await makeNumberTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
- numberFormat = typeOption.format;
|
|
|
|
|
|
+ if (field.field_type === FieldType.MultiSelect) {
|
|
|
|
+ typeOption = (await makeMultiSelectTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- case FieldType.DateTime:
|
|
|
|
- {
|
|
|
|
- const typeOption = (await makeDateTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
- dateFormat = typeOption.date_format;
|
|
|
|
- timeFormat = typeOption.time_format;
|
|
|
|
- includeTime = typeOption.include_time;
|
|
|
|
|
|
+ if (field.field_type === FieldType.Checklist) {
|
|
|
|
+ typeOption = (await makeChecklistTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- return {
|
|
|
|
- fieldId: field.id,
|
|
|
|
- title: field.name,
|
|
|
|
- fieldType: field.field_type,
|
|
|
|
- fieldOptions: {
|
|
|
|
- selectOptions,
|
|
|
|
- numberFormat,
|
|
|
|
- dateFormat,
|
|
|
|
- timeFormat,
|
|
|
|
- includeTime,
|
|
|
|
- },
|
|
|
|
- };
|
|
|
|
|
|
+ if (typeOption) {
|
|
|
|
+ selectOptions = typeOption.options.map<ISelectOption>((option) => {
|
|
|
|
+ return {
|
|
|
|
+ selectOptionId: option.id,
|
|
|
|
+ title: option.name,
|
|
|
|
+ color: option.color,
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ fieldId: field.id,
|
|
|
|
+ title: field.name,
|
|
|
|
+ fieldType: field.field_type,
|
|
|
|
+ fieldOptions: {
|
|
|
|
+ selectOptions,
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ case FieldType.Number: {
|
|
|
|
+ const typeOption = (await makeNumberTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
+ return {
|
|
|
|
+ fieldId: field.id,
|
|
|
|
+ title: field.name,
|
|
|
|
+ fieldType: field.field_type,
|
|
|
|
+ fieldOptions: {
|
|
|
|
+ numberFormat: typeOption.format,
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ case FieldType.DateTime: {
|
|
|
|
+ const typeOption = (await makeDateTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
|
|
|
+ return {
|
|
|
|
+ fieldId: field.id,
|
|
|
|
+ title: field.name,
|
|
|
|
+ fieldType: field.field_type,
|
|
|
|
+ fieldOptions: {
|
|
|
|
+ dateFormat: typeOption.date_format,
|
|
|
|
+ timeFormat: typeOption.time_format,
|
|
|
|
+ includeTime: typeOption.include_time,
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ default: {
|
|
|
|
+ return {
|
|
|
|
+ fieldId: field.id,
|
|
|
|
+ title: field.name,
|
|
|
|
+ fieldType: field.field_type,
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|