Create an issue key property that changes when data needs refresh

(closes #8655)
This commit is contained in:
Bryan Housel
2021-08-26 16:04:51 -04:00
parent 81b7e282c3
commit 9e3df2c4aa
4 changed files with 11 additions and 3 deletions
+8
View File
@@ -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.
@@ -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);
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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()