Commit 9ebcd5c0 authored by Tim Rogers's avatar Tim Rogers

cos-46 updated delete to remove bl:ref and i# node if no other nodes use it,...

cos-46 updated delete to remove bl:ref and i# node if no other nodes use it, updated clostest path check
parent 8f05e98c
......@@ -101,6 +101,12 @@ module.exports = function(utils){
}else if(node.toDelete){
//delete
_.set(blMaps, node.path, undefined);
//check if there are any other nodes on this bl:ref
var otherNodes = _.filter(_.get(blMaps, node.path.slice(0, -1)), 'source');
//Delete the entire bl:ref if no other nodes need it
if(_.isEmpty(otherNodes)) {
_.unset(blMaps, node.path.slice(0, 2));
}
}else if(node.modified){
//copy just the relevant data
_.set(blMaps, node.path, cloneNode());
......
......@@ -14,7 +14,11 @@ module.exports = function(utils, key, $lockButton){
var getClosestToComponentPath = function(paths) {
return _.minBy(paths, function(path) {
var pageParts = dialog.config.saveTarget.split('/');
var target = dialog.config.saveTarget;
if(!path.includes('jcr:content')) {
target = target.split('/jcr:content')[0];
}
var pageParts = target.split('/');
var pathParts = path.split('/');
return (pageParts.length > pathParts.length ? _.difference(pageParts, pathParts).length : _.difference(pathParts, pageParts).length);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment