181 lines
7.4 KiB
JavaScript
181 lines
7.4 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Created by igor.samulenko on 3/6/14.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
angular.module('myitsmApp')
|
|
.directive('timelineItemRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
item: '=',
|
|
type: '=',
|
|
parentContext: '=',
|
|
isUnflagEditAllowed: '=',
|
|
showContext: '&',
|
|
expandItem: '&',
|
|
handleLikeClick: '&',
|
|
handleAttachmentClick: '&',
|
|
saveNote: '&'
|
|
},
|
|
templateUrl: 'views/feed/timeline-item-renderer.html',
|
|
link: function (scope) {
|
|
scope.isActivityForKA = function () {
|
|
return scope.type === EntityVO.TYPE_KNOWLEDGE;
|
|
};
|
|
}
|
|
};
|
|
}).directive('feedItemRenderer', ['$sce', function ($sce) {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
item: '=',
|
|
handleAttachmentClick: '&',
|
|
handleUnpinClick: '&'
|
|
},
|
|
templateUrl: 'views/feed/feed-item-renderer.html',
|
|
link: function (scope) {
|
|
scope.titleRegExp = new RegExp(/.{1,5}/g);
|
|
scope.safeHtml = function (htmlString) {
|
|
return $sce.trustAsHtml(htmlString);
|
|
};
|
|
}
|
|
};
|
|
}]).directive('responseItemRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
item: '='
|
|
},
|
|
templateUrl: 'views/feed/response-item-renderer.html'
|
|
};
|
|
}).directive('personTicketRenderer', ['$state', 'events', '$window', function ($state, events, $window) {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
data: '=',
|
|
selectedChat: '=',
|
|
setStyle: '='
|
|
},
|
|
templateUrl: 'views/person/person-ticket-renderer.html',
|
|
link: function (scope) {
|
|
scope.showRelateToChat = scope.selectedChat && scope.selectedChat.status === 'Assigned' &&
|
|
(!scope.selectedChat.ticket || (scope.selectedChat.ticket && !scope.selectedChat.ticket.ticketId)) &&
|
|
(_.includes(scope.selectedChat.allowedTicketTypes, scope.data.type)) &&
|
|
(scope.data.type === EntityVO.TYPE_INCIDENT || scope.data.type === EntityVO.TYPE_WORKORDER);
|
|
scope.showUnRelateToChat = scope.selectedChat && (scope.selectedChat.status === 'Assigned') &&
|
|
scope.selectedChat.ticket && scope.selectedChat.ticket.ticketDisplayId &&
|
|
scope.selectedChat.applicationData && scope.selectedChat.applicationData.ticketAssociationDetails &&
|
|
scope.selectedChat.applicationData.ticketAssociationDetails.displayId &&
|
|
(scope.selectedChat.ticket.ticketDisplayId === scope.data.displayId);
|
|
scope.showProfileDetails = function (item, type, $event) {
|
|
if ('href' in $event.target) {
|
|
if (scope.selectedChat && $event.target.href !== 'javascript:void(0)') {
|
|
$event.target.target = '_blank';
|
|
}
|
|
return;
|
|
}
|
|
switch (type) {
|
|
case EntityVO.TYPE_TICKET:
|
|
if (scope.selectedChat) {
|
|
var url = $state.href(item.type, { id: item.id });
|
|
$window.open(url, '_blank');
|
|
}
|
|
else {
|
|
$state.go(item.type, { id: item.id });
|
|
}
|
|
break;
|
|
case EntityVO.TYPE_ASSET:
|
|
$state.go(type, { assetId: item.reconciliationId, assetClassId: item.classId });
|
|
break;
|
|
case EntityVO.TYPE_KNOWLEDGE:
|
|
$state.go(type, { id: item.uuid });
|
|
break;
|
|
}
|
|
};
|
|
scope.relateTicketToChat = function (ticket) {
|
|
scope.$emit(events.RELATE_TICKET_TO_CHAT, { chat: scope.selectedChat, ticket: ticket });
|
|
};
|
|
scope.unrelateTicketToChat = function (ticket) {
|
|
scope.$emit(events.UNRELATE_TICKET_TO_CHAT, { chat: scope.selectedChat, ticket: ticket });
|
|
};
|
|
}
|
|
};
|
|
}]).directive('personAssetRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
data: '='
|
|
},
|
|
templateUrl: 'views/person/person-asset-renderer.html'
|
|
};
|
|
}).directive('personSupportGroupRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
data: '='
|
|
},
|
|
templateUrl: 'views/person/person-support-group-renderer.html'
|
|
};
|
|
}).directive('personKnowledgeRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
data: '='
|
|
},
|
|
templateUrl: 'views/person/person-knowledge-renderer.html'
|
|
};
|
|
}).directive('personAssetWithCheckboxRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
data: '=',
|
|
showItemDetails: '&',
|
|
selectAssetItem: '&',
|
|
savedTemplate: '='
|
|
},
|
|
templateUrl: 'views/person/person-asset-with-checkbox-renderer.html'
|
|
};
|
|
}).directive('assetPersonRenderer', function () {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
scope: {
|
|
data: '=',
|
|
isPeopleType: '&',
|
|
removePeople: '&',
|
|
showPersonDetails: '&',
|
|
editModeAllowed: '@'
|
|
},
|
|
templateUrl: 'views/asset/asset-person-renderer.html',
|
|
link: function (scope) {
|
|
scope.displayValue;
|
|
if (scope.data.realObject.reqType === 'supportgroup') {
|
|
scope.displayValue = scope.data.realObject.supportGroupName;
|
|
}
|
|
else if (scope.data.realObject.reqType === 'organization') {
|
|
scope.displayValue = scope.data.realObject.organizationName;
|
|
}
|
|
else if (scope.data.realObject.reqType === 'department') {
|
|
scope.displayValue = scope.data.realObject.departmentName;
|
|
}
|
|
else if (scope.data.realObject.reqType === 'company') {
|
|
scope.displayValue = scope.data.realObject.companyContactName;
|
|
}
|
|
else {
|
|
scope.displayValue = scope.data.realObject.fullName;
|
|
}
|
|
}
|
|
};
|
|
});
|
|
}());
|