Skip to content

Fix the variable tables that's related to WRC changes. #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions webui/src/js/viewModels/model-design-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,39 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, ViewMod
};

// Triggered when changes have been downloaded from the WRC backend, for the active WDT Model File provider.
//
this.changesAutoDownloaded = (event) => {
function filterOriginalModelProperties(array1, array2){
return array1.filter(c => array2.findIndex(x=>x.uid == c.uid) > -1)
}

wktLogger.debug('Received changesAutoDownloaded event with modelContent = %s', event.detail.value);
this.wrcBackendTriggerChange = true;
this.project.wdtModel.modelContent(event.detail.value);
if (event.detail.properties) {
const existingProperties = this.project.wdtModel.getModelPropertiesObject().observable();
// Model properties initially passed to WRC was a deep copy
// created using the spread operator. event.detail.properties
// contains what the model properties need to be now, which
// may in fact result in the removal of some of the original
// ones passed to the WRC.
const existingProperties = filterOriginalModelProperties(
this.project.wdtModel.getModelPropertiesObject().observable(),
event.detail.properties
);
this.project.wdtModel.getModelPropertiesObject().observable(existingProperties);
event.detail.properties.forEach((item) => {
// Get index of existing property that matches property coming
// from “Design View”
const index = existingProperties.map(item1 => item1.uid).indexOf(item.uid);
if (index === -1) {
// Must call addNewItem() in order to get remove() function added
// Didn’t find a match, so we need to call addNewItem() in order
// to get the remove() function added to the property coming from “Design View”
this.project.wdtModel.getModelPropertiesObject().addNewItem({uid: item.uid, Name: item.Name, Value: item.Value});
}
else {
// Update existing properties with data from "Design View"
// Found a match, so we just need to update existing properties
// with data coming from “Design View”. The uid of the existing
// property will be the same, but “Design View” could have made
// both the Name and Value different.
existingProperties[index].Name = item.Name;
existingProperties[index].Value = item.Value;
}
Expand Down