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: 'dependency' , visible : false},
66 {field: 'userCreatedBy.userName', displayName : 'Created By'},
67 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
68 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
69 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
71 exporterMenuPdf: false,
72 exporterPdfDefaultStyle: {fontSize: 9},
73 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
74 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
75 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
76 exporterPdfFooter: function ( currentPage, pageCount ) {
77 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
79 exporterPdfCustomFormatter: function ( docDefinition ) {
80 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
81 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
84 exporterFieldCallback: function(grid, row, col, input) {
85 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
86 var date = new Date(input);
87 return date.toString("yyyy-MM-dd HH:MM:ss a");
92 exporterPdfOrientation: 'portrait',
93 exporterPdfPageSize: 'LETTER',
94 exporterPdfMaxGridWidth: 500,
95 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
96 onRegisterApi: function(gridApi){
97 $scope.gridApi = gridApi;
101 $scope.editBRMSDependency = null;
102 $scope.createNewBRMSDependencyWindow = function(){
103 $scope.editBRMSDependency = null;
104 var modalInstance = $modal.open({
105 backdrop: 'static', keyboard: false,
106 templateUrl : 'add_brmsDependency_popup.html',
107 controller: 'editBRMSDependencyController',
109 message: function () {
111 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
118 modalInstance.result.then(function(response){
119 console.log('response', response);
120 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
124 $scope.viewBRMSDependencyWindow = function(brmsDependencyDictionaryData) {
125 $scope.editBRMSDependency = brmsDependencyDictionaryData;
126 var modalInstance = $modal.open({
127 backdrop: 'static', keyboard: false,
128 templateUrl : 'add_brmsDependency_popup.html',
129 controller: 'editBRMSDependencyController',
131 message: function () {
133 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
140 modalInstance.result.then(function(response){
141 console.log('response', response);
142 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
146 $scope.editBRMSDependencyWindow = function(brmsDependencyDictionaryData) {
147 $scope.editBRMSDependency = brmsDependencyDictionaryData;
148 var modalInstance = $modal.open({
149 backdrop: 'static', keyboard: false,
150 templateUrl : 'add_brmsDependency_popup.html',
151 controller: 'editBRMSDependencyController',
153 message: function () {
155 brmsDependencyDictionaryDatas: $scope.editBRMSDependency,
162 modalInstance.result.then(function(response){
163 console.log('response', response);
164 $scope.brmsDependencyDictionaryDatas=response.brmsDependencyDictionaryDatas;
168 $scope.deleteBRMSDependency = function(data) {
169 modalService.popupConfirmWin("Confirm","You are about to delete the BRMS Dependency "+data.dependencyName+". Do you want to continue?",
171 var uuu = "deleteDictionary/brms_dictionary/remove_brmsDependency";
172 var postData={data: data};
177 contentType: 'application/json',
178 data: JSON.stringify(postData),
179 success : function(data){
180 $scope.$apply(function(){$scope.brmsDependencyDictionaryDatas=data.brmsDependencyDictionaryDatas;});
182 error : function(data){
184 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);