fix(editor): database block create new row when group by rich-text (#10564)
This commit is contained in:
@@ -134,7 +134,7 @@ export const groupByMatchers = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
addToGroup: value => (typeof value === 'number' ? value * 10 : undefined),
|
addToGroup: value => (typeof value === 'number' ? value * 10 : null),
|
||||||
view: createUniComponentFromWebComponent(NumberGroupView),
|
view: createUniComponentFromWebComponent(NumberGroupView),
|
||||||
}),
|
}),
|
||||||
groupByMatcherCreator.createMatcher(t.boolean.instance(), {
|
groupByMatcherCreator.createMatcher(t.boolean.instance(), {
|
||||||
|
|||||||
@@ -168,11 +168,11 @@ export class GroupTrait {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const addTo = this.config$.value?.addToGroup ?? (value => value);
|
const addTo = this.config$.value?.addToGroup ?? (value => value);
|
||||||
const newValue = addTo(
|
const v = groupMap[key]?.value;
|
||||||
groupMap[key]?.value,
|
if (v != null) {
|
||||||
this.view.cellJsonValueGet(rowId, propertyId)
|
const newValue = addTo(v, this.view.cellJsonValueGet(rowId, propertyId));
|
||||||
);
|
this.view.cellJsonValueSet(rowId, propertyId, newValue);
|
||||||
this.view.cellValueSet(rowId, propertyId, newValue);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeCardSort(groupKey: string, cardIds: string[]) {
|
changeCardSort(groupKey: string, cardIds: string[]) {
|
||||||
@@ -233,9 +233,9 @@ export class GroupTrait {
|
|||||||
if (!propertyId) {
|
if (!propertyId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const remove = this.config$.value?.removeFromGroup ?? (() => undefined);
|
const remove = this.config$.value?.removeFromGroup ?? (() => null);
|
||||||
const group = fromGroupKey != null ? groupMap[fromGroupKey] : undefined;
|
const group = fromGroupKey != null ? groupMap[fromGroupKey] : undefined;
|
||||||
let newValue: unknown = undefined;
|
let newValue: DVJSON = null;
|
||||||
if (group) {
|
if (group) {
|
||||||
newValue = remove(
|
newValue = remove(
|
||||||
group.value,
|
group.value,
|
||||||
@@ -243,8 +243,8 @@ export class GroupTrait {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const addTo = this.config$.value?.addToGroup ?? (value => value);
|
const addTo = this.config$.value?.addToGroup ?? (value => value);
|
||||||
newValue = addTo(groupMap[toGroupKey]?.value, newValue);
|
newValue = addTo(groupMap[toGroupKey]?.value ?? null, newValue);
|
||||||
this.view.cellValueSet(rowId, propertyId, newValue);
|
this.view.cellJsonValueSet(rowId, propertyId, newValue);
|
||||||
}
|
}
|
||||||
const rows = groupMap[toGroupKey]?.rows.filter(id => id !== rowId) ?? [];
|
const rows = groupMap[toGroupKey]?.rows.filter(id => id !== rowId) ?? [];
|
||||||
const index = insertPositionToIndex(position, rows, id => id);
|
const index = insertPositionToIndex(position, rows, id => id);
|
||||||
@@ -278,7 +278,7 @@ export class GroupTrait {
|
|||||||
}
|
}
|
||||||
const remove = this.config$.value?.removeFromGroup ?? (() => undefined);
|
const remove = this.config$.value?.removeFromGroup ?? (() => undefined);
|
||||||
const newValue = remove(
|
const newValue = remove(
|
||||||
groupMap[key]?.value,
|
groupMap[key]?.value ?? null,
|
||||||
this.view.cellJsonValueGet(rowId, propertyId)
|
this.view.cellJsonValueGet(rowId, propertyId)
|
||||||
);
|
);
|
||||||
this.view.cellValueSet(rowId, propertyId, newValue);
|
this.view.cellValueSet(rowId, propertyId, newValue);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export type GroupByConfig = {
|
|||||||
key: string;
|
key: string;
|
||||||
value: DVJSON;
|
value: DVJSON;
|
||||||
}[];
|
}[];
|
||||||
addToGroup?: (value: unknown, oldValue: unknown) => unknown;
|
addToGroup?: (value: DVJSON, oldValue: DVJSON) => DVJSON;
|
||||||
removeFromGroup?: (value: unknown, oldValue: unknown) => unknown;
|
removeFromGroup?: (value: DVJSON, oldValue: DVJSON) => DVJSON;
|
||||||
view: UniComponent<GroupRenderProps>;
|
view: UniComponent<GroupRenderProps>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export interface SingleView {
|
|||||||
|
|
||||||
cellValueSet(rowId: string, propertyId: string, value: unknown): void;
|
cellValueSet(rowId: string, propertyId: string, value: unknown): void;
|
||||||
|
|
||||||
cellJsonValueGet(rowId: string, propertyId: string): unknown;
|
cellJsonValueGet(rowId: string, propertyId: string): DVJSON;
|
||||||
|
|
||||||
cellJsonValueSet(rowId: string, propertyId: string, value: DVJSON): void;
|
cellJsonValueSet(rowId: string, propertyId: string, value: DVJSON): void;
|
||||||
|
|
||||||
@@ -264,10 +264,10 @@ export abstract class SingleViewBase<
|
|||||||
return new CellBase(this, propertyId, rowId);
|
return new CellBase(this, propertyId, rowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
cellJsonValueGet(rowId: string, propertyId: string): unknown {
|
cellJsonValueGet(rowId: string, propertyId: string): DVJSON {
|
||||||
const type = this.propertyTypeGet(propertyId);
|
const type = this.propertyTypeGet(propertyId);
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
return this.dataSource.propertyMetaGet(type).config.cellToJson({
|
return this.dataSource.propertyMetaGet(type).config.cellToJson({
|
||||||
value: this.dataSource.cellValueGet(rowId, propertyId),
|
value: this.dataSource.cellValueGet(rowId, propertyId),
|
||||||
|
|||||||
Reference in New Issue
Block a user