Skip to content

Commit 4945cdc

Browse files
Fixed issue where changing values in normal authoring didn't update the JSON in advanced view if they're both being displayed. #2824
1 parent 4c048c2 commit 4945cdc

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/main/webapp/site/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class EditComponentJsonComponent {
1717
componentContentJSONString: string;
1818
@Input()
1919
componentId: string;
20+
nodeChangedSubscription: Subscription;
2021
@Input()
2122
nodeId: string;
2223
showJSONAuthoring: boolean = false;
@@ -28,9 +29,7 @@ export class EditComponentJsonComponent {
2829
}
2930

3031
ngOnInit() {
31-
const authoringComponentContent = this.ProjectService.getComponentByNodeIdAndComponentId(
32-
this.nodeId, this.componentId);
33-
this.componentContentJSONString = angular.toJson(authoringComponentContent, 4);
32+
this.setComponentContentJsonString()
3433
this.jsonChangedSubscription = this.jsonChanged
3534
.pipe(
3635
debounceTime(1000),
@@ -44,10 +43,20 @@ export class EditComponentJsonComponent {
4443
this.NotificationService.showJSONInvalidMessage();
4544
}
4645
});
46+
this.nodeChangedSubscription = this.ProjectService.nodeChanged$.subscribe(() => {
47+
this.setComponentContentJsonString();
48+
});
4749
}
4850

4951
ngOnDestory() {
5052
this.jsonChangedSubscription.unsubscribe();
53+
this.nodeChangedSubscription.unsubscribe();
54+
}
55+
56+
setComponentContentJsonString() {
57+
const authoringComponentContent = this.ProjectService.getComponentByNodeIdAndComponentId(
58+
this.nodeId, this.componentId);
59+
this.componentContentJSONString = angular.toJson(authoringComponentContent, 4);
5160
}
5261

5362
toggleJSONView(): void {

0 commit comments

Comments
 (0)