process/calculate(validation): disable reset options value on load-kp
This commit is contained in:
parent
614511ab18
commit
e5b0d7a746
@ -6,6 +6,7 @@ import ValidationHelper from '@/stores/validation/helper';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import { reaction } from 'mobx';
|
||||
import { uid } from 'radash';
|
||||
import { filterObject } from 'tools';
|
||||
import type { BaseOption } from 'ui/elements/types';
|
||||
|
||||
function hasInvalidValueOrOptions(value: unknown, options: Array<BaseOption<unknown>>) {
|
||||
@ -92,7 +93,8 @@ export default function reactions({ store }: ProcessContext) {
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
disposableReaction(
|
||||
() => $process.has('LoadKP'),
|
||||
() => element.getOptions(),
|
||||
(options) => {
|
||||
const value = element.getValue();
|
||||
@ -106,7 +108,9 @@ export default function reactions({ store }: ProcessContext) {
|
||||
);
|
||||
}
|
||||
|
||||
(Object.keys(types) as Values.Elements[]).forEach((elementName) =>
|
||||
const optionsTypes = filterObject(types, (type) => type().typeName === 'Options');
|
||||
|
||||
(Object.keys(optionsTypes) as Values.Elements[]).forEach((elementName) =>
|
||||
validateOptionsElement(elementName)
|
||||
);
|
||||
|
||||
@ -142,7 +146,8 @@ export default function reactions({ store }: ProcessContext) {
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
disposableReaction(
|
||||
() => $process.has('LoadKP'),
|
||||
() => row.getOptions('insuranceCompany'),
|
||||
(options) => {
|
||||
const value = row.getValue('insuranceCompany');
|
||||
|
||||
@ -1,3 +1,18 @@
|
||||
export function flatten(obj: object) {
|
||||
return Object.values(obj).flat();
|
||||
}
|
||||
|
||||
export function filterObject<T extends object, RemovedKeys extends keyof T>(
|
||||
obj: T,
|
||||
filter: (value: T[keyof T]) => boolean
|
||||
): Omit<T, RemovedKeys> {
|
||||
const keys = Object.keys(obj) as Array<keyof T>;
|
||||
|
||||
return keys.reduce((acc, objKey) => {
|
||||
if (filter(obj[objKey])) {
|
||||
acc[objKey] = obj[objKey];
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {} as T);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user