chore: refactor per comments

This commit is contained in:
Martin Guillon
2021-01-05 15:50:35 +01:00
parent 79537d9c0c
commit 36a7ce3d9b
3 changed files with 20 additions and 12 deletions

View File

@ -344,7 +344,8 @@ export class Binding {
}
let newValue = value;
if (!__UI_CUSTOM_FLAVOR__ && this.options.expression) {
if (__UI_CUSTOM_FLAVOR__) {
} else if (this.options.expression) {
const changedModel = {};
changedModel[bc.bindingValueKey] = value;
changedModel[bc.newPropertyValueKey] = value;
@ -370,6 +371,7 @@ export class Binding {
newValue = expressionValue;
}
this.updateSource(newValue);
}
@ -424,14 +426,7 @@ export class Binding {
}
}
if (!__UI_CUSTOM_FLAVOR__ && this.options.expression) {
const expressionValue = this._getExpressionValue(this.options.expression, false, undefined);
if (expressionValue instanceof Error) {
Trace.write(expressionValue.message, Trace.categories.Binding, Trace.messageType.error);
} else {
this.updateTarget(expressionValue);
}
} else {
if (__UI_CUSTOM_FLAVOR__ || !this.options.expression) {
if (changedPropertyIndex > -1) {
const props = sourceProps.slice(changedPropertyIndex + 1);
const propsLength = props.length;
@ -446,6 +441,13 @@ export class Binding {
this.updateTarget(data.value);
}
}
} else {
const expressionValue = this._getExpressionValue(this.options.expression, false, undefined);
if (expressionValue instanceof Error) {
Trace.write(expressionValue.message, Trace.categories.Binding, Trace.messageType.error);
} else {
this.updateTarget(expressionValue);
}
}
// we need to do this only if nested objects are used as source and some middle object has changed.
@ -519,7 +521,8 @@ export class Binding {
}
private getSourcePropertyValue() {
if (!__UI_CUSTOM_FLAVOR__ && this.options.expression) {
if (__UI_CUSTOM_FLAVOR__) {
} else if (this.options.expression) {
const changedModel = {};
changedModel[bc.bindingValueKey] = this.source ? this.source.get() : undefined;
const expressionValue = this._getExpressionValue(this.options.expression, false, changedModel);

View File

@ -26,7 +26,8 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi
public _defaultTemplate: KeyedTemplate = {
key: 'default',
createView: () => {
if (!__UI_CUSTOM_FLAVOR__ && this.itemTemplate) {
if (__UI_CUSTOM_FLAVOR__) {
} else if (this.itemTemplate) {
return Builder.parse(this.itemTemplate, this);
}

View File

@ -129,7 +129,11 @@ export class Repeater extends CustomLayoutView {
}
if (!viewToAdd) {
viewToAdd = (!__UI_CUSTOM_FLAVOR__ && this.itemTemplate) ? Builder.parse(this.itemTemplate, this) : this._getDefaultItemContent(i);
if (__UI_CUSTOM_FLAVOR__) {
viewToAdd = this._getDefaultItemContent(i)
} else {
viewToAdd = this.itemTemplate ? Builder.parse(this.itemTemplate, this) : this._getDefaultItemContent(i);
}
}
viewToAdd.bindingContext = dataItem;