Commit e3eac9a5 authored by Caleb Weeks's avatar Caleb Weeks

adding option to write stub value to additional nodes

parent 79eb6b5b
......@@ -204,7 +204,7 @@ function loadComponent(rtype, roots, widgetRegistry, hb){
widget.hbsValidName = _.map(widget.name.split('/'), (nameSegment)=>{
return /[^\w^:]/.test(nameSegment) ? '['+nameSegment +']' : nameSegment;
}).join('/');
widget.lockAllowed = widget.widget !== 'hidden';
widget.lockAllowed = widget.widget !== 'hidden' && !widget.readonly && !widget.diabled;
widget.hide_on_edit_page = widget.widget === 'hidden';
widget.wingo="bigno";
});
......
......@@ -51,6 +51,18 @@ module.exports = function restubFromBlQuery(params, cb){
var sourceMapping = querySpecification.sourceMapping;
var allowLocalChildren = querySpecification.allowLocalChildren || false;
if(querySpecification.writeStubTo){
if(!_.isArray(querySpecification.writeStubTo)){
querySpecification.writeStubTo = [querySpecification.writeStubTo];
}
querySpecification.writeStubToTransform = querySpecification.writeStubToTransform ||{
replace: '' ,
with: ''
}
}
if(!queryPath){cb("No 'bl:query' property found at path: " + path); return;}
if(!_.isArray(resourceTypes)){cb("Must be an array. Bad 'resourceTypes' value at bl:query path: " + path); return;}
if(resourceTypes.length !== targetParts.length){cb("There must be one 'resourceTypes' entry for each target child node pattern component at path: " + path); return;}
......@@ -278,6 +290,13 @@ module.exports = function restubFromBlQuery(params, cb){
allNewNodes.push({name:_path.join(curParentPath,"sling:resourceType"), value:resourceType})
}
}
if(querySpecification.writeStubTo){
_.each(querySpecification.writeStubTo ,(path) =>{
let writeToStubValue = sourcePath.replace(new RegExp(querySpecification.writeStubToTransform.replace), querySpecification.writeStubToTransform.with);
allNewNodes.push({name: pageMode ? _path.join(curTargetPath, "jcr:content", path) : _path.join(curTargetPath, path), value: writeToStubValue});
});
}
log.debug("creating:", _path.join(targetPath, curTargetPath), " of type ", resourceType);
}
......
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