70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
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.archetypeLabelService.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.archetypeLabelService.getEntityById(scope, value.typeData.contentId, "Document");
|
|
}
|
|
break;
|
|
|
|
case "media":
|
|
if(value.typeData.mediaId) {
|
|
entity = scope.services.archetypeLabelService.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);
|
|
}
|
|
}
|
|
})(); |