'use strict'; // // Auto generated controller mapping for: <%= tview.tid %> // crudRouteInit.push(auto<%= tviewCode %>Init); function auto<%= tviewCode %>Init($routeProvider, $locationProvider) { <% if (tview.tlist) { %> $routeProvider.when('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/', { redirectTo: '<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>' }); <%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tlist', routeEnd: ''}); %> <% } %> <% if (tview.tcreate) { %> <%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tcreate', routeEnd: ''}); %> <% } %> <% if (tview.tedit) { %> <%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tedit', routeEnd: '/'+tview.tmeta.tmodel.tkey}); %> <% } %> <% if (tview.tread) { %> <%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tread', routeEnd: '/'+tview.tmeta.tmodel.tkey}); %> <% } %> <% if (tview.tdelete) { %> <%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tdelete', routeEnd: '/'+tview.tmeta.tmodel.tkey}); %> <% } %> } <% if (tview.tlist) { %> function <%= tview.tlist.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tlist.tplugin.angular.tcontroller.postfix %>(<%= tview.tlist.tplugin.angular.tcontroller.argu %>) { $scope.uiTableMain = {}; $scope.uiTableMain.enableColumnResizing = true; $scope.uiTableMain.enableFiltering = false; $scope.uiTableMain.enableGridMenu = true; $scope.uiTableMain.showGridFooter = false; $scope.uiTableMain.showColumnFooter = false; $scope.uiTableMain.paginationPageSizes = [25, 50, 75]; $scope.uiTableMain.paginationPageSize = 25; $scope.uiTableMain.enableFullRowSelection = true; $scope.uiTableMain.multiSelect = false; $scope.uiTableMain.columnDefs = []; $scope.uiTableMain.onRegisterApi = function(gridApi){ $scope.gridApi = gridApi; gridApi.selection.on.rowSelectionChanged($scope,function(row) { if ($scope.gridApi.selection.getSelectedRows().length > 0) { navigationService.actions.open = $scope.doEdit; } else { navigationService.actions.open = null; } }); }; var fetchData = function() { $http.get('<%= tapiPrefix %>/<%= tview.tlist.tplugin.formatJSON.tslug %>').then(function(response) { $scope.uiTableMain.data = response.data.data; }); }; navigationService.actions.refresh = function() { fetchData(); }; navigationService.actions.create = function() { $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tcreate.tplugin.angular.tslug %>'); }; $scope.doEdit = function() { $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tedit.tplugin.angular.tslug %>/'+$scope.gridApi.selection.getSelectedRows()[0].country_id); }; $http.get('<%= tapiPrefix2 %>').then(function(response) { var tview = response.data.data.tview; tview.tlist.tfields.forEach(function (fieldKey) { var field = tview.tmeta.tfields[fieldKey]; $scope.uiTableMain.columnDefs.push({ name: field.tname, field: field.tid, type2: field.ttype, }); }); navigationService.pageTitle = tview.tname; fetchData(); }); } <% } %> <% if (tview.tcreate) { %> function <%= tview.tcreate.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tcreate.tplugin.angular.tcontroller.postfix %>(<%= tview.tcreate.tplugin.angular.tcontroller.argu %>) { $scope.data = {}; $scope.tcreateData = function () { $http.post('<%= tapiPrefix %>/<%= tview.tcreate.tplugin.formatJSON.tslug %>', $scope.data).then(function(response) { <% if (tview.tlist) { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>'); <% } else { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/'); <% } %> }); } <%- include('controller-action-none', {tview: tview,taction: 'tcreate'}); %> } <% } %> <% if (tview.tread) { %> function <%= tview.tread.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tread.tplugin.angular.tcontroller.postfix %>(<%= tview.tread.tplugin.angular.tcontroller.argu %>) { $scope.data = {}; $http.get('<%= tapiPrefix %>/<%= tview.tread.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>).then(function(response) { $scope.data = response.data.data; }); <%- include('controller-action-none', {tview: tview,taction: 'tread'}); %> } <% } %> <% if (tview.tedit) { %> function <%= tview.tedit.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tedit.tplugin.angular.tcontroller.postfix %>(<%= tview.tedit.tplugin.angular.tcontroller.argu %>) { $scope.data = {}; var fetchData = function() { $http.get('<%= tapiPrefix %>/<%= tview.tread.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>).then(function(response) { $scope.data = response.data.data; }); }; fetchData(); $scope.teditData = function () { $http.put('<%= tapiPrefix %>/<%= tview.tedit.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>, $scope.data ).then(function(response) { <% if (tview.tread) { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tread.tplugin.angular.tslug %>/' + <%= ejsRouteParams %>); <% } else { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/'); <% } %> }); } $scope.tdeleteData = function () { $http.delete('<%= tapiPrefix %>/<%= tview.tdelete.tplugin.formatJSON.tslug %>/'+ <%= ejsRouteParams %>, $scope.data).then(function(response) { <% if (tview.tlist) { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>'); <% } else { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/'); <% } %> }); } <%- include('controller-action-none', {tview: tview,taction: 'tedit'}); %> navigationService.actions.save = $scope.teditData; navigationService.actions.cancel = $scope.teditNone; navigationService.actions.delete = $scope.tdeleteData; navigationService.actions.refresh = function() { fetchData(); }; } <% } %> <% if (tview.tdelete) { %> function <%= tview.tdelete.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tdelete.tplugin.angular.tcontroller.postfix %>(<%= tview.tdelete.tplugin.angular.tcontroller.argu %>) { $scope.data = {}; $http.get('<%= tapiPrefix %>/<%= tview.tread.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>).then(function(response) { $scope.data = response.data.data; console.log('delete obj: '+JSON.stringify(data.data)); }); $scope.tdeleteData = function () { $http.delete('<%= tapiPrefix %>/<%= tview.tdelete.tplugin.formatJSON.tslug %>/'+ <%= ejsRouteParams %>, $scope.data).then(function(response) { <% if (tview.tlist) { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>'); <% } else { %> $location.url('<%= tview.tmeta.tplugin.angular.tbase %>/'); <% } %> }); } <%- include('controller-action-none', {tview: tview,taction: 'tdelete'}); %> } <% } %>