"use strict"; /** * Created by ygowtham on 6/16/2015. */ (function () { 'use strict'; angular.module('changeModule') .directive('collisionBanner', ['collisionModel', '$modal', 'emailModel', '$filter', '$state', 'configurationModel', function (collisionModel, $modal, emailModel, $filter, $state, configurationModel) { return { restrict: 'E', replace: true, templateUrl: 'views/collision/collision-banner.html', scope: { context: '=', collisions: '=', showCollisionDetection: '=' }, link: function (scope) { scope.autoTriggerChangeCollisionForCIsUpto = configurationModel.autoTriggerChangeCollisionForCIsUpto; scope.toggle = function () { scope.visible = !scope.visible; }; scope.editMode = scope.context.accessMappings.collisionEditAllowed; scope.editDatesView = function () { $state.go('changeEditCollisions', { id: scope.context.id }); }; scope.showEmailForm = function () { var recipients = []; _.each(scope.collisions.changeList, function (change) { if (change.assignee.id) { change.assignee.loginId = change.assignee.id; change.assignee.type = $filter('i18n')('change.detail.emailRecipients.allCollisionManagers'); recipients.push(change.assignee); } }); recipients = _.uniqBy(recipients, 'id'); return emailModel.createEmail([scope.context], recipients); }; } }; }]); })();