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 exporterFieldCallback: function(grid, row, col, input) {
84 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
85 var date = new Date(input);
86 return date.toString("yyyy-MM-dd HH:MM:ss a");
91 exporterPdfOrientation: 'portrait',
92 exporterPdfPageSize: 'LETTER',
93 exporterPdfMaxGridWidth: 500,
94 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
95 onRegisterApi: function(gridApi){
96 $scope.gridApi = gridApi;
100 $scope.editBRMSDependency = null;
101 $scope.createNewBRMSDependencyWindow = function(){
102 $scope.editBRMSDependency = null;
103 var modalInstance = $modal.open({
104 backdrop: 'static', keyboard: false,
105 templateUrl : 'add_brmsDependency_popup.html',
106 controller: 'editBRMSDependencyController',
108 message: function () {
110 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
117 modalInstance.result.then(function(response){
118 console.log('response', response);
119 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
123 $scope.viewBRMSDependencyWindow = function(brmsDependencyDictionaryData) {
124 $scope.editBRMSDependency = brmsDependencyDictionaryData;
125 var modalInstance = $modal.open({
126 backdrop: 'static', keyboard: false,
127 templateUrl : 'add_brmsDependency_popup.html',
128 controller: 'editBRMSDependencyController',
130 message: function () {
132 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
139 modalInstance.result.then(function(response){
140 console.log('response', response);
141 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
145 $scope.editBRMSDependencyWindow = function(brmsDependencyDictionaryData) {
146 $scope.editBRMSDependency = brmsDependencyDictionaryData;
147 var modalInstance = $modal.open({
148 backdrop: 'static', keyboard: false,
149 templateUrl : 'add_brmsDependency_popup.html',
150 controller: 'editBRMSDependencyController',
152 message: function () {
154 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
161 modalInstance.result.then(function(response){
162 console.log('response', response);
163 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
167 $scope.deleteBRMSDependency = function(data) {
168 modalService.popupConfirmWin("Confirm","You are about to delete the BRMS Dependency "+data.dependencyName+". Do you want to continue?",
170 var uuu = "deleteDictionary/brms_dictionary/remove_brmsDependency";
171 var postData={data: data};
176 contentType: 'application/json',
177 data: JSON.stringify(postData),
178 success : function(data){
179 $scope.$apply(function(){$scope.brmsDependencyDictionaryDatas=data.brmsDependencyDictionaryDatas;});
181 error : function(data){
183 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);