mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-29 11:21:40 +02:00
Optionally include ids members of modified relations in extantIDs
(closes #6273)
This commit is contained in:
@@ -73,14 +73,30 @@ export function coreDifference(base, head) {
|
||||
_diff.didChange = _didChange;
|
||||
|
||||
|
||||
_diff.extantIDs = function extantIDs() {
|
||||
var result = [];
|
||||
// pass true to include affected relation members
|
||||
_diff.extantIDs = function extantIDs(includeRelMembers) {
|
||||
var result = new Set();
|
||||
Object.keys(_changes).forEach(function(id) {
|
||||
if (_changes[id].head) {
|
||||
result.push(id);
|
||||
result.add(id);
|
||||
}
|
||||
|
||||
var h = _changes[id].head;
|
||||
var b = _changes[id].base;
|
||||
var entity = h || b;
|
||||
|
||||
if (includeRelMembers && entity.type === 'relation') {
|
||||
var mh = h ? h.members.map(function(m) { return m.id; }) : [];
|
||||
var mb = b ? b.members.map(function(m) { return m.id; }) : [];
|
||||
utilArrayUnion(mh, mb).forEach(function(memberID) {
|
||||
if (head.hasEntity(memberID)) {
|
||||
result.add(memberID);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
return Array.from(result);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user