Chriztian Steinmeier
01/18/2023, 10:40 PMMike Chambers
01/23/2023, 11:02 AMjavascript
angular.module("umbraco").controller("SM.Blocks.LabelController", function ($scope, entityResource) {
var vm = this;
vm.imageUrl = null;
vm.node = { icon: "icon-application-error color-red ", name: "n/a" };
function loadImage(propertyValue) {
if (propertyValue != undefined) {
entityResource.getById(propertyValue, "Media").then(function (ent) {
vm.imageUrl = ent.metaData.MediaPath;
});
} else {
vm.imageUrl = null;
}
}
function loadNode(propertyValue) {
if (propertyValue != undefined) {
entityResource.getById(propertyValue, "Document").then(function (ent) {
vm.node = ent;
});
} else {
vm.node = { icon: "icon-application-error color-red ", name: "n/a" };
}
}
loadImage($scope.block.data.image);
loadNode($scope.block.data.housetypeName);
$scope.$watch("block.data.image", function (newValue, oldValue) {
if (newValue === oldValue) return;
loadImage(newValue);
});
$scope.$watch("block.data.housetypeName", function (newValue, oldValue) {
if (newValue === oldValue) return;
loadNode(newValue);
});
});
Mike Chambers
01/23/2023, 11:09 AM