summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js77
1 files changed, 53 insertions, 24 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js
index 57e2e80..5236001 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js
@@ -1,10 +1,12 @@
-appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceDS2){
+appDS2.controller('profileSearchCtrlDS2', function($scope, $log, $modal, ProfileServiceDS2){
$scope.showInput = true;
- $scope.totalPages1 = 5;
+ $scope.totalPages1 = 0;
$scope.viewPerPage1 = 8;
$scope.currentPage1 = 1;
$scope.showLoader = false;
+ var debug = false;
+
$scope.$watch('viewPerPage1', function(val) {
$scope.showLoader = true;
ProfileServiceDS2.getProfilePagination($scope.currentPage1, val).then(function(data){
@@ -12,15 +14,9 @@ appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceD
$scope.data = JSON.parse(j.data);
$scope.tableData =JSON.parse($scope.data.profileList);
$scope.totalPages1 =JSON.parse($scope.data.totalPage);
- for(x in $scope.tableData){
- if($scope.tableData[x].active_yn=='Y')
- $scope.tableData[x].active_yn=true;
- else
- $scope.tableData[x].active_yn=false;
- }
$scope.showLoader = false;
},function(error){
- console.log("failed");
+ console.log("watch of viewPerPage1 failed");
reloadPageOnce();
});
@@ -34,15 +30,9 @@ appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceD
$scope.data = JSON.parse(j.data);
$scope.tableData =JSON.parse($scope.data.profileList);
$scope.totalPages1 =JSON.parse($scope.data.totalPage);
- for(x in $scope.tableData){
- if($scope.tableData[x].active_yn=='Y')
- $scope.tableData[x].active_yn=true;
- else
- $scope.tableData[x].active_yn=false;
- }
$scope.showLoader = false;
},function(error){
- console.log("failed");
+ console.log("customHandler failed");
reloadPageOnce();
});
@@ -52,13 +42,52 @@ appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceD
window.location = 'userProfile#/profile/' + profileId;
};
+ var ModalInstanceCtrl = function ($scope, $log, $modalInstance, items) {
+ $scope.msg = items;
+
+ $scope.toggleUserStatus = function(id) {
+ if (debug)
+ $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl:toggleUserStatus: data is ' + id);
+ ProfileServiceDS2.toggleProfileStatus(id);
+ $modalInstance.close();
+ };
+
+ $scope.cancelUserStatusToggle = function(rowData) {
+ if (debug)
+ $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl: cancelUserStatusToggle: data is ' + JSON.stringify(rowData));
+ // Undo the toggle of the checkbox
+ rowData.active = ! rowData.active;
+ $modalInstance.dismiss('cancel');
+ }
+
+ }
+
+ // user activation/deactivation
$scope.toggleProfileActive = function(rowData) {
- modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?",
- function(){
- $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){});
- },
- function(){
- rowData.active=!rowData.active;
- })
- };
+ if (debug)
+ $log.debug('profileSearchCtrlDS2:toggleProfileActive: id is ' + rowData.id
+ + ', active is ' + rowData.active);
+ var toggleType = null;
+ // The checkbox is already in the desired state,
+ // so the sense of the "if" is reversed here.
+ if (rowData.active)
+ toggleType = "activate";
+ else
+ toggleType = "deactivate";
+ var modalInstance = $modal.open({
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html',
+ controller: ModalInstanceCtrl,
+ sizeClass: 'modal-small',
+ resolve: {
+ items: function () {
+ var message = {
+ text : toggleType,
+ rowData : rowData
+ };
+ return message;
+ }
+ }
+ });
+ };
+
});