SmartIT_Extensions/BMC/smart-it-full-helix/scripts/app/change/risk-level-badge-directive.js

34 lines
1.2 KiB
JavaScript

"use strict";
(function () {
'use strict';
angular
.module('changeModule')
.directive('riskLevelBadge', ['metadataModel',
function (metadataModel) {
return {
restrict: 'E',
replace: true,
templateUrl: 'views/change/risk-level-badge.html',
scope: {
riskLevel: '='
},
link: function (scope) {
scope.metadata = {};
scope.riskLevelCls = function () {
var index = _.findIndex(scope.metadata.riskLevels, function (item) {
return item.name === scope.riskLevel;
});
return 'ticket__risk-level-' + (index + 1);
};
function loadMetadata() {
metadataModel.getMetadataByType(EntityVO.TYPE_CHANGE).then(function (metadata) {
angular.extend(scope.metadata, metadata);
});
}
loadMetadata();
}
};
}
]);
})();