diff --git a/app/scripts/directives/blocks.js b/app/scripts/directives/blocks.js
index 2153b15e7..72e307c70 100644
--- a/app/scripts/directives/blocks.js
+++ b/app/scripts/directives/blocks.js
@@ -20,10 +20,15 @@ angular.module('confRegistrationWebApp').directive('nameQuestion', function () {
return {
templateUrl: nameQuestionTemplate,
restrict: 'E',
- controller: function ($scope) {
+ controller: function ($rootScope, $scope) {
if (!$scope.answer && !$scope.answer.value) {
$scope.answer.value = {};
}
+
+ const user = $rootScope.globalUser();
+ $scope.lockedStaffProfileBlock = Boolean(
+ user && user.employeeId && $scope.block.profileType === 'NAME',
+ );
},
};
});
@@ -64,6 +69,12 @@ angular
return {
templateUrl: emailQuestionTemplate,
restrict: 'E',
+ controller: function ($rootScope, $scope) {
+ const user = $rootScope.globalUser();
+ $scope.lockedStaffProfileBlock = Boolean(
+ user && user.employeeId && $scope.block.profileType === 'EMAIL',
+ );
+ },
};
});
diff --git a/app/views/blocks/emailQuestion.html b/app/views/blocks/emailQuestion.html
index 9a6136dfc..97db94d54 100644
--- a/app/views/blocks/emailQuestion.html
+++ b/app/views/blocks/emailQuestion.html
@@ -7,7 +7,7 @@
ng-model="answer.value"
ng-model-options="{ debounce: 1000 }"
ng-required="block.required"
- ng-disabled="editBlock"
+ ng-disabled="editBlock || lockedStaffProfileBlock"
/>
Please enter a valid email such as: example@example.com
@@ -20,7 +20,7 @@
ng-model="answer.value.lastName"
ng-model-options="{ debounce: 300 }"
ng-required="block.required"
- ng-disabled="editBlock"
+ ng-disabled="editBlock || lockedStaffProfileBlock"
/>
diff --git a/test/spec/directives/block.spec.js b/test/spec/directives/block.spec.js
index 277397b00..98adab1b4 100644
--- a/test/spec/directives/block.spec.js
+++ b/test/spec/directives/block.spec.js
@@ -4,6 +4,171 @@ import _ from 'lodash';
describe('Directive: blocks', () => {
beforeEach(angular.mock.module('confRegistrationWebApp'));
+ describe('nameQuestion', () => {
+ let $compile, $rootScope, $scope;
+ beforeEach(inject((_$compile_, _$rootScope_, $templateCache, testData) => {
+ $compile = _$compile_;
+ $rootScope = _$rootScope_;
+
+ $scope = $rootScope.$new();
+ $scope.answer = {};
+ $templateCache.put('views/blocks/nameQuestion.html', '');
+
+ $scope.block = _.cloneDeep(
+ testData.conference.registrationPages[1].blocks[1],
+ );
+ }));
+
+ describe('lockedStaffProfileBlock', () => {
+ describe('for staff', () => {
+ beforeEach(() => {
+ spyOn($rootScope, 'globalUser').and.returnValue({
+ employeeId: '0123456',
+ });
+ });
+
+ it('is true when the profile type is NAME', () => {
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(true);
+ });
+
+ it('is false when the profile type is not NAME', () => {
+ $scope.block.profileType = null;
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+ });
+
+ describe('for non-staff', () => {
+ beforeEach(() => {
+ spyOn($rootScope, 'globalUser').and.returnValue({ employeeId: null });
+ });
+
+ it('is false when the profile type is NAME', () => {
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+
+ it('is false when the profile type is not NAME', () => {
+ $scope.block.profileType = null;
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+ });
+
+ describe('with no profile', () => {
+ beforeEach(() => {
+ spyOn($rootScope, 'globalUser').and.returnValue(null);
+ });
+
+ it('is false when the profile type is NAME', () => {
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+
+ it('is false when the profile type is not NAME', () => {
+ $scope.block.profileType = null;
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+ });
+ });
+ });
+
+ describe('emailQuestion', () => {
+ let $compile, $rootScope, $scope;
+ beforeEach(inject((_$compile_, _$rootScope_, $templateCache, testData) => {
+ $compile = _$compile_;
+ $rootScope = _$rootScope_;
+
+ $scope = $rootScope.$new();
+ $templateCache.put('views/blocks/emailQuestion.html', '');
+
+ $scope.block = _.cloneDeep(
+ testData.conference.registrationPages[0].blocks[0],
+ );
+ }));
+
+ describe('lockedStaffProfileBlock', () => {
+ describe('for staff', () => {
+ beforeEach(() => {
+ spyOn($rootScope, 'globalUser').and.returnValue({
+ employeeId: '0123456',
+ });
+ });
+
+ it('is true when the profile type is EMAIL', () => {
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(true);
+ });
+
+ it('is false when the profile type is not EMAIL', () => {
+ $scope.block.profileType = null;
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+ });
+
+ describe('for non-staff', () => {
+ beforeEach(() => {
+ spyOn($rootScope, 'globalUser').and.returnValue({ employeeId: null });
+ });
+
+ it('is false when the profile type is EMAIL', () => {
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+
+ it('is false when the profile type is not EMAIL', () => {
+ $scope.block.profileType = null;
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+ });
+
+ describe('with no profile', () => {
+ beforeEach(() => {
+ spyOn($rootScope, 'globalUser').and.returnValue(null);
+ });
+
+ it('is false when the profile type is EMAIL', () => {
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+
+ it('is false when the profile type is not EMAIL', () => {
+ $scope.block.profileType = null;
+ $compile('')($scope);
+ $scope.$digest();
+
+ expect($scope.lockedStaffProfileBlock).toBe(false);
+ });
+ });
+ });
+ });
+
describe('radioQuestion', () => {
let $compile, $rootScope, $scope, $timeout;
beforeEach(inject((