Skip to content

Commit

Permalink
Wait for dataPackage to sync before rendering the packageTable
Browse files Browse the repository at this point in the history
Reference #1451 #2080 #2081
  • Loading branch information
rushirajnenuji committed Jan 10, 2023
1 parent 0fb293f commit 9dd70d1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/js/views/MetadataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ define(['jquery',
model: new SolrResult(),
packageModels: new Array(),
dataPackage: null,
dataPackageSynced: false,
el: '#Content',
metadataContainer: "#metadata-container",
citationContainer: "#citation-container",
Expand Down Expand Up @@ -175,6 +176,8 @@ define(['jquery',
}

this.listenToOnce(this.dataPackage, "complete", function () {
this.dataPackageSynced = true;
this.trigger("changed:dataPackageSynced");
var dataPackageView = _.findWhere(this.subviews, { type: "DataPackage" });
if (dataPackageView) {
dataPackageView.dataPackageCollection = this.dataPackage;
Expand Down Expand Up @@ -836,6 +839,13 @@ define(['jquery',
},

insertPackageTable: function (packageModel, options) {
var view = this;
if (!this.dataPackageSynced) {
this.on("changed:dataPackageSynced", function(){
view.insertPackageTable(packageModel, options);
});
return;
}
var viewRef = this;

if (options) {
Expand All @@ -850,7 +860,7 @@ define(['jquery',
//** Draw the package table **//
var tableView = new DataPackageView({
edit: false,
dataPackage: MetacatUI.dataPackage,
dataPackage: this.dataPackage,
model: packageModel,
currentlyViewing: this.pid,
parentView: this,
Expand Down

0 comments on commit 9dd70d1

Please sign in to comment.