fix(editor): kanban data refresh (#15321)
fix #15281 #### PR Dependency Tree * **PR #15321** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved row handling during group and card updates to prevent rows from remaining locked. * Preserved manual card ordering when moving cards or updating group values. * Added coverage to verify row unlocking behavior during card moves. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -300,10 +300,14 @@ const createGroupTraitHarness = (options?: {
|
|||||||
return cell;
|
return cell;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isLocked$ = signal(false);
|
||||||
const view = {
|
const view = {
|
||||||
data$,
|
data$,
|
||||||
rows$: signal(rows.map(createTestRow)),
|
rows$: signal(rows.map(createTestRow)),
|
||||||
isLocked$: signal(false),
|
isLocked$,
|
||||||
|
lockRows: vi.fn((locked: boolean) => {
|
||||||
|
isLocked$.value = locked;
|
||||||
|
}),
|
||||||
manager: {
|
manager: {
|
||||||
dataSource: asDataSource(dataSource),
|
dataSource: asDataSource(dataSource),
|
||||||
},
|
},
|
||||||
@@ -348,6 +352,7 @@ const createGroupTraitHarness = (options?: {
|
|||||||
groupTrait: new GroupTrait(groupBy$, view as never, ops),
|
groupTrait: new GroupTrait(groupBy$, view as never, ops),
|
||||||
ops,
|
ops,
|
||||||
cells,
|
cells,
|
||||||
|
view,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -382,7 +387,7 @@ describe('kanban', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('preserves manual group order when updating card sort', () => {
|
it('preserves manual group order when updating card sort', () => {
|
||||||
const { groupTrait, ops, cells } = createGroupTraitHarness({
|
const { groupTrait, ops, cells, view } = createGroupTraitHarness({
|
||||||
groupProperties: [
|
groupProperties: [
|
||||||
{
|
{
|
||||||
key: 'false',
|
key: 'false',
|
||||||
@@ -402,8 +407,21 @@ describe('kanban', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
groupTrait.groupsDataList$.value
|
||||||
|
?.find(group => group.key === 'true')
|
||||||
|
?.rows.map(row => row.rowId)
|
||||||
|
).toEqual(['row-2']);
|
||||||
|
view.lockRows(true);
|
||||||
|
|
||||||
groupTrait.moveCardTo('row-1', 'false', 'true', 'end');
|
groupTrait.moveCardTo('row-1', 'false', 'true', 'end');
|
||||||
|
|
||||||
|
expect(view.lockRows).toHaveBeenLastCalledWith(false);
|
||||||
|
expect(
|
||||||
|
groupTrait.groupsDataList$.value
|
||||||
|
?.find(group => group.key === 'true')
|
||||||
|
?.rows.map(row => row.rowId)
|
||||||
|
).toEqual(['row-2', 'row-1']);
|
||||||
expect(ops.changeRowSort).toHaveBeenCalledWith(
|
expect(ops.changeRowSort).toHaveBeenCalledWith(
|
||||||
['false', 'true'],
|
['false', 'true'],
|
||||||
'true',
|
'true',
|
||||||
|
|||||||
@@ -353,6 +353,7 @@ export class GroupTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addToGroup(rowId: string, key: string) {
|
addToGroup(rowId: string, key: string) {
|
||||||
|
this.view.lockRows(false);
|
||||||
const groupMap = this.groupDataMap$.value;
|
const groupMap = this.groupDataMap$.value;
|
||||||
const groupInfo = this.groupInfo$.value;
|
const groupInfo = this.groupInfo$.value;
|
||||||
if (!groupMap || !groupInfo) {
|
if (!groupMap || !groupInfo) {
|
||||||
@@ -448,6 +449,7 @@ export class GroupTrait {
|
|||||||
toGroupKey: string,
|
toGroupKey: string,
|
||||||
position: InsertToPosition
|
position: InsertToPosition
|
||||||
) {
|
) {
|
||||||
|
this.view.lockRows(false);
|
||||||
const groupMap = this.groupDataMap$.value;
|
const groupMap = this.groupDataMap$.value;
|
||||||
if (!groupMap) {
|
if (!groupMap) {
|
||||||
return;
|
return;
|
||||||
@@ -490,6 +492,7 @@ export class GroupTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveGroupTo(groupKey: string, position: InsertToPosition) {
|
moveGroupTo(groupKey: string, position: InsertToPosition) {
|
||||||
|
this.view.lockRows(false);
|
||||||
const groups = this.groupsDataListAll$.value;
|
const groups = this.groupsDataListAll$.value;
|
||||||
if (!groups) {
|
if (!groups) {
|
||||||
return;
|
return;
|
||||||
@@ -506,6 +509,7 @@ export class GroupTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeFromGroup(rowId: string, key: string) {
|
removeFromGroup(rowId: string, key: string) {
|
||||||
|
this.view.lockRows(false);
|
||||||
const groupMap = this.groupDataMap$.value;
|
const groupMap = this.groupDataMap$.value;
|
||||||
if (!groupMap) {
|
if (!groupMap) {
|
||||||
return;
|
return;
|
||||||
@@ -524,6 +528,7 @@ export class GroupTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateValue(rows: string[], value: unknown) {
|
updateValue(rows: string[], value: unknown) {
|
||||||
|
this.view.lockRows(false);
|
||||||
const propertyId = this.property$.value?.id;
|
const propertyId = this.property$.value?.id;
|
||||||
if (!propertyId) {
|
if (!propertyId) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user