Skip to content

Commit 231bd3c

Browse files
Fix the variable tables that's related to WRC changes. (#138)
* Fix the variable tables that's related to WRC changes. * update wrc-jet-pack Co-authored-by: Robert Patrick <robert.patrick@oracle.com>
1 parent 5685276 commit 231bd3c

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

webui/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/src/js/viewModels/model-design-view.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,39 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, ViewMod
164164
};
165165

166166
// Triggered when changes have been downloaded from the WRC backend, for the active WDT Model File provider.
167-
//
168167
this.changesAutoDownloaded = (event) => {
168+
function filterOriginalModelProperties(array1, array2){
169+
return array1.filter(c => array2.findIndex(x=>x.uid == c.uid) > -1)
170+
}
171+
169172
wktLogger.debug('Received changesAutoDownloaded event with modelContent = %s', event.detail.value);
170173
this.wrcBackendTriggerChange = true;
171174
this.project.wdtModel.modelContent(event.detail.value);
172175
if (event.detail.properties) {
173-
const existingProperties = this.project.wdtModel.getModelPropertiesObject().observable();
176+
// Model properties initially passed to WRC was a deep copy
177+
// created using the spread operator. event.detail.properties
178+
// contains what the model properties need to be now, which
179+
// may in fact result in the removal of some of the original
180+
// ones passed to the WRC.
181+
const existingProperties = filterOriginalModelProperties(
182+
this.project.wdtModel.getModelPropertiesObject().observable(),
183+
event.detail.properties
184+
);
185+
this.project.wdtModel.getModelPropertiesObject().observable(existingProperties);
174186
event.detail.properties.forEach((item) => {
187+
// Get index of existing property that matches property coming
188+
// from “Design View”
175189
const index = existingProperties.map(item1 => item1.uid).indexOf(item.uid);
176190
if (index === -1) {
177-
// Must call addNewItem() in order to get remove() function added
191+
// Didn’t find a match, so we need to call addNewItem() in order
192+
// to get the remove() function added to the property coming from “Design View”
178193
this.project.wdtModel.getModelPropertiesObject().addNewItem({uid: item.uid, Name: item.Name, Value: item.Value});
179194
}
180195
else {
181-
// Update existing properties with data from "Design View"
196+
// Found a match, so we just need to update existing properties
197+
// with data coming from “Design View”. The uid of the existing
198+
// property will be the same, but “Design View” could have made
199+
// both the Name and Value different.
182200
existingProperties[index].Name = item.Name;
183201
existingProperties[index].Value = item.Value;
184202
}

0 commit comments

Comments
 (0)