Skip to content

Commit 935557d

Browse files
authored
chore: fix missing group key (#253)
* chore: fix missing group key * chore: lint
1 parent c8cd243 commit 935557d

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/application/database-yjs/dispatch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ function generateGroupByField(field: YDatabaseField) {
173173

174174
group.set(YjsDatabaseKey.field_id, fieldId);
175175
group.set(YjsDatabaseKey.id, `g:${nanoid(6)}`);
176+
group.set(YjsDatabaseKey.type, fieldType);
176177

177178
switch (fieldType) {
178179
case FieldType.SingleSelect:

src/application/database-yjs/dispatch/group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function generateGroupByField(field: YDatabaseField) {
4646

4747
group.set(YjsDatabaseKey.field_id, fieldId);
4848
group.set(YjsDatabaseKey.id, `g:${nanoid(6)}`);
49+
group.set(YjsDatabaseKey.type, fieldType);
4950

5051
switch (fieldType) {
5152
case FieldType.SingleSelect:

src/application/types.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ export enum YjsDatabaseKey {
348348
data = 'data',
349349
iid = 'iid',
350350
database_id = 'database_id',
351+
is_two_way = 'is_two_way',
352+
reciprocal_field_id = 'reciprocal_field_id',
353+
reciprocal_field_name = 'reciprocal_field_name',
354+
source_limit = 'source_limit',
355+
target_limit = 'target_limit',
351356
relation_field_id = 'relation_field_id',
352357
target_field_id = 'target_field_id',
353358
calculation_type = 'calculation_type',
@@ -378,12 +383,14 @@ export enum YjsDatabaseKey {
378383
calculations = 'calculations',
379384
field_id = 'field_id',
380385
calculation_value = 'calculation_value',
386+
cv = 'cv',
381387
source_field_type = 'source_field_type', // Added this
382388
condition = 'condition',
383389
schema_version = 'schema_version',
384390
format = 'format',
385391
filter_type = 'filter_type',
386392
visible = 'visible',
393+
collapsed_group_ids = 'collapsed_group_ids',
387394
hide_ungrouped_column = 'hide_ungrouped_column',
388395
collapse_hidden_groups = 'collapse_hidden_groups',
389396
first_day_of_week = 'first_day_of_week',
@@ -667,10 +674,14 @@ export interface YDatabaseGroup extends Y.Map<unknown> {
667674

668675
get(key: YjsDatabaseKey.field_id): FieldId;
669676

677+
get(key: YjsDatabaseKey.type): number | string;
678+
670679
// eslint-disable-next-line @typescript-eslint/unified-signatures
671680
get(key: YjsDatabaseKey.content): string; // "{"hide_empty":false,"condition":2}"
672681

673682
get(key: YjsDatabaseKey.groups): YDatabaseGroupColumns;
683+
684+
get(key: YjsDatabaseKey.collapsed_group_ids): Y.Array<string> | string[] | undefined;
674685
}
675686

676687
export type YDatabaseGroupColumns = Y.Array<{ id: string; visible: boolean }>;
@@ -704,7 +715,11 @@ export interface YDatabaseFilter extends Y.Map<unknown> {
704715
export interface YDatabaseCalculation extends Y.Map<unknown> {
705716
get(key: YjsDatabaseKey.field_id): FieldId;
706717

707-
get(key: YjsDatabaseKey.id | YjsDatabaseKey.type | YjsDatabaseKey.calculation_value): string;
718+
get(key: YjsDatabaseKey.id | YjsDatabaseKey.cv): string;
719+
720+
get(key: YjsDatabaseKey.type): string | number;
721+
722+
get(key: YjsDatabaseKey.calculation_value): string | number | undefined;
708723
}
709724

710725
export interface YDatabaseFieldSettings extends Y.Map<unknown> {
@@ -762,6 +777,8 @@ export interface YMapFieldTypeOption extends Y.Map<unknown> {
762777
| YjsDatabaseKey.condition_value
763778
): string;
764779

780+
get(key: YjsDatabaseKey.reciprocal_field_id | YjsDatabaseKey.reciprocal_field_name): string | undefined;
781+
765782
// CreatedTime, LastEditedTime, DateTime
766783
// eslint-disable-next-line @typescript-eslint/unified-signatures
767784
get(key: YjsDatabaseKey.time_format): string | undefined;
@@ -773,15 +790,16 @@ export interface YMapFieldTypeOption extends Y.Map<unknown> {
773790
// Relation
774791
get(key: YjsDatabaseKey.database_id): DatabaseId;
775792

793+
get(key: YjsDatabaseKey.is_two_way | YjsDatabaseKey.include_time): boolean;
794+
795+
get(key: YjsDatabaseKey.source_limit | YjsDatabaseKey.target_limit): number | undefined;
796+
776797
get(key: YjsDatabaseKey.calculation_type | YjsDatabaseKey.show_as): number;
777798

778799
// Number
779800
// eslint-disable-next-line @typescript-eslint/unified-signatures
780801
get(key: YjsDatabaseKey.format): string;
781802

782-
// LastEditedTime and CreatedTime
783-
get(key: YjsDatabaseKey.include_time): boolean;
784-
785803
// AI Translate
786804
// eslint-disable-next-line @typescript-eslint/unified-signatures
787805
get(key: YjsDatabaseKey.auto_fill): boolean;

src/components/database/components/database-row/DatabaseRowSubDocument.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const DatabaseRowSubDocument = memo(({ rowId }: { rowId: string }) => {
130130
// undefined = meta hasn't loaded from Yjs yet (wait)
131131
// true = meta loaded, document is empty (open locally)
132132
// false = meta loaded, document has content (load from server)
133-
const isDocumentEmptyResolved = meta == null ? undefined : (meta.isEmptyDocument ?? true);
133+
const isDocumentEmptyResolved = meta === null || meta === undefined ? undefined : (meta.isEmptyDocument ?? true);
134134

135135
const isDocumentEmpty = useCallback(
136136
(editor: YjsEditor) => {

src/components/database/components/grid/grid-cell/GridCalculateRowCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function GridCalculateRowCell ({ fieldId }: GridCalculateRowCellProps) {
4040
setCalculation({
4141
id: item.get(YjsDatabaseKey.id),
4242
fieldId: item.get(YjsDatabaseKey.field_id),
43-
value: item.get(YjsDatabaseKey.calculation_value),
43+
value: String(item.get(YjsDatabaseKey.calculation_value) ?? ''),
4444
type: Number(item.get(YjsDatabaseKey.type)) as CalculationType,
4545
});
4646
}, [calculations, fieldId]);

0 commit comments

Comments
 (0)