2015-06-01 12:12:33 -04:00
|
|
|
var ArchetypeSampleLabelTemplates = (function() {
|
2014-08-12 17:15:16 -04:00
|
|
|
|
2015-05-27 13:31:25 -04:00
|
|
|
//public functions
|
2014-08-12 17:15:16 -04:00
|
|
|
return {
|
2015-05-29 08:55:08 -04:00
|
|
|
Entity: function (value, scope, args) {
|
2015-05-27 13:31:25 -04:00
|
|
|
|
2015-05-27 13:47:23 -04:00
|
|
|
if(!args.entityType) {
|
2015-05-27 13:31:25 -04:00
|
|
|
args = {entityType: "Document", propertyName: "name"}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 17:15:16 -04:00
|
|
|
if (value) {
|
2015-05-27 13:31:25 -04:00
|
|
|
//if handed a csv list, take the first only
|
2014-08-12 17:15:16 -04:00
|
|
|
var id = value.split(",")[0];
|
|
|
|
|
|
|
|
|
|
if (id) {
|
2015-06-01 10:02:32 -04:00
|
|
|
var entity = scope.services.archetypeLabelService.getEntityById(scope, id, args.entityType);
|
2015-05-27 13:41:58 -04:00
|
|
|
|
|
|
|
|
if(entity) {
|
|
|
|
|
return entity[args.propertyName];
|
|
|
|
|
}
|
2014-08-12 17:15:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-27 13:31:25 -04:00
|
|
|
return "";
|
|
|
|
|
},
|
2015-05-27 13:47:23 -04:00
|
|
|
UrlPicker: function(value, scope, args) {
|
2015-05-27 13:31:25 -04:00
|
|
|
|
2015-05-27 13:47:23 -04:00
|
|
|
if(!args.propertyName) {
|
2015-05-27 13:31:25 -04:00
|
|
|
args = {propertyName: "name"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entity;
|
|
|
|
|
|
|
|
|
|
switch (value.type) {
|
|
|
|
|
case "content":
|
|
|
|
|
if(value.typeData.contentId) {
|
2015-06-01 10:02:32 -04:00
|
|
|
entity = scope.services.archetypeLabelService.getEntityById(scope, value.typeData.contentId, "Document");
|
2015-05-27 13:31:25 -04:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "media":
|
|
|
|
|
if(value.typeData.mediaId) {
|
2015-06-01 10:02:32 -04:00
|
|
|
entity = scope.services.archetypeLabelService.getEntityById(scope, value.typeData.mediaId, "Media");
|
2015-05-27 13:31:25 -04:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "url":
|
|
|
|
|
return value.typeData.url;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(entity) {
|
|
|
|
|
return entity[args.propertyName];
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 17:15:16 -04:00
|
|
|
return "";
|
2015-05-27 13:56:33 -04:00
|
|
|
},
|
|
|
|
|
Rte: function (value, scope, args) {
|
|
|
|
|
|
|
|
|
|
if(!args.contentLength) {
|
|
|
|
|
args = {contentLength: 50}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $(value).text().substring(0, args.contentLength);
|
2014-08-12 17:15:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})();
|