82 lines
4.3 KiB
JavaScript
82 lines
4.3 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('ticketModule')
|
|
.controller('TicketProfileController', ['$scope', '$state', 'ticketModel', '$timeout', 'historyModel', 'events', 'systemAlertService', 'configurationModel', 'objectValueMapperService', 'metadataModel', '$stateParams',
|
|
function ($scope, $state, ticketModel, $timeout, historyModel, events, systemAlertService, configurationModel, objectValueMapperService, metadataModel, $stateParams) {
|
|
$scope.id = $state.params.id;
|
|
$scope.type = $state.current.name;
|
|
$scope.ticket = {};
|
|
$scope.progress = {};
|
|
$scope.state = {};
|
|
$scope.isActive = [{ active: true }, { active: false }];
|
|
//only required for copy chnage scenario
|
|
$scope.activityNote = {};
|
|
$scope.isNoteRequired = false;
|
|
objectValueMapperService.clearMap($scope.type);
|
|
if ($scope.type !== 'task' && $scope.type !== 'outage' && !configurationModel.isServerApplicationEnabled($scope.type)) {
|
|
$state.go('unauthorized');
|
|
}
|
|
metadataModel.getMetadataByType('global').then(function (metadata) {
|
|
var isPwaEnabled = (metadata.configurationParameters['Enable-Progressive-Views'] === 'T' || metadata.configurationParameters['Enable-Progressive-Views'] === 'true');
|
|
isPwaEnabled = localStorage.getItem('overridePV') === 'T' ? false : isPwaEnabled;
|
|
if (isPwaEnabled && localStorage.getItem('midtierUrl') && configurationModel.get('pwaEnabledTickets.tickets').indexOf($scope.type) >= 0) {
|
|
$state.go($scope.type + 'PV', { id: $stateParams.id }, { inherit: false });
|
|
}
|
|
}).catch(function (error) {
|
|
if (error) {
|
|
systemAlertService.error({
|
|
text: error.data.error,
|
|
clear: false
|
|
});
|
|
}
|
|
});
|
|
/**
|
|
* Adding item to history menu after it was loaded
|
|
*/
|
|
$scope.$on(events.TICKET_BASIC_DATA_LOADED, function (event, data) {
|
|
historyModel.addToHistory(EntityVO.TYPE_TICKET, data.ticket);
|
|
$scope.ticket = data.ticket;
|
|
$scope.state.loadResources = $scope.isActive[1].active ? true : false;
|
|
});
|
|
/**
|
|
* Ticket Profile Controller is a "Event Bus" between all component on profile page
|
|
* to communicate in your sub component controller you should $scope.$emit(events.TICKET_PROFILE_RESEND_EVENT, {eventName: 'event name you want to broadcast to other component'})
|
|
*/
|
|
$scope.$on(events.TICKET_PROFILE_RESEND_EVENT, function (event, resend) {
|
|
event.stopPropagation();
|
|
$scope.$broadcast(resend.eventName, resend.data);
|
|
});
|
|
$scope.$on(events.SHOW_PROGRESS_MODAL_FOR_EDIT, function (event, params) {
|
|
if (params) {
|
|
$scope.progress.title = params.title || '';
|
|
$scope.progress.text = params.text || '';
|
|
$scope.progress.cssClass = params.cssClass || '';
|
|
$scope.state.showProgressModal = params.showModal;
|
|
}
|
|
});
|
|
/**
|
|
* On refresh ticket upadte ticket activities
|
|
*/
|
|
$scope.$on(events.REFRESH_TICKET, function (event, data) {
|
|
$scope.$broadcast(events.REFRESH_ACTIVITY_FEED);
|
|
$scope.$broadcast(events.REFRESH_RESOURCE_FEED, data);
|
|
});
|
|
$scope.$on(events.SELECT_RESOURCE_TAB, function () {
|
|
$scope.isActive[0].active = false;
|
|
$scope.state.loadResources = $scope.isActive[1].active = true;
|
|
});
|
|
$scope.$on(events.SELECT_ACTIVITY_TAB, function () {
|
|
$scope.isActive[0].active = true;
|
|
$scope.state.loadResources = $scope.isActive[1].active = false;
|
|
});
|
|
$scope.$on(events.SAVE_COPY_CHANGE_DRAFT, function () {
|
|
$scope.$broadcast(events.SAVE_COPY_CHANGE_ACTIVITY);
|
|
});
|
|
$scope.loadResources = function () {
|
|
$scope.state.loadResources = true;
|
|
};
|
|
}
|
|
]);
|
|
})();
|