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=========================================================
20 app.controller('brmsDependencyDictGridController', function ($scope, PolicyAppService,modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_BRMSDependencyData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.brmsDependencyDictionaryDatas = JSON.parse($scope.data.brmsDependencyDictionaryDatas);
28 console.log($scope.brmsDependencyDictionaryDatas);
30 console.log("failed");
34 PolicyAppService.getData('get_LockDownData').then(function(data){
36 $scope.data = JSON.parse(j.data);
37 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
38 if($scope.lockdowndata[0].lockdown == true){
39 $scope.brmsDependencyDictionaryGrid.columnDefs[0].visible = false;
40 $scope.gridApi.grid.refresh();
42 $scope.brmsDependencyDictionaryGrid.columnDefs[0].visible = true;
43 $scope.gridApi.grid.refresh();
46 console.log("failed");
49 $scope.brmsDependencyDictionaryGrid = {
50 data : 'brmsDependencyDictionaryDatas',
51 enableFiltering: true,
52 exporterCsvFilename: 'BRMSDependencyDictionary.csv',
54 enableSelectAll: true,
56 field: 'id', enableFiltering: false, headerCellTemplate: '' +
57 '<button id=\'New\' ng-click="grid.appScope.createNewBRMSDependencyWindow()" class="btn btn-success">' + 'Create</button>',
59 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.viewBRMSDependencyWindow(row.entity)"><i class="glyphicon glyphicon-eye-open"></i></button> ' +
60 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editBRMSDependencyWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
61 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteBRMSDependency(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '12%'
63 { field: 'dependencyName', displayName : 'Dependency Name', sort: { direction: 'asc', priority: 0 }},
64 { field: 'description'},
65 {field: 'userCreatedBy.userName', displayName : 'Created By'},
66 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
67 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
68 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
70 exporterMenuPdf: false,
71 exporterPdfDefaultStyle: {fontSize: 9},
72 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
73 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
74 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
75 exporterPdfFooter: function ( currentPage, pageCount ) {
76 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
78 exporterPdfCustomFormatter: function ( docDefinition ) {
79 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
80 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
83 exporterPdfOrientation: 'portrait',
84 exporterPdfPageSize: 'LETTER',
85 exporterPdfMaxGridWidth: 500,
86 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
87 onRegisterApi: function(gridApi){
88 $scope.gridApi = gridApi;
92 $scope.editBRMSDependency = null;
93 $scope.createNewBRMSDependencyWindow = function(){
94 $scope.editBRMSDependency = null;
95 var modalInstance = $modal.open({
96 backdrop: 'static', keyboard: false,
97 templateUrl : 'add_brmsDependency_popup.html',
98 controller: 'editBRMSDependencyController',
100 message: function () {
102 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
109 modalInstance.result.then(function(response){
110 console.log('response', response);
111 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
115 $scope.viewBRMSDependencyWindow = function(brmsDependencyDictionaryData) {
116 $scope.editBRMSDependency = brmsDependencyDictionaryData;
117 var modalInstance = $modal.open({
118 backdrop: 'static', keyboard: false,
119 templateUrl : 'add_brmsDependency_popup.html',
120 controller: 'editBRMSDependencyController',
122 message: function () {
124 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
131 modalInstance.result.then(function(response){
132 console.log('response', response);
133 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
137 $scope.editBRMSDependencyWindow = function(brmsDependencyDictionaryData) {
138 $scope.editBRMSDependency = brmsDependencyDictionaryData;
139 var modalInstance = $modal.open({
140 backdrop: 'static', keyboard: false,
141 templateUrl : 'add_brmsDependency_popup.html',
142 controller: 'editBRMSDependencyController',
144 message: function () {
146 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
153 modalInstance.result.then(function(response){
154 console.log('response', response);
155 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
159 $scope.deleteBRMSDependency = function(data) {
160 modalService.popupConfirmWin("Confirm","You are about to delete the BRMS Dependency "+data.dependencyName+". Do you want to continue?",
162 var uuu = "deleteDictionary/brms_dictionary/remove_brmsDependency";
163 var postData={data: data};
168 contentType: 'application/json',
169 data: JSON.stringify(postData),
170 success : function(data){
171 $scope.$apply(function(){$scope.brmsDependencyDictionaryDatas=data.brmsDependencyDictionaryDatas;});
173 error : function(data){
175 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);