Browse Source

Fix TS

data-source-import-policy
Artur Arseniev 6 months ago
parent
commit
e53cc6d60d
  1. 7
      packages/core/src/dom_components/model/ModelResolverWatcher.ts
  2. 10
      packages/core/test/specs/data_sources/import_policy.ts

7
packages/core/src/dom_components/model/ModelResolverWatcher.ts

@ -53,12 +53,13 @@ export class ModelResolverWatcher<T extends ObjectHash> {
addDataValues(values: ObjectAny | undefined, options: DataWatchersOptions = {}) { addDataValues(values: ObjectAny | undefined, options: DataWatchersOptions = {}) {
if (!values) return {}; if (!values) return {};
values = this.applyImportPolicy(values, options); const nextValues = this.applyImportPolicy(values, options);
const evaluatedValues = this.evaluateValues(values); if (!nextValues) return {};
const evaluatedValues = this.evaluateValues(nextValues);
const shouldSkipWatcherUpdates = options.skipWatcherUpdates || options.fromDataSource; const shouldSkipWatcherUpdates = options.skipWatcherUpdates || options.fromDataSource;
if (!shouldSkipWatcherUpdates) { if (!shouldSkipWatcherUpdates) {
this.updateListeners(values); this.updateListeners(nextValues);
} }
return evaluatedValues; return evaluatedValues;

10
packages/core/test/specs/data_sources/import_policy.ts

@ -34,6 +34,14 @@ const makeConditionVar = () => ({
ifFalse: 'blue', ifFalse: 'blue',
}); });
type BaseRecord = {
id: string;
title: string;
color: string;
content: string;
mutable?: boolean;
};
describe('Data source import policy', () => { describe('Data source import policy', () => {
let editor: Editor; let editor: Editor;
let em: EditorModel; let em: EditorModel;
@ -45,7 +53,7 @@ describe('Data source import policy', () => {
}; };
const addBaseDataSource = ( const addBaseDataSource = (
record = { id: 'rec1', title: 'Initial Title', color: 'red', content: 'Dynamic Content' }, record: BaseRecord = { id: 'rec1', title: 'Initial Title', color: 'red', content: 'Dynamic Content' },
) => { ) => {
dsm.add({ dsm.add({
id: 'records', id: 'records',

Loading…
Cancel
Save