Skip to content

Commit

Permalink
fix: Editing of subscriptions on 9.5 fails. Fix #56
Browse files Browse the repository at this point in the history
It seems that ThingWorx changed how subscriptions are modeled, so we need to read information from different fields
  • Loading branch information
stefan-lacatus committed Feb 11, 2024
1 parent 5ced477 commit 2d8d4e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/newComposerMonacoEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,13 @@ function load() {
if (this.editorType == EditorType.SERVICE_EDITOR) {
serviceDefinition = currentEditedModel.service;
} else if (this.editorType == EditorType.SUBSCRIPTION_EDITOR) {
let subscriptionFields: any[] = currentEditedModel.fieldsModel.all;
let subscriptionFields: any[];
// on ThingWorx 9.5, the data is coming from a different field, `selectedEvent`
if(currentEditedModel.fieldsModel) {
subscriptionFields = currentEditedModel.fieldsModel.all;
} else {
subscriptionFields = currentEditedModel.selectedEvent.fieldsModel.all;
}
serviceDefinition = {
parameterDefinitions: subscriptionFields.reduce(function (map, obj) {
map[obj.name] = obj;
Expand All @@ -417,8 +423,9 @@ function load() {
// now also fill out the datashape for the eventData param.
if(serviceDefinition.parameterDefinitions["eventData"]) {
const eventName = currentEditedModel.eventName;
const allEvents = currentEditedModel.eventsModel ? currentEditedModel.eventsModel.all : currentEditedModel.selectedEvent.eventsModel.all
// iterate through the event definitions
for(const event of currentEditedModel.eventsModel.all) {
for(const event of allEvents) {
if(event.name == eventName) {
serviceDefinition.parameterDefinitions["eventData"].aspects = {
dataShape: event.event.dataShape
Expand Down

0 comments on commit 2d8d4e5

Please sign in to comment.