Skip to content
Open
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
40 changes: 32 additions & 8 deletions modules/ui/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export function uiField(context, presetField, entityIDs, options) {
}


function allKeys() {
return field.allKeys();
function allKeys(tags) {
return field.allKeys(tags);
}


Expand All @@ -75,15 +75,23 @@ export function uiField(context, presetField, entityIDs, options) {
return entityIDs.some(function(entityID) {
var original = context.graph().base().entities[entityID];
var latest = context.graph().entity(entityID);
return allKeys().some(function(key) {
return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
});
if (original) {
var originalKeys = allKeys(original.tags);
var latestKeys = allKeys(_tags);
return latestKeys.concat(originalKeys).some(function (key) {
return latest.tags[key] !== original.tags[key];
});
} else {
return allKeys(_tags).some(function (key) {
return !!latest.tags[key];
});
}
});
}


function tagsContainFieldKey() {
return allKeys().some(function(key) {
return allKeys(_tags).some(function(key) {
if (field.type === 'multiCombo') {
for (var tagKey in _tags) {
if (tagKey.indexOf(key) === 0) {
Expand Down Expand Up @@ -111,7 +119,23 @@ export function uiField(context, presetField, entityIDs, options) {
d3_event.preventDefault();
if (!entityIDs || _locked) return;

dispatch.call('revert', d, allKeys());
let keys = allKeys(_tags);

if (entityIDs) {
for (let i = 0; i < entityIDs.length; i++) {
const entityID = entityIDs[i];
const original = context.graph().base().entities[entityID];
if (original) {
allKeys(original.tags).forEach(function(key) {
if (keys.indexOf(key) === -1) {
keys.push(key);
}
});
}
}
}

dispatch.call('revert', d, keys);
}


Expand All @@ -121,7 +145,7 @@ export function uiField(context, presetField, entityIDs, options) {
if (_locked) return;

var t = {};
allKeys().forEach(function(key) {
allKeys(_tags).forEach(function(key) {
t[key] = undefined;
});

Expand Down
Loading