Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions packages/amis-core/src/store/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function initChildren(
item
};
const id = String(
getEntryId ? getEntryId(item, index) : item.__id ?? guid()
getEntryId ? getEntryId(item, index) : (item.__id ?? guid())
);

return {
Expand Down Expand Up @@ -423,7 +423,7 @@ export const Row = types
},

change(values: object, savePristine?: boolean) {
let data = immutableExtends(self.data, values);
let data = immutableExtends(self.data, values, true);

Object.isExtensible(data) &&
!data.__pristine &&
Expand Down Expand Up @@ -653,13 +653,13 @@ export const TableStore = iRendererStore
!self.hideCheckToggler &&
self.rows.length
: item.type === '__dragme'
? self.dragging
: item.type === '__expandme'
? getFootableColumns().length && !self.dragging
: (item.toggled || !item.toggable) &&
(!self.footable ||
!item.breakpoint ||
!isBreakpoint(item.breakpoint)))
? self.dragging
: item.type === '__expandme'
? getFootableColumns().length && !self.dragging
: (item.toggled || !item.toggable) &&
(!self.footable ||
!item.breakpoint ||
!isBreakpoint(item.breakpoint)))
);
}

Expand Down Expand Up @@ -1434,8 +1434,8 @@ export const TableStore = iRendererStore
typeof column.pristine.width === 'number'
? `width: ${column.pristine.width}px;`
: column.pristine.width
? `width: ${column.pristine.width};min-width: ${column.pristine.width};`
: '' // todo 可能需要让修改过列宽的保持相应宽度,目前这样相当于重置了
? `width: ${column.pristine.width};min-width: ${column.pristine.width};`
: '' // todo 可能需要让修改过列宽的保持相应宽度,目前这样相当于重置了
}`;
});

Expand Down Expand Up @@ -1582,7 +1582,7 @@ export const TableStore = iRendererStore
}

let id = String(
getEntryId ? getEntryId(item, index) : item.__id ?? guid()
getEntryId ? getEntryId(item, index) : (item.__id ?? guid())
);
return {
// id: getEntryId ? getEntryId(item, key) : String(item && (item as any)[self.primaryField] || `${key}-1-${key}`),
Expand Down
2 changes: 1 addition & 1 deletion packages/amis-core/src/store/table2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const Row = types
}
},
change(values: object, savePristine?: boolean) {
self.data = immutableExtends(self.data, values);
self.data = immutableExtends(self.data, values, true);
savePristine && (self.pristine = self.data);
},
reset() {
Expand Down
22 changes: 14 additions & 8 deletions packages/amis-core/src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,15 @@
Object.keys(from).forEach(key => {
const origin = to[key];
const value = from[key];
let newValue = value;
if (deep && isObject(origin) && isObject(value)) {
newValue = immutableExtends(origin, value, deep);
}

// todo 支持深度merge
if (origin !== value) {
if (origin !== newValue) {
// 一旦有修改,就创建个新对象。
ret = ret !== to ? ret : {...to};
ret[key] = value;
ret[key] = newValue;

Check warning

Code scanning / CodeQL

Prototype-polluting function Medium

Properties are copied from
from
to
ret
without guarding against prototype pollution.
}
});

Expand Down Expand Up @@ -466,7 +469,7 @@
const name = filter(schema.name, data);

const visible = isAlive(statusStore)
? statusStore.visibleState[id] ?? statusStore.visibleState[name]
? (statusStore.visibleState[id] ?? statusStore.visibleState[name])
: undefined;

if (typeof visible !== 'undefined') {
Expand Down Expand Up @@ -539,8 +542,11 @@
return schema.hasOwnProperty(ability)
? schema[ability]
: schema.hasOwnProperty(`${ability}On`)
? evalExpressionWithConditionBuilder(schema[`${ability}On`], data || schema)
: defaultValue;
? evalExpressionWithConditionBuilder(
schema[`${ability}On`],
data || schema
)
: defaultValue;
}

export function makeHorizontalDeeper(
Expand Down Expand Up @@ -1675,8 +1681,8 @@
ret === false
? false
: typeof fn == 'function'
? fn(...args)
: undefined,
? fn(...args)
: undefined,
undefined
);
}
Expand Down
Loading