"use strict"; (function () { 'use strict'; angular.module('ticketModule') .controller('TicketProfileController', ['$scope', '$state', 'ticketModel', '$timeout', 'historyModel', 'events', 'systemAlertService', 'configurationModel', 'objectValueMapperService', function ($scope, $state, ticketModel, $timeout, historyModel, events, systemAlertService, configurationModel, objectValueMapperService) { $scope.id = $state.params.id; $scope.type = $state.current.name; $scope.ticket = {}; $scope.progress = {}; $scope.state = { resourceTabActive: 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'); } /** * 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.state.resourceTabActive ? 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 () { $scope.$broadcast(events.REFRESH_ACTIVITY_FEED); $scope.$broadcast(events.REFRESH_RESOURCE_FEED); }); $scope.$on(events.SELECT_RESOURCE_TAB, function () { $scope.state.resourceTabActive = true; }); $scope.$on(events.SAVE_COPY_CHANGE_DRAFT, function () { $scope.$broadcast(events.SAVE_COPY_CHANGE_ACTIVITY); }); $scope.loadResources = function () { $scope.state.loadResources = true; }; } ]); })();