fix(devtools): pass property updates to the correct data sources

This commit is contained in:
AleksanderBodurri 2020-03-22 02:53:42 -04:00 committed by Minko Gechev
parent 3a6b5b0bd9
commit 820ec85ea4
2 changed files with 26 additions and 3 deletions

View file

@ -22,7 +22,7 @@ describe('edit properties of directive in the property view tab', () => {
cy.get('.explorer-panel:contains("Properties of app-todo")')
.find('ng-property-view mat-tree-node:contains("editMode")')
.find('ng-property-editor .editor')
.click()
.click({ force: true })
.find('.editor-input')
.clear()
.type('true')

View file

@ -91,11 +91,34 @@ export class DirectivePropertyResolver {
}
getExpandedProperties(): NestedProp[] {
return getExpandedDirectiveProperties(this._dataSource.data);
return [
...getExpandedDirectiveProperties(this._inputsDataSource.data),
...getExpandedDirectiveProperties(this._outputsDataSource.data),
...getExpandedDirectiveProperties(this._stateDataSource.data),
];
}
updateProperties(newProps: Properties): void {
this._dataSource.update(newProps.props);
const inputLabels: string[] = Object.keys(newProps.inputs || {});
const outputLabels: string[] = Object.keys(newProps.outputs || {});
const inputProps = {};
const outputProps = {};
const stateProps = {};
let propPointer;
Object.keys(this.directiveProperties).forEach(propName => {
propPointer = inputLabels.includes(propName)
? inputProps
: outputLabels.includes(propName)
? outputProps
: stateProps;
propPointer[propName] = this.directiveProperties[propName];
});
this._inputsDataSource.update(inputProps);
this._outputsDataSource.update(outputProps);
this._stateDataSource.update(stateProps);
this._props = newProps;
}