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=========================================================
23 app.controller('descriptiveDictGridController', function ($scope, DictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 DictionaryService.getDescriptiveDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.descriptiveScopeDictionaryDatas = JSON.parse($scope.data.descriptiveScopeDictionaryDatas);
37 console.log($scope.descriptiveScopeDictionaryDatas);
39 console.log("failed");
44 $scope.descriptiveDictionaryGrid = {
45 data : 'descriptiveScopeDictionaryDatas',
46 enableFiltering: true,
47 exporterCsvFilename: 'SearchCriteria.csv',
49 enableSelectAll: true,
51 field: 'id', enableFiltering: false, headerCellTemplate: '' +
52 '<button id=\'New\' ng-click="grid.appScope.createNewDescriptiveScopeWindow()" class="btn btn-success">' + 'Create</button>',
54 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editDescriptiveScopeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
55 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteDescriptiveScope(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
56 },{ field: 'scopeName', displayName : 'Descriptive Scope Name'},
57 { field: 'search', displayName : 'Search Criteria' },
58 { field: 'description' },
59 {field: 'userCreatedBy.userName', displayName : 'Created By' },
60 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
61 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
62 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
64 exporterPdfDefaultStyle: {fontSize: 9},
65 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
66 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
67 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
68 exporterPdfFooter: function ( currentPage, pageCount ) {
69 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
71 exporterPdfCustomFormatter: function ( docDefinition ) {
72 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
73 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
76 exporterPdfOrientation: 'portrait',
77 exporterPdfPageSize: 'LETTER',
78 exporterPdfMaxGridWidth: 500,
79 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
80 onRegisterApi: function(gridApi){
81 $scope.gridApi = gridApi;
85 $scope.editDescriptiveScope = null;
86 $scope.createNewDescriptiveScopeWindow = function(){
87 $scope.editDescriptiveScope = null;
88 var modalInstance = $modal.open({
89 backdrop: 'static', keyboard: false,
90 templateUrl : 'add_descriptiveScope_popup.html',
91 controller: 'editDescriptiveScopeController',
93 message: function () {
95 descriptiveScopeDictionaryDatas: $scope.editDescriptiveScope
101 modalInstance.result.then(function(response){
102 console.log('response', response);
103 $scope.descriptiveScopeDictionaryDatas=response.descriptiveScopeDictionaryDatas;
107 $scope.editDescriptiveScopeWindow = function(descriptiveScopeDictionaryData) {
108 $scope.editDescriptiveScope = descriptiveScopeDictionaryData;
109 var modalInstance = $modal.open({
110 backdrop: 'static', keyboard: false,
111 templateUrl : 'add_descriptiveScope_popup.html',
112 controller: 'editDescriptiveScopeController',
114 message: function () {
116 descriptiveScopeDictionaryData: $scope.editDescriptiveScope
122 modalInstance.result.then(function(response){
123 console.log('response', response);
124 $scope.descriptiveScopeDictionaryDatas = response.descriptiveScopeDictionaryDatas;
128 $scope.deleteDescriptiveScope = function(data) {
129 modalService.popupConfirmWin("Confirm","You are about to delete the Descriptive Scope : "+data.scopeName+". Do you want to continue?",
131 var uuu = papUrl + "/ecomp/descriptive_dictionary/remove_descriptiveScope.htm";
132 var postData={data: data};
137 contentType: 'application/json',
138 data: JSON.stringify(postData),
139 success : function(data){
140 $scope.$apply(function(){$scope.descriptiveScopeDictionaryDatas=data.descriptiveScopeDictionaryDatas;});
142 error : function(data){
144 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);