(function () { 'use strict'; var streamApp = angular.module('streamApp'); streamApp.directive('connectionBasicCrudDirective', ['sharingService', 'userService', 'groupsService', ConnectionCrudDirective]); function ConnectionCrudDirective(sharingService, userService, groupsService) { return { restrict: 'E', scope: { prompt: '=', timeline: '=', buttonText: '=', hideName: '=', callback: '=' }, templateUrl: '/App/Directives/connectionCrud/connectionBasicCrudDirective.html?v=6.0.0c', link: function (scope, element, attrs, tabsCtrl) { scope.model = {}; userService.isAuthenticated().then(function (user) { scope.model.name = user.userName; scope.name = user.userName; }); let sending = false; scope.addConnection = function () { $('.upload').show(); if (sending) return; sending = true; let promptId = scope.prompt ? scope.prompt.promptId : null; let timelineId = scope.timeline ? scope.timeline.Id : null; scope.model.groups = scope.model.groups || []; sharingService.add(scope.model.email, scope.model.contactName, scope.model.name, scope.model.groups.filter(x => x.selected).map(s => s.tagId), promptId, timelineId ).then(function (data) { if (data.data.isValid) { scope.clear(); gtag_report_conversion(); if (scope.callback) scope.callback(true, data.data.message); } else { scope.message = data.data.message; } sending = false; $('.upload').hide(); }).catch(err => { sending = false; $('.upload').hide(); }); }; scope.cancel = function () { scope.clear(); scope.callback(false); }; scope.clear = function () { scope.model.contactName = ''; scope.model.email = ''; scope.model.name = scope.name; scope.confirmText = ''; scope.refreshTags(); } scope.refreshTags = function () { groupsService.getGroupsEditable().then(function (data) { scope.model.groups = sortName(data.data.activeTags); }); }; scope.refreshTags(); scope.addGroup = function (group) { //nothing to do }; function gtag_report_conversion(url) { var callback = function () { if (typeof(url) != 'undefined') { window.location = url; } }; gtag('event', 'conversion', { 'send_to': 'AW-696539402/HDPSCIeCgc0BEIqykcwC', 'event_callback': callback }); return false; } } }; }; })();