Skip to content

Commit f874bfe

Browse files
authored
fix(updateProperties): getFieldMask ignore gridProperties (#674)
1 parent cfee339 commit f874bfe

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

src/lib/utils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import * as _ from './lodash';
22

33
export function getFieldMask(obj: Record<string, unknown>) {
4-
return Object.keys(obj).join(',');
4+
let fromGrid = '';
5+
let fromRoot = Object.keys(obj).filter((key) => key !== 'gridProperties').join(',');
6+
7+
if (obj.gridProperties) {
8+
fromGrid = Object.keys(obj.gridProperties).map(key => `gridProperties.${key}`).join(',');
9+
if (fromGrid.length && fromRoot.length) {
10+
fromGrid = `${fromGrid},`
11+
}
12+
}
13+
return fromGrid + fromRoot;
514
}
615

716
export function columnToLetter(column: number) {

src/test/utils.test.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import {getFieldMask} from "../lib/utils";
2+
3+
describe('utils', () => {
4+
describe('getFieldMask', () => {
5+
const cases = [
6+
['tabColor', {
7+
tabColor: {
8+
red: 0,
9+
green: 1,
10+
blue: 2,
11+
},
12+
}],
13+
['hidden,tabColor', {
14+
hidden: false,
15+
tabColor: {
16+
red: 0,
17+
green: 1,
18+
blue: 2,
19+
},
20+
}],
21+
['hidden,tabColor', {
22+
hidden: false,
23+
gridProperties: {},
24+
tabColor: {
25+
red: 0,
26+
green: 1,
27+
blue: 2,
28+
},
29+
}],
30+
['gridProperties.colCount,hidden,tabColor', {
31+
hidden: false,
32+
gridProperties: {
33+
colCount: 78,
34+
},
35+
tabColor: {
36+
red: 0,
37+
green: 1,
38+
blue: 2,
39+
},
40+
}],
41+
['gridProperties.colCount,gridProperties.rowCount,hidden,tabColor', {
42+
hidden: false,
43+
gridProperties: {
44+
colCount: 78,
45+
rowCount: 14,
46+
},
47+
tabColor: {
48+
red: 0,
49+
green: 1,
50+
blue: 2,
51+
},
52+
}],
53+
['gridProperties.colCount,gridProperties.rowCount', {
54+
gridProperties: {
55+
colCount: 78,
56+
rowCount: 14,
57+
},
58+
}],
59+
];
60+
61+
test.each(cases)('%s', (expected, from) => {
62+
expect(getFieldMask(from)).toBe(expected);
63+
})
64+
});
65+
});

0 commit comments

Comments
 (0)