SmartIT_Extensions/BMC/smart-it-full/scripts/app/common/related-item-list-directive.js

692 lines
44 KiB
JavaScript

"use strict";
(function () {
'use strict';
angular.module('myitsmApp')
.directive('relatedItemList', ['ticketModel', 'relationModel', 'relationService', '$filter', 'configurationModel',
'$state', '$modal', 'systemAlertService', 'events', 'roles', 'permissionModel', 'ciExplorerModel', 'metadataModel',
function (ticketModel, relationModel, relationService, $filter, configurationModel, $state, $modal, systemAlertService, events, roles, permissionModel, ciExplorerModel, metadataModel) {
return {
restrict: 'E',
replace: true,
templateUrl: 'views/common/related-item-list.html',
scope: {
dependency: '@',
context: '=',
isDraft: '=',
relationCounters: '='
},
link: function (scope) {
var parentFilter = 'parent', childFilter = 'child', impactFilter = 'impact', showAffectedServiceRelation = false, globalMetadataPromise = metadataModel.getMetadataByType(EntityVO.TYPE_GLOBAL), relatedItemsWatcherUnregister, refreshRelatedItemsListUnsubscribe;
scope.relatedItems = [];
scope.ciExplorerModel = ciExplorerModel;
// Watch by relation (no , true option). relatedItems should be changed explicitly (scope.relatedItems = newRelateItems)
relatedItemsWatcherUnregister = scope.$watch('relatedItems', function () {
if (scope.relatedItems.length && scope.relatedItems.length > 0) {
scope.relatedItemGroups = ticketModel.groupRelatedItems(scope.relatedItems);
}
else {
scope.relatedItemGroups = [];
}
if (scope.relationCounters) {
scope.relationCounters.linkedItems = scope.relatedItems.length;
}
});
scope.state = {
loadingRelatedItems: false
};
scope.getContextType = function () {
return scope.context.ticketType || scope.context.type;
};
scope.factory = (function () {
var factory = {
addAllowed: scope.context.accessMappings.relationsEditAllowed,
removeAllowed: scope.context.accessMappings.relationsEditAllowed,
createRelationAllowed: scope.context.accessMappings.relationsEditAllowed
&& _.contains([EntityVO.TYPE_INCIDENT, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_CHANGE, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_KNOWNERROR, EntityVO.TYPE_ASSET], scope.context.ticketType || scope.context.type)
};
var itemId = scope.context.id;
var itemType = scope.getContextType();
switch (scope.dependency) {
case 'asset-to-tickets':
scope.filterConfig = $filter('filter')(configurationModel.get('asset.filter'), { type: 'ticketTypes' });
scope.filterTypes = _.map(scope.filterConfig, 'name');
var parentId = scope.context.reconciliationId;
factory.backdrop = 'custom';
factory.load = function () {
scope.state.loadingRelatedItems = true;
relationModel.getRelations(parentId, itemType).then(function (relations) {
scope.relatedItems = _.chain(relations)
.reject({ type: EntityVO.TYPE_ASSET })
.filter(function (relatedItem) {
return relatedItem.type === EntityVO.TYPE_TASK || relatedItem.tag === RelationItemVO.TAG_LINKEDITEM;
})
.filter(function (relatedItem) {
if (!scope.filterTypes.length) {
return true;
}
else {
return _.includes(scope.filterTypes, relatedItem.type);
}
}).value();
}).finally(function () {
scope.state.loadingRelatedItems = false;
});
};
factory.refresh = function () {
factory.load();
};
factory.remove = function (relatedItem) {
var parent = { parentType: scope.getContextType(), parentId: parentId };
var relation = {
id: relatedItem.id,
type: relatedItem.type,
tag: relatedItem.tag,
relationshipType: relatedItem.relationshipType
};
relationModel.removeRelation(parent, [relation]).then(function () {
// immutable method, to change .relateItems link -> will trigger scope.$watch
scope.relatedItems = _.reject(scope.relatedItems, function (item) {
return item === relatedItem;
});
});
};
factory.applyFilter = function (filterOption) {
//todo: maybe filters should not reload a list, they should filter existing list???
filterOption.selected = !filterOption.selected;
if (filterOption.selected) {
scope.filterTypes.push(filterOption.name);
}
else {
scope.filterTypes.splice(scope.filterTypes.indexOf(filterOption.name), 1);
}
//todo: super anti-pattern, should work via refresh relations
delete relationModel.cache[parentId];
scope.factory.load();
};
factory.selectAllFilters = function (state, skipLoad) {
scope.filterTypes = [];
if (state) {
scope.filterTypes = _.map(scope.filterConfig, 'name');
}
_.forEach(scope.filterConfig, function (filterOption) {
filterOption.selected = state;
});
if (!skipLoad) {
delete relationModel.cache[parentId];
scope.factory.load();
}
};
factory.cleanUp = function () {
};
break;
case 'asset-to-assets':
factory.addAllowed = scope.context.accessMappings.assetrelationsEditAllowed;
factory.removeAllowed = scope.context.accessMappings.assetrelationsEditAllowed;
factory.createRelationAllowed = scope.context.accessMappings.assetrelationsEditAllowed;
var criteria = [];
parentId = scope.context.reconciliationId;
scope.filterConfig = $filter('filter')(configurationModel.get('asset.filter'), { type: 'assetTypes' });
var assetToAssetNewRelationsUnsubscribe = scope.$on('new-relations', function () {
delete relationModel.cache[parentId];
scope.factory.refresh();
});
factory.load = function () {
scope.state.loadingRelatedItems = true;
relationModel.getRelations(parentId, itemType).then(function (relations) {
scope.relatedItems = _.chain(relations)
.filter({ type: EntityVO.TYPE_ASSET })
.filter(function (relatedItem) {
if (!criteria.length) {
return true;
}
else {
var itemCriteria = [];
if (relatedItem.realObject.isParent) {
itemCriteria.push(parentFilter);
}
if (relatedItem.realObject.isChild) {
itemCriteria.push(childFilter);
}
if (relatedItem.realObject.hasImpact) {
itemCriteria.push(impactFilter);
}
return _.intersection(criteria, itemCriteria).length > 0;
}
}).value();
}).finally(function () {
scope.state.loadingRelatedItems = false;
});
};
factory.refresh = function () {
factory.load();
};
factory.remove = function (relatedItem) {
var parent = { parentType: scope.getContextType(), parentId: scope.context.reconciliationId };
var relation = {
type: relatedItem.type,
desc: "COMPONENT",
relationshipType: relatedItem.relationshipClassId,
parentId: scope.context.instanceId,
id: relatedItem.realObject.instanceId
};
if (relatedItem.realObject.isParent) {
//parent.parentId = relatedItem.realObject.reconciliationId;
relation.parentId = relatedItem.realObject.instanceId;
relation.id = scope.context.instanceId;
}
relationModel.removeRelation(parent, [relation]).then(function () {
scope.factory.refresh();
});
};
factory.applyFilter = function (filterOption) {
filterOption.selected = !filterOption.selected;
if (filterOption.selected) {
criteria.push(filterOption.name);
}
else {
criteria.splice(criteria.indexOf(filterOption.name), 1);
}
scope.factory.load();
};
factory.selectAllFilters = function (state, skipLoad) {
criteria = state ? [parentFilter, childFilter, impactFilter] : [];
_.forEach(scope.filterConfig, function (filterOption) {
filterOption.selected = state;
});
if (!skipLoad) {
scope.factory.load();
}
};
factory.cleanUp = function () {
assetToAssetNewRelationsUnsubscribe();
};
break;
case 'change-to-cis':
case 'ticket-to-all':
var relationWatcherUnregister = angular.noop; // if not defined
scope.relations = relationModel.cache;
factory.load = function () {
if (itemId && !scope.isDraft) {
scope.state.loadingRelatedItems = true;
relationModel.getRelations(itemId, itemType).finally(function () {
scope.state.loadingRelatedItems = false;
});
}
};
factory.backdrop = 'custom';
factory.refresh = function () {
scope.state.loadingRelatedItems = true;
return relationModel.refreshRelations(itemId, itemType).finally(function () {
scope.$emit(events.RELATIONS_UPDATE_COMPLETE, false);
scope.state.loadingRelatedItems = false;
});
};
factory.remove = function (relatedItem) {
var parent = { parentType: scope.context.type, parentId: scope.context.id }, relation = {
id: relatedItem.id,
type: relatedItem.type,
relationshipType: relatedItem.relationshipType
};
if (relatedItem.type === EntityVO.TYPE_OUTAGE) {
relation.id = relatedItem.displayId;
}
scope.relations[scope.context.id].splice(_.findIndex(scope.relations[scope.context.id], { id: relatedItem.id }), 1);
if (relatedItem.relationshipType === EntityVO.TYPE_ORIGINALOF
&& !(_.where(scope.relations[scope.context.id], { relationshipType: EntityVO.TYPE_ORIGINALOF })).length) {
scope.context.accessMappings.duplicateActionAllowed = true;
}
scope.relations.relationsRefreshInProgress = true;
relationService.removeRelation(parent, [relation]).then(function () {
if (scope.dependency === 'change-to-cis') {
scope.$emit(events.LINKED_CI_SAVE_COMPLETE);
}
relationModel.refreshRelations(itemId, itemType).finally(function () {
scope.$emit(events.RELATIONS_UPDATE_COMPLETE, false);
scope.relations.relationsRefreshInProgress = false;
});
});
};
factory.applyFilter = function ( /* filterOption */) {
};
factory.selectAllFilters = function ( /* state */) {
};
factory.cleanUp = function () {
relationWatcherUnregister();
};
if (scope.dependency === 'change-to-cis') {
factory.addTemplateUrl = 'views/ticket/link-CI-action-blade.html';
factory.addController = 'LinkCIController';
factory.addClass = 'profile-relation__tab-ciRelations-modal';
factory.backdrop = false;
factory.keyboard = false;
relationWatcherUnregister = scope.$watch('relations', function () {
scope.relatedItems = _.filter(angular.copy(scope.relations[itemId]), { type: EntityVO.TYPE_ASSET }) || [];
globalMetadataPromise.then(function (metadata) {
if (metadata.configurationParameters && metadata.configurationParameters.affectedServiceRelation && metadata.configurationParameters.affectedServiceRelation === 'false') {
scope.relatedItems = _.chain(scope.relatedItems).reject(function (linkedItem) {
var context = scope.context;
return context && _.contains([context.causalCI && context.causalCI.reconciliationId, context.impactedService && context.impactedService.reconciliationId], linkedItem.id) && linkedItem.type === EntityVO.TYPE_ASSET;
}).value();
}
});
}, true);
}
if (scope.dependency === 'ticket-to-all') {
factory.addBladeSize = 'md';
relationWatcherUnregister = scope.$watch('relations', function (newVal, oldVal) {
if (newVal.relationsRefreshInProgress !==
oldVal.relationsRefreshInProgress) {
scope.state.loadingRelatedItems = !!newVal.relationsRefreshInProgress;
}
globalMetadataPromise.then(function (metadata) {
if (metadata.configurationParameters && metadata.configurationParameters.affectedServiceRelation) {
showAffectedServiceRelation = (metadata.configurationParameters.affectedServiceRelation === 'true');
}
scope.relatedItems = relationService.getRelatedLinkedItems(angular.copy(scope.relations[itemId]), scope.context, showAffectedServiceRelation);
});
}, true);
}
break;
}
return factory;
})();
scope.factory.selectAllFilters(false, true);
scope.factory.load();
scope.showRelatedItemDetails = function (relatedItem, $event) {
if ('href' in $event.target) {
return;
}
var params = {};
if (relatedItem.type === EntityVO.TYPE_ASSET) {
params.assetId = relatedItem.realObject && relatedItem.realObject.reconciliationId;
params.assetClassId = relatedItem.realObject && relatedItem.realObject.classId;
}
else {
if (relatedItem.type === EntityVO.TYPE_OUTAGE || relatedItem.type === EntityVO.TYPE_DLP || configurationModel.isServerApplicationEnabled(relatedItem.type)) {
params.id = relatedItem.id;
}
else {
if (systemAlertService.alertStack.length) {
systemAlertService.dismissAllAlerts();
}
systemAlertService.warning({
text: $filter('i18n')('person.preview.notification.disabled.application'),
hide: 10000
});
return;
}
}
$state.go(relatedItem.type, params);
};
scope.openAddRelatedAssetBlade = function () {
var modalInstance = $modal.open({
templateUrl: 'views/asset/relate-asset.html',
windowClass: 'action-blade',
controller: 'RelateAssetController',
backdrop: 'custom',
size: 'lg',
resolve: {
linkParams: function () {
return {
selectedItem: scope.context
};
}
}
});
modalInstance.result.then(function ( /* response */) {
// if(response[0] && response[0].type === "Success") {
// systemAlertService.success({
// text: response[0].message,
// hide: 5000
// });
// }
scope.factory.refresh();
});
};
scope.addRelatedItem = function ($event) {
ticketModel.linkCIsParent = scope.context;
var modalInstance = $modal.open({
templateUrl: scope.factory.addTemplateUrl || 'views/ticket/link-item-action-blade.html',
windowClass: scope.factory.addClass || 'action-blade',
controller: scope.factory.addController || 'LinkController',
size: scope.factory.addBladeSize,
backdrop: _.isUndefined(scope.factory.backdrop) ? true : scope.factory.backdrop,
resolve: {
linkParams: function () {
return {
selectedItems: [scope.context],
selectedItem: scope.context,
isDraft: scope.isDraft,
linkFromTicketConsole: false
};
}
}
});
modalInstance.result.then(function (relatedItems) {
if (scope.dependency === 'change-to-cis') {
var linkedCIs = relatedItems && relatedItems.linkedItems && relatedItems.linkedItems.linkedCIs ? relatedItems.linkedItems.linkedCIs : [];
if (relatedItems.relationPromise) {
scope.$emit(events.SHOW_PROGRESS_MODAL_FOR_EDIT, {
showModal: true,
title: $filter('i18n')('change.details.relatingCIs.title'),
text: $filter('i18n')('change.details.relatingCIs.text')
});
relatedItems.relationPromise.finally(function () {
scope.$emit(events.SHOW_PROGRESS_MODAL_FOR_EDIT, { showModal: false });
systemAlertService.success({
text: $filter('i18n')('ticket.notification.link.message', relatedItems.linkedCount),
hide: 10000
});
scope.factory.refresh();
});
}
else {
systemAlertService.success({
text: $filter('i18n')('ticket.notification.link.message', relatedItems.linkedCount),
hide: 10000
});
scope.factory.refresh();
}
}
else {
if (scope.isDraft) {
scope.$emit(events.DRAFT_TICKET_RESOURCE_RELATED, relatedItems);
}
else {
systemAlertService.success({
text: $filter('i18n')('ticket.notification.link.message', relatedItems.length),
hide: 10000
});
scope.factory.refresh(relatedItems);
}
}
var relatedItem = relatedItems[0] || (linkedCIs && linkedCIs[0]);
switch (relatedItem && relatedItem.relationshipType) {
case EntityVO.TYPE_DUPLICATEOF:
if (!scope.isDraft) {
scope.context.status.value = 'Pending';
}
scope.context.accessMappings.detailsEditAllowed = false;
scope.context.accessMappings.statusEditAllowed = false;
scope.context.accessMappings.relationsEditAllowed = false;
scope.$emit(events.REFRESH_TICKET_FROM_TITLE_BAR);
systemAlertService.warning({
text: $filter('i18n')('ticket.notification.duplicate.message', relatedItems[0].displayId + ': ' +
(relatedItems[0].title || relatedItems[0].realObject.title || relatedItems[0].desc)),
hide: 10000
});
break;
case EntityVO.TYPE_ORIGINALOF:
scope.context.accessMappings.duplicateActionAllowed = false;
break;
}
$event.currentTarget.focus();
}, function () {
$event.currentTarget.focus();
});
};
scope.removeRelatedItem = function (relatedItem, $event) {
$event.stopPropagation();
if (scope.context && scope.context.impactedService && scope.context.impactedService.reconciliationId === relatedItem.id) {
systemAlertService.error({
text: $filter('i18n')('ticket.notification.unlink.notAllowed'),
hide: 10000
});
return;
}
var modalInstance = systemAlertService.modal({
title: $filter('i18n')('common.notification.delete.title'),
text: $filter('i18n')('common.notification.delete.message'),
buttons: [
{
text: $filter('i18n')('common.notification.delete.button1'),
data: true
},
{
text: $filter('i18n')('common.notification.delete.button2'),
data: false
}
]
});
modalInstance.result.then(function (data) {
if (data) {
if (scope.isDraft) {
scope.$emit(events.DRAFT_TICKET_RESOURCE_UNRELATED, relatedItem);
}
else {
scope.factory.remove(relatedItem);
systemAlertService.success({
text: $filter('i18n')('ticket.notification.unlink.message', 1),
hide: 10000
});
}
}
});
};
scope.createRelatedDraft = function (ticketType, location) {
ticketModel.cache.draft = {
type: ticketType
};
ticketModel.cache.relatedDraft = {
type: ticketType,
fromType: scope.getContextType(),
id: scope.context.id,
fromContext: scope.context
};
if (scope.getContextType() === EntityVO.TYPE_ASSET) {
ticketModel.cache.relatedDraft.id = scope.context.reconciliationId;
ticketModel.cache.relatedDraft.relationship = RelationItemVO.TYPE_RELATEDTO;
}
$state.go(location);
};
scope.createRelatedOutage = function () {
var modalInstance = $modal.open({
templateUrl: 'views/create/create-outage-action-blade.html',
controller: 'CreateOutageController',
windowClass: 'action-blade',
backdrop: 'custom',
size: 'lg',
resolve: {
params: function () {
return {
context: scope.context,
relations: scope.relations[scope.context.id]
};
}
}
});
modalInstance.result.then(function (response) {
if (response.createPromise) {
scope.$emit(events.SHOW_PROGRESS_MODAL_FOR_EDIT, {
showModal: true,
title: $filter('i18n')('change.details.relatingOutages.text'),
text: $filter('i18n')('change.details.relatingOutages.text')
});
response.createPromise.then(function (error) {
scope.$emit(events.SHOW_PROGRESS_MODAL_FOR_EDIT, { showModal: false });
if (error) {
systemAlertService.error({
text: error,
clear: false
});
return;
}
if (!scope.isDraft) {
systemAlertService.success({
text: $filter('i18n')('ticket.notification.link.message', response.ciList.length),
hide: 10000
});
scope.factory.refresh(response.ciList);
}
});
}
else {
if (!scope.isDraft) {
systemAlertService.success({
text: $filter('i18n')('ticket.notification.link.message', response.ciList.length),
hide: 10000
});
scope.factory.refresh(response.ciList);
}
}
});
};
scope.createRelatedArticle = function () {
ticketModel.articleParent = scope.context;
var modalInstance = $modal.open({
templateUrl: 'views/create/create-ka.html',
controller: 'CreateKnowledgeArticleModalController',
windowClass: 'action-blade',
backdrop: 'custom',
size: 'full-page',
});
modalInstance.result.then(function (article) {
scope.state.loadingRelatedItems = true;
var resourceItem = new RelationItemVO().build({
id: article.id,
displayId: article.articleId,
title: article.title,
desc: article.title,
type: article.type,
additionalInformation: {
modifiedDate: article.modifiedDate
},
tag: EntityVO.TYPE_RESOURCE,
relationshipType: EntityVO.TYPE_RELATEDTO
});
var parent = {
type: scope.context.type,
uuid: scope.context.id
}, data = {
id: resourceItem.id,
desc: resourceItem.desc,
type: resourceItem.type,
tag: EntityVO.TYPE_RESOURCE,
relationshipType: EntityVO.TYPE_RELATEDTO
};
relationModel.addRelation(parent, [data]).then(function () {
scope.state.loadingRelatedItems = false;
scope.$emit(events.SELECT_RESOURCE_TAB);
if (data.type === EntityVO.TYPE_KNOWLEDGE) {
delete relationModel.cache[data.id]; //Delete cache entry for the knowledge-ticket relation to fetch it fresh from backend.
}
$state.go(resourceItem.type, {
id: resourceItem.id,
});
});
});
};
scope.showCreateRelatedMenu = false;
scope.validateCreatePermission = function (type) {
var permission = false;
switch (type) {
case EntityVO.TYPE_WORKORDER:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_WORKORDER)
&& permissionModel.hasPermission(roles.ITSM_AGENT_ROLE);
break;
case EntityVO.TYPE_CHANGE:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_CHANGE)
&& permissionModel.hasPermission(roles.ITSM_CHANGE_USER_ROLE)
&& scope.getContextType() !== EntityVO.TYPE_CHANGE;
break;
case EntityVO.TYPE_OUTAGE:
permission = scope.context.accessMappings.createoutageEditAllowed
&& scope.getContextType() === EntityVO.TYPE_CHANGE;
break;
case EntityVO.TYPE_INCIDENT:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_INCIDENT)
&& permissionModel.hasPermission(roles.ITSM_AGENT_ROLE);
break;
case EntityVO.TYPE_PROBLEM:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_PROBLEM)
&& permissionModel.hasPermission(roles.ITSM_PROBLEM_USER_ROLE);
break;
case EntityVO.TYPE_KNOWNERROR:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_KNOWNERROR)
&& permissionModel.hasPermission(roles.ITSM_PROBLEM_USER_ROLE);
break;
case EntityVO.TYPE_ASSET:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_ASSET);
break;
case EntityVO.TYPE_KNOWLEDGE:
permission = (permissionModel.hasPermission(roles.ITSM_KNOWLEDGE_USER_ROLE)
&& (_.includes([EntityVO.TYPE_INCIDENT, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_KNOWNERROR], scope.getContextType())));
break;
case EntityVO.TYPE_RELEASE:
permission = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_RELEASE)
&& permissionModel.hasPermission(roles.ITSM_RELEASE_USER_ROLE);
break;
}
if (!scope.showCreateRelatedMenu) {
scope.showCreateRelatedMenu = permission;
}
return permission;
};
scope.checkLinkPermission = function () {
var linkConfig = configurationModel.get('link'), type = scope.getContextType();
var options = linkConfig[type];
if (type === EntityVO.TYPE_CHANGE) {
options = _.reject(options, { type: EntityVO.TYPE_ASSET });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_ASSET)) {
options = _.reject(options, { type: EntityVO.TYPE_ASSET });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_WORKORDER) || !permissionModel.hasPermission(roles.ITSM_AGENT_ROLE)) {
options = _.reject(options, { type: EntityVO.TYPE_WORKORDER });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_CHANGE) || !permissionModel.hasPermission(roles.ITSM_CHANGE_USER_ROLE)) {
options = _.reject(options, { type: EntityVO.TYPE_CHANGE });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_INCIDENT) || !permissionModel.hasPermission(roles.ITSM_AGENT_ROLE)) {
options = _.reject(options, { type: EntityVO.TYPE_INCIDENT });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_PROBLEM) || !permissionModel.hasPermission(roles.ITSM_PROBLEM_USER_ROLE)) {
options = _.reject(options, { type: EntityVO.TYPE_PROBLEM });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_KNOWNERROR) || !permissionModel.hasPermission(roles.ITSM_PROBLEM_USER_ROLE)) {
options = _.reject(options, { type: EntityVO.TYPE_KNOWNERROR });
}
if (!configurationModel.isServerApplicationEnabled(EntityVO.TYPE_RELEASE)) {
options = _.reject(options, { type: EntityVO.TYPE_RELEASE });
}
return options.length ? true : false;
};
scope.goToGraphicalCi = function () {
goToExplorer('assetCiExplorer.graphical');
};
scope.goToListCi = function () {
goToExplorer('assetCiExplorer.list');
};
function goToExplorer(explorer) {
$state.go(explorer, {
assetId: scope.context.reconciliationId,
assetClassId: scope.context.classId
});
}
function refreshRelatedItemsList(event, parentEvent) {
if (scope.getContextType() === EntityVO.TYPE_CHANGE && parentEvent && parentEvent.event === events.AFFECTED_SERVICE_UPDATE_SAVED) {
if (scope.dependency === "change-to-cis") {
delete relationModel.cache[scope.context.reconciliationId];
scope.factory.refresh();
}
}
else {
delete relationModel.cache[scope.context.reconciliationId];
scope.factory.refresh();
}
}
refreshRelatedItemsListUnsubscribe = scope.$on(events.REFRESH_RELATED_ITEM_LIST, refreshRelatedItemsList);
scope.$on('$destroy', function () {
// Unregister watcher for scope.relatedItems
relatedItemsWatcherUnregister();
// Unregister watchers and unsubscribe from listeners initiated during factory initialization
scope.factory.cleanUp();
// Unsubscribe from 'REFRESH_RELATED_ITEM_LIST' events
refreshRelatedItemsListUnsubscribe();
});
}
};
}
]);
})();