Skip to content

Commit

Permalink
Merge branch 'master' into 188129114-bar-graph-select
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoldowsky authored Sep 17, 2024
2 parents 8e73250 + 7a65c8c commit 6a918e6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 0 additions & 1 deletion cypress/e2e/functional/tile_tests/bar_graph_tile_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ context('Bar Graph Tile', function () {
barGraph.getBarHighlight(workspace).should('have.length', 0);
tableTile.getSelectedRow(workspace).should('have.length', 0); // All "XX / Y" cases
}

});

});
33 changes: 33 additions & 0 deletions src/plugins/bar-graph/bar-graph-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,39 @@ export const BarGraphContentModel = TileContentModel
}
},

updateAfterSharedModelChanges(sharedModel?: SharedModelType) {

Check warning on line 176 in src/plugins/bar-graph/bar-graph-content.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/bar-graph/bar-graph-content.ts#L176

Added line #L176 was not covered by tests
// When new dataset is attached, store its ID and pick a primary attribute to display.
const dataSetId = self.sharedModel?.dataSet?.id;
if (self.dataSetId !== dataSetId) {
self.dataSetId = dataSetId;
self.setPrimaryAttribute(undefined);
self.setSecondaryAttribute(undefined);

Check warning on line 182 in src/plugins/bar-graph/bar-graph-content.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/bar-graph/bar-graph-content.ts#L180-L182

Added lines #L180 - L182 were not covered by tests
if (dataSetId) {
const atts = self.sharedModel.dataSet.attributes;

Check warning on line 184 in src/plugins/bar-graph/bar-graph-content.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/bar-graph/bar-graph-content.ts#L184

Added line #L184 was not covered by tests
if (atts.length > 0) {
self.setPrimaryAttribute(atts[0].id);

Check warning on line 186 in src/plugins/bar-graph/bar-graph-content.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/bar-graph/bar-graph-content.ts#L186

Added line #L186 was not covered by tests
}
}
}
// Check if primary or secondary attribute has been deleted
if (self.primaryAttribute && !self.sharedModel?.dataSet.attrFromID(self.primaryAttribute)) {
self.setPrimaryAttribute(undefined); // this will also unset secondaryAttribute

Check warning on line 192 in src/plugins/bar-graph/bar-graph-content.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/bar-graph/bar-graph-content.ts#L192

Added line #L192 was not covered by tests
}
if (self.secondaryAttribute && !self.sharedModel?.dataSet.attrFromID(self.secondaryAttribute)) {
self.setSecondaryAttribute(undefined);

Check warning on line 195 in src/plugins/bar-graph/bar-graph-content.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/bar-graph/bar-graph-content.ts#L195

Added line #L195 was not covered by tests
}
}
}))
.actions(self => ({
unlinkDataSet() {
const smm = getSharedModelManager(self);
if (!smm || !smm.isReady) return;
const sharedDataSets = smm.getTileSharedModelsByType(self, SharedDataSet);
for (const sharedDataSet of sharedDataSets) {
smm.removeTileSharedModel(self, sharedDataSet);
}
},

updateAfterSharedModelChanges(sharedModel?: SharedModelType) {
// When new dataset is attached, store its ID and pick a primary attribute to display.
const dataSetId = self.sharedModel?.dataSet?.id;
Expand Down

0 comments on commit 6a918e6

Please sign in to comment.