52 lines
2.7 KiB
JavaScript
52 lines
2.7 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('feedModule')
|
|
.directive('entityProfileLink', ['$filter', 'pwaModel', 'configurationModel', function ($filter, pwaModel, configurationModel) {
|
|
return {
|
|
restrict: 'A',
|
|
scope: {
|
|
entityData: '=entityProfileLink'
|
|
},
|
|
link: function (scope, iElement) {
|
|
if (!scope.entityData) {
|
|
console.log('No information about entity');
|
|
}
|
|
else {
|
|
if (scope.entityData.type && scope.entityData.type === 'changerequest') {
|
|
scope.entityData.type = 'change';
|
|
}
|
|
var entityLink = scope.entityData.entityLink, type = scope.entityData.type;
|
|
if (_.includes(scope.entityData.entityLink, '/asset/')) {
|
|
type = 'asset';
|
|
}
|
|
if (pwaModel.isPwaEnabled() && configurationModel.get('pwaEnabledTickets.tickets').indexOf(type) >= 0) {
|
|
type = type + 'PV';
|
|
}
|
|
if (_.includes(scope.entityData.entityLink, 'asset') && !scope.entityData.loginId) {
|
|
var assetId, classId;
|
|
if (scope.entityData.reconciliationId || scope.entityData.id) {
|
|
assetId = $filter('escape')(scope.entityData.reconciliationId || scope.entityData.id);
|
|
classId = scope.entityData.classId || scope.entityData.realObject.classId;
|
|
entityLink = '#/' + type + '/' + assetId + '/' + classId;
|
|
}
|
|
else if (scope.entityData.realObject.reconciliationId) {
|
|
assetId = $filter('escape')(scope.entityData.realObject.reconciliationId);
|
|
entityLink = '#/' + type + '/' + assetId + '/' + scope.entityData.realObject.classId;
|
|
}
|
|
}
|
|
if (!scope.entityData.entityLink && scope.entityData.id) {
|
|
entityLink = '#/' + type + '/' + encodeURIComponent(scope.entityData.id.replace(/\\\\/g, '\\'));
|
|
}
|
|
if (!iElement.attr('href')) {
|
|
if (pwaModel.isPwaEnabled()) {
|
|
entityLink = entityLink.replace("/person/", "/personPV/");
|
|
}
|
|
iElement.attr('href', entityLink);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}]);
|
|
}());
|