Skip to content

Commit

Permalink
Create an issue key property that changes when data needs refresh
Browse files Browse the repository at this point in the history
(closes #8655)
  • Loading branch information
bhousel committed Aug 27, 2021
1 parent 81b7e28 commit 9e3df2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions modules/core/validation/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function validationIssue(attrs) {
this.hash = attrs.hash; // optional - string to further differentiate the issue

this.id = generateID.apply(this); // generated - see below
this.key = generateKey.apply(this); // generated - see below (call after generating this.id)
this.autoFix = null; // generated - if autofix exists, will be set below

// A unique, deterministic string hash.
Expand All @@ -39,6 +40,13 @@ export function validationIssue(attrs) {
return parts.join(':');
}

// An identifier suitable for use as the second argument to d3.selection#data().
// (i.e. this should change whenever the data needs to be refreshed)
function generateKey() {
return this.id + ':' + Date.now().toString(); // include time of creation
}


this.extent = function(resolver) {
if (this.loc) {
return geoExtent(this.loc);
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/commit_warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function uiCommitWarnings(context) {


var items = container.select('ul').selectAll('li')
.data(issues, function(d) { return d.id; });
.data(issues, function(d) { return d.key; });

items.exit()
.remove();
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/sections/entity_issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function uiSectionEntityIssues(context) {
_activeIssueID = _issues.length > 0 ? _issues[0].id : null;

var containers = selection.selectAll('.issue-container')
.data(_issues, function(d) { return d.id; });
.data(_issues, function(d) { return d.key; });

// Exit
containers.exit()
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/sections/validation_issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function uiSectionValidationIssues(id, severity, context) {


var items = list.selectAll('li')
.data(issues, function(d) { return d.id; });
.data(issues, function(d) { return d.key; });

// Exit
items.exit()
Expand Down

0 comments on commit 9e3df2c

Please sign in to comment.