var ArchetypeSampleLabelTemplates = (function() { //public functions return { Entity: function (value, scope, args) { if(!args.entityType) { args = {entityType: "Document", propertyName: "name"} } if (value) { //if handed a csv list, take the first only var id = value.split(",")[0]; if (id) { var entity = scope.services.archetypeCacheService.getEntityById(scope, id, args.entityType); if(entity) { return entity[args.propertyName]; } } } return ""; }, UrlPicker: function(value, scope, args) { if(!args.propertyName) { args = {propertyName: "name"} } var entity; switch (value.type) { case "content": if(value.typeData.contentId) { entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document"); } break; case "media": if(value.typeData.mediaId) { entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media"); } break; case "url": return value.typeData.url; default: break; } if(entity) { return entity[args.propertyName]; } return ""; }, Rte: function (value, scope, args) { if(!args.contentLength) { args = {contentLength: 50} } return $(value).text().substring(0, args.contentLength); } } })();