2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 import {IUserProperties, IAppConfigurtaion} from "app/models";
23 let PunchOutRegistry = require('third-party/PunchOutRegistry.js');
25 export interface IPunchOutScope extends ng.IScope {
32 export class PunchOutDirective implements ng.IDirective {
34 constructor(private sdcConfig:IAppConfigurtaion) {
47 link = (scope:IPunchOutScope, element:ng.IAugmentedJQuery):void => {
48 // global registry object
49 let PunchOutRegistry = window['PunchOutRegistry'];
51 let render = ():void => {
52 let cookieConfig = this.sdcConfig.cookie;
57 apiRoot: this.sdcConfig.api.root,
60 name: cookieConfig.userIdSuffix,
61 value: scope.user.userId
64 name: cookieConfig.userFirstName,
65 value: scope.user.firstName
68 name: cookieConfig.userLastName,
69 value: scope.user.lastName
72 name: cookieConfig.userEmail,
73 value: scope.user.email
77 onEvent: (...args) => {
79 scope.onEvent().apply(null, args);
83 PunchOutRegistry.render(props, element[0]);
86 let unmount = ():void => {
87 PunchOutRegistry.unmount(element[0]);
90 scope.$watch('data', render);
91 element.on('$destroy', unmount);
94 public static factory = (sdcConfig:IAppConfigurtaion) => {
95 return new PunchOutDirective(sdcConfig);
100 PunchOutDirective.factory.$inject = ['sdcConfig'];