"use strict"; (function () { 'use strict'; angular.module('customWidgetsModule').directive('supportGroupField', ['customFieldLinkFunction', 'events', function (customFieldLinkFunction, events) { return { restrict: 'E', replace: true, scope: { data: '=', isEditable: '=' }, templateUrl: 'views/custom-widgets/support-group-field.html', link: function (scope) { customFieldLinkFunction(scope); scope.onFieldValueChange = function () { scope.$emit(events.WIDGET_VALUE_CHANGE, { fieldName: scope.data.name }); }; var role = 'assignee', managerRegExp = new RegExp('manager', 'ig'); if (managerRegExp.test(scope.data.primaryKey)) { role = 'manager'; } scope.openAssignBlade = function ($event) { var editMode = scope.$parent.editMode; var assignParams = { originalEvent: $event, saveSelection: !editMode, role: role }; scope.$emit(events.SHOW_ASSIGN_TICKET_BLADE, assignParams); }; scope.onValueChange = function () { scope.$emit(events.WIDGET_VALUE_CHANGE, { fieldName: scope.data.name }); }; scope.$watch('data.setValueFlag', function (value) { if (value !== '#$#' && value) { if (!value.name && value.supportGroups) { value.name = value.supportGroups; } scope.data.value = value; scope.onValueChange(); scope.data.setValueFlag = '#$#'; } }); } }; }]); }());