Skip to content

Commit

Permalink
Merge pull request #855 from CruGlobal/845-lock-staff-profile-blocks
Browse files Browse the repository at this point in the history
[EVENT-845] Allow admins to edit profile fields
  • Loading branch information
canac authored May 1, 2024
2 parents 1fe57f8 + 7ea1da2 commit 680e601
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/scripts/directives/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ angular.module('confRegistrationWebApp').directive('nameQuestion', function () {

const user = $rootScope.globalUser();
$scope.lockedStaffProfileBlock = Boolean(
user && user.employeeId && $scope.block.profileType === 'NAME',
!$scope.adminEditRegistrant &&
user &&
user.employeeId &&
$scope.block.profileType === 'NAME',
);
},
};
Expand Down Expand Up @@ -72,7 +75,10 @@ angular
controller: function ($rootScope, $scope) {
const user = $rootScope.globalUser();
$scope.lockedStaffProfileBlock = Boolean(
user && user.employeeId && $scope.block.profileType === 'EMAIL',
!$scope.adminEditRegistrant &&
user &&
user.employeeId &&
$scope.block.profileType === 'EMAIL',
);
},
};
Expand Down
48 changes: 48 additions & 0 deletions test/spec/directives/block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ describe('Directive: blocks', () => {
expect($scope.lockedStaffProfileBlock).toBe(false);
});
});

describe('when an admin is editing', () => {
beforeEach(() => {
$scope.adminEditRegistrant = {};
spyOn($rootScope, 'globalUser').and.returnValue({
employeeId: '0123456',
});
});

it('is false when the profile type is NAME', () => {
$compile('<name-question></name-question>')($scope);
$scope.$digest();

expect($scope.lockedStaffProfileBlock).toBe(false);
});

it('is false when the profile type is not NAME', () => {
$scope.block.profileType = null;
$compile('<name-question></name-question>')($scope);
$scope.$digest();

expect($scope.lockedStaffProfileBlock).toBe(false);
});
});
});
});

Expand Down Expand Up @@ -146,6 +170,30 @@ describe('Directive: blocks', () => {
});
});

describe('when an admin is editing', () => {
beforeEach(() => {
$scope.adminEditRegistrant = {};
spyOn($rootScope, 'globalUser').and.returnValue({
employeeId: '0123456',
});
});

it('is false when the profile type is EMAIL', () => {
$compile('<email-question></email-question>')($scope);
$scope.$digest();

expect($scope.lockedStaffProfileBlock).toBe(false);
});

it('is false when the profile type is not EMAIL', () => {
$scope.block.profileType = null;
$compile('<email-question></email-question>')($scope);
$scope.$digest();

expect($scope.lockedStaffProfileBlock).toBe(false);
});
});

describe('with no profile', () => {
beforeEach(() => {
spyOn($rootScope, 'globalUser').and.returnValue(null);
Expand Down

0 comments on commit 680e601

Please sign in to comment.