ResourceCollectionUtils.js revision 90929d4c6b284dd318f4a78c2aa407afb7423747
/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2011-2015 ForgeRock AS.
*/
/*global define */
/*jslint evil:true */
"jquery",
"underscore",
"handlebars",
var obj = {};
obj.resourceCollectionCache = {};
var pathToResource = (prop.items) ? prop.items.resourceCollection[resourceCollectionIndex].path : prop.resourceCollection[resourceCollectionIndex].path,
}),
return eval("item." + p);
}
return txt;
};
var fields = (prop.items) ? prop.items.resourceCollection[resourceCollectionIndex].query.fields : prop.resourceCollection[resourceCollectionIndex].query.fields;
if(showRaw) {
return fields;
} else {
});
}
};
obj.setupAutocompleteField = function(autocompleteField, prop, opts, resourceCollectionIndex, propertyValue) {
var pathToResource = (prop.items) ? prop.items.resourceCollection[resourceCollectionIndex].path : prop.resourceCollection[resourceCollectionIndex].path,
initialLoad = true,
defaultOpts = {
valueField: '_id',
create: false,
preload: true,
render: {
},
}
},
searchDelegate.searchResults(pathToResource, obj.autocompleteProps(prop, resourceCollectionIndex, true), query).then(function(result) {
var convertNestedProps = function(item) {
}
});
return item;
},
return convertNestedProps(item);
});
if (prop.parentObjectId) {
//filter out any values that are the same as the parentObjectId
modifiedResult = _.reject(modifiedResult, function (mr) { return mr._id === prop.parentObjectId; });
}
},
function(){
callback();
}
);
},
this.addOption(propertyValue);
initialLoad = false;
}
}
};
}
};
var propField = function() {
};
} else {
return field;
}
});
};
}
};
/**
* convertRelationshipTypes loops over every property looking for
* arrays of relationship types or single value relationship types
* once found the type is converted to "string" for jsonEditor and the
* typeRelationship flag is set to true
*
* this function is recursive...when a property is an object the function
* calls itself to deal with cases where relationship types are nested
*
* @param {Object[]} properties
* @returns {Object[]}
*/
}
}
}
prop.typeRelationship = true;
}
});
return properties;
};
/**
* getFieldsToExpand loops over every property looking for single value relationship types
* once found a string of a list of properties defined in the resourceCollection.query.fields property
* is constructed for the use in the _fields parameter of a query url
*
* this function is recursive...when a property is an object the function
* calls itself to deal with cases where relationship types are nested
*
* @param {Object[]} properties
* @returns {String}
*/
var fieldsArray = ["*"],
}
});
};
}
});
}
}
});
};
/**
* takes in a relationship object, turns the _ref property into an array,
* drops off the last array item (the _id of the object), and returns
* just the path to the resource collection it comes from
*
*
*
* @param {Object} propertyValue
* @returns {string}
*/
};
/**
* finds the index of the resource collection in a relationship property's schema definition
* based on the resource collection's path
*
* @param {Object} schema
* @param {Object} propertyValue
* @param {string} propName
* @returns {int}
*/
}
}, this));
if (resourceCollectionIndex === -1) {
}
return resourceCollectionIndex;
};
});
return obj;
});