mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: change IDatabaseField fix eslint errors
This commit is contained in:
parent
557a524648
commit
7ca4da0966
@ -9,6 +9,7 @@
|
||||
"preview": "vite preview",
|
||||
"format": "prettier --write .",
|
||||
"test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .",
|
||||
"test:errors": "eslint --quiet --ext .js,.ts,.tsx .",
|
||||
"test:prettier": "yarn prettier --list-different src",
|
||||
"tauri:dev": "tauri dev",
|
||||
"test": "jest"
|
||||
|
@ -37,7 +37,7 @@ export async function assertTextCell(
|
||||
const cellController = await makeTextCellController(fieldId, rowInfo, databaseController).then((result) =>
|
||||
result.unwrap()
|
||||
);
|
||||
await cellController.subscribeChanged({
|
||||
cellController.subscribeChanged({
|
||||
onCellChanged: (value) => {
|
||||
const cellContent = value.unwrap();
|
||||
if (cellContent !== expectedContent) {
|
||||
|
@ -124,7 +124,7 @@ export const TestCreateSelectOptionInCell = () => {
|
||||
const cellController = await makeSingleSelectCellController(fieldInfo.field.id, row, databaseController).then(
|
||||
(result) => result.unwrap()
|
||||
);
|
||||
await cellController.subscribeChanged({
|
||||
cellController.subscribeChanged({
|
||||
onCellChanged: (value) => {
|
||||
if (value.some) {
|
||||
const option: SelectOptionCellDataPB = value.unwrap();
|
||||
|
@ -25,75 +25,84 @@ export default async function (viewId: string, fieldInfo: FieldInfo, dispatch?:
|
||||
const field = fieldInfo.field;
|
||||
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
|
||||
let groupingFieldSelected = false;
|
||||
|
||||
switch (field.field_type) {
|
||||
case FieldType.SingleSelect:
|
||||
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 }));
|
||||
}
|
||||
groupingFieldSelected = true;
|
||||
}
|
||||
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 (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,
|
||||
};
|
||||
});
|
||||
}
|
||||
if (typeOption) {
|
||||
selectOptions = typeOption.options.map<ISelectOption>((option) => {
|
||||
return {
|
||||
selectOptionId: option.id,
|
||||
title: option.name,
|
||||
color: option.color,
|
||||
};
|
||||
});
|
||||
}
|
||||
break;
|
||||
case FieldType.Number:
|
||||
{
|
||||
const typeOption = (await makeNumberTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
||||
numberFormat = typeOption.format;
|
||||
}
|
||||
break;
|
||||
case FieldType.DateTime:
|
||||
{
|
||||
const typeOption = (await makeDateTypeOptionContext(typeOptionController).getTypeOption()).unwrap();
|
||||
dateFormat = typeOption.date_format;
|
||||
timeFormat = typeOption.time_format;
|
||||
includeTime = typeOption.include_time;
|
||||
}
|
||||
break;
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
fieldId: field.id,
|
||||
title: field.name,
|
||||
fieldType: field.field_type,
|
||||
fieldOptions: {
|
||||
selectOptions,
|
||||
numberFormat,
|
||||
dateFormat,
|
||||
timeFormat,
|
||||
includeTime,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import { DatabaseViewCache } from './view/database_view_cache';
|
||||
import { DatabasePB } from '../../../../services/backend';
|
||||
import { RowChangedReason, RowInfo } from './row/row_cache';
|
||||
import { Err, Ok, Result } from 'ts-results';
|
||||
import { FlowyError, RowPB } from '../../../../services/backend';
|
||||
|
||||
export type SubscribeCallbacks = {
|
||||
onViewChanged?: (data: DatabasePB) => void;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { OnNotificationError } from '../../../../../services/backend/notifications';
|
||||
import { AFNotificationObserver } from '../../../../../services/backend/notifications';
|
||||
import { OnNotificationError, AFNotificationObserver } from '../../../../../services/backend/notifications';
|
||||
import { FolderNotificationParser } from './parser';
|
||||
import { FlowyError, FolderNotification } from '../../../../../services/backend';
|
||||
import { Result } from 'ts-results';
|
||||
|
@ -8,19 +8,25 @@ export interface ISelectOption {
|
||||
color?: SelectOptionColorPB;
|
||||
}
|
||||
|
||||
export interface IFieldOptions {
|
||||
selectOptions?: ISelectOption[];
|
||||
dateFormat?: DateFormat;
|
||||
timeFormat?: TimeFormat;
|
||||
includeTime?: boolean;
|
||||
numberFormat?: NumberFormat;
|
||||
export interface ISelectOptionType {
|
||||
selectOptions: ISelectOption[];
|
||||
}
|
||||
|
||||
export interface IDateType {
|
||||
dateFormat: DateFormat;
|
||||
timeFormat: TimeFormat;
|
||||
includeTime: boolean;
|
||||
}
|
||||
|
||||
export interface INumberType {
|
||||
numberFormat: NumberFormat;
|
||||
}
|
||||
|
||||
export interface IDatabaseField {
|
||||
fieldId: string;
|
||||
title: string;
|
||||
fieldType: FieldType;
|
||||
fieldOptions: IFieldOptions;
|
||||
fieldOptions?: ISelectOptionType | IDateType | INumberType;
|
||||
}
|
||||
|
||||
export interface IDatabaseColumn {
|
||||
@ -29,19 +35,8 @@ export interface IDatabaseColumn {
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
/*export interface ICellData {
|
||||
rowId: string;
|
||||
fieldId: string;
|
||||
cellId: string;
|
||||
data: string[];
|
||||
}*/
|
||||
|
||||
// export type DatabaseCellMap = { [keys: string]: ICellData };
|
||||
|
||||
export interface IDatabaseRow {
|
||||
rowId: string;
|
||||
// key(fieldId) -> value(Cell)
|
||||
// cells: DatabaseCellMap;
|
||||
}
|
||||
|
||||
export type DatabaseFieldMap = { [keys: string]: IDatabaseField };
|
||||
|
Loading…
Reference in New Issue
Block a user