From 351b2b444ebf537e168b438fb71a498c433970ff Mon Sep 17 00:00:00 2001 From: Lee Braddock Date: Tue, 11 Jul 2023 08:47:16 -0400 Subject: [PATCH 1/5] Change UI Display --- app/scripts/directives/questionToolbar.js | 4 ++-- app/views/components/blockEditor.html | 2 +- languages/ert.pot | 2 +- test/spec/testData.spec.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/scripts/directives/questionToolbar.js b/app/scripts/directives/questionToolbar.js index 3b7405590..762a72dbd 100644 --- a/app/scripts/directives/questionToolbar.js +++ b/app/scripts/directives/questionToolbar.js @@ -149,10 +149,10 @@ angular }, { id: 'genderQuestion', - defaultTitle: 'Gender', + defaultTitle: 'Sex', defaultProfile: 'GENDER', iconClass: 'fa-male', - name: 'Gender', + name: 'Sex', }, { id: 'yearInSchoolQuestion', diff --git a/app/views/components/blockEditor.html b/app/views/components/blockEditor.html index 078b42172..b3f553dfa 100644 --- a/app/views/components/blockEditor.html +++ b/app/views/components/blockEditor.html @@ -441,7 +441,7 @@ Question Rules can depend on questions of these types diff --git a/languages/ert.pot b/languages/ert.pot index 683459bd7..ee7883b8a 100644 --- a/languages/ert.pot +++ b/languages/ert.pot @@ -1392,7 +1392,7 @@ msgid "Move" msgstr "" #: ./app/views/components/blockEditor.html:444 -msgid "Multiple Choice, Dropdown, Number, Date, Gender or Year in School" +msgid "Multiple Choice, Dropdown, Number, Date, Sex or Year in School" msgstr "" #: ./app/scripts/app.config.js:180 diff --git a/test/spec/testData.spec.js b/test/spec/testData.spec.js index 48b4ba482..8f35df12e 100644 --- a/test/spec/testData.spec.js +++ b/test/spec/testData.spec.js @@ -156,7 +156,7 @@ angular.module('confRegistrationWebApp').service('testData', function () { { id: '9b83eebd-b064-4edf-92d0-7982a330272a', pageId: '7b4c19df-7377-4d37-90fb-5b262bb66d1a', - title: 'Gender', + title: 'Sex', exportFieldTitle: null, type: 'genderQuestion', required: false, From 92d4982603d7827be086c89f37880953508fa3ba Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Wed, 26 Jul 2023 12:56:24 -0700 Subject: [PATCH 2/5] Make multiple profile question error say Sex instead of Gender --- app/scripts/directives/blockEditor.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/scripts/directives/blockEditor.js b/app/scripts/directives/blockEditor.js index 5b4268cfc..b895ae023 100644 --- a/app/scripts/directives/blockEditor.js +++ b/app/scripts/directives/blockEditor.js @@ -325,11 +325,19 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { }); }); if (profileCount > 1) { - modalMessage.error( - 'Only one ' + + if ($scope.block.profileType == 'GENDER') { + var pType = 'Sex'; + } else { + pType = $scope.block.profileType.charAt(0).toUpperCase() + - $scope.block.profileType.slice(1).toLowerCase() + - ' profile block can be used per form.', + $scope.block.profileType + .split('_') + .join(' ') + .slice(1) + .toLowerCase(); + } + modalMessage.error( + 'Only one ' + pType + ' profile block can be used per form.', ); $scope.block.profileType = null; $scope.profileCheck = false; From 5ce2c0b449551ff223bc23c0986b8b21ed6f761a Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Thu, 27 Jul 2023 10:24:06 -0700 Subject: [PATCH 3/5] Fix code syntax of profile error message --- app/scripts/directives/blockEditor.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/scripts/directives/blockEditor.js b/app/scripts/directives/blockEditor.js index b895ae023..c604f0cc2 100644 --- a/app/scripts/directives/blockEditor.js +++ b/app/scripts/directives/blockEditor.js @@ -324,18 +324,18 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { } }); }); + if (profileCount > 1) { - if ($scope.block.profileType == 'GENDER') { - var pType = 'Sex'; - } else { - pType = - $scope.block.profileType.charAt(0).toUpperCase() + - $scope.block.profileType - .split('_') - .join(' ') - .slice(1) - .toLowerCase(); - } + const pType = + $scope.block.profileType == 'GENDER' + ? 'Sex' + : $scope.block.profileType.charAt(0).toUpperCase() + + $scope.block.profileType + .split('_') + .join(' ') + .slice(1) + .toLowerCase(); + modalMessage.error( 'Only one ' + pType + ' profile block can be used per form.', ); From 9069950dccf2747aa4bd7d2fbe7b421bbfdf1097 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Thu, 27 Jul 2023 10:24:06 -0700 Subject: [PATCH 4/5] Fix code syntax of profile error message --- app/scripts/directives/blockEditor.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/scripts/directives/blockEditor.js b/app/scripts/directives/blockEditor.js index c604f0cc2..078e5d1d8 100644 --- a/app/scripts/directives/blockEditor.js +++ b/app/scripts/directives/blockEditor.js @@ -324,7 +324,6 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { } }); }); - if (profileCount > 1) { const pType = $scope.block.profileType == 'GENDER' @@ -335,7 +334,6 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { .join(' ') .slice(1) .toLowerCase(); - modalMessage.error( 'Only one ' + pType + ' profile block can be used per form.', ); @@ -344,7 +342,6 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { } } }; - $scope.registrationTypeName = function (id) { if (!id) { return; From c59e3d0a12531f71004c627c67e95c88e3920eef Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Fri, 4 Aug 2023 20:49:31 -0700 Subject: [PATCH 5/5] Add tests for when multiple question types are set as Cru Profile --- app/scripts/directives/blockEditor.js | 32 +++++++++++++----------- test/spec/directives/blockEditor.spec.js | 23 +++++++++++++++++ test/spec/testData.spec.js | 13 ++++++++++ 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/app/scripts/directives/blockEditor.js b/app/scripts/directives/blockEditor.js index 078e5d1d8..860c1f1e8 100644 --- a/app/scripts/directives/blockEditor.js +++ b/app/scripts/directives/blockEditor.js @@ -171,19 +171,19 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { true, ); - var typeToProfile = []; - //typeToProfile['emailQuestion'] = 'EMAIL'; - //typeToProfile['nameQuestion'] = 'NAME'; - typeToProfile.phoneQuestion = 'PHONE'; - typeToProfile.addressQuestion = 'ADDRESS'; - typeToProfile.genderQuestion = 'GENDER'; - typeToProfile.yearInSchoolQuestion = 'YEAR_IN_SCHOOL'; - typeToProfile.birthDateQuestion = 'BIRTH_DATE'; - typeToProfile.campusQuestion = 'CAMPUS'; - typeToProfile.dormitoryQuestion = 'DORMITORY'; + $scope.typeToProfile = []; + //$scope.typeToProfile['emailQuestion'] = 'EMAIL'; + //$scope.typeToProfile['nameQuestion'] = 'NAME'; + $scope.typeToProfile.phoneQuestion = 'PHONE'; + $scope.typeToProfile.addressQuestion = 'ADDRESS'; + $scope.typeToProfile.genderQuestion = 'GENDER'; + $scope.typeToProfile.yearInSchoolQuestion = 'YEAR_IN_SCHOOL'; + $scope.typeToProfile.birthDateQuestion = 'BIRTH_DATE'; + $scope.typeToProfile.campusQuestion = 'CAMPUS'; + $scope.typeToProfile.dormitoryQuestion = 'DORMITORY'; $scope.profileCheck = !_.isNull($scope.block.profileType); - $scope.profileOption = _.has(typeToProfile, $scope.block.type); + $scope.profileOption = _.has($scope.typeToProfile, $scope.block.type); $scope.requiredOption = !_.includes( ['paragraphContent'], $scope.block.type, @@ -315,8 +315,8 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { if (!value) { $scope.block.profileType = null; } else { - $scope.block.profileType = typeToProfile[$scope.block.type]; - var profileCount = 0; + $scope.block.profileType = $scope.typeToProfile[$scope.block.type]; + let profileCount = 0; $scope.conference.registrationPages.forEach(function (page) { page.blocks.forEach(function (block) { if ($scope.block.profileType === block.profileType) { @@ -325,7 +325,7 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { }); }); if (profileCount > 1) { - const pType = + $scope.pType = $scope.block.profileType == 'GENDER' ? 'Sex' : $scope.block.profileType.charAt(0).toUpperCase() + @@ -335,7 +335,9 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () { .slice(1) .toLowerCase(); modalMessage.error( - 'Only one ' + pType + ' profile block can be used per form.', + 'Only one ' + + $scope.pType + + ' profile block can be used per form.', ); $scope.block.profileType = null; $scope.profileCheck = false; diff --git a/test/spec/directives/blockEditor.spec.js b/test/spec/directives/blockEditor.spec.js index b39c0a15d..58127c1de 100644 --- a/test/spec/directives/blockEditor.spec.js +++ b/test/spec/directives/blockEditor.spec.js @@ -53,4 +53,27 @@ describe('Directive: blockEditor', function () { expect(scope.block.content.choices[4].operand).toBe('OR'); }); + + it('should not create an error message if there are not multiple questions with the same Cru Profile type', function () { + const block = _.find(testData.conference.registrationPages[1].blocks, { + id: '9b83eebd-b064-4edf-92d0-7982a330272b', + }); + scope.block = block; + scope.block.profileType = null; + + scope.toggleProfileType(true); + + expect(scope.pType).toBeUndefined(); + }); + + it('Duplicate Cru Profile Gender Question: Changes gender to sex in error message', function () { + const block = _.find(testData.conference.registrationPages[1].blocks, { + id: '9b83eebd-b064-4edf-92d0-7982a330272a', + }); + scope.block = block; + + scope.toggleProfileType(true); + + expect(scope.pType).toBe('Sex'); + }); }); diff --git a/test/spec/testData.spec.js b/test/spec/testData.spec.js index 8f35df12e..4a6976777 100644 --- a/test/spec/testData.spec.js +++ b/test/spec/testData.spec.js @@ -303,6 +303,19 @@ angular.module('confRegistrationWebApp').service('testData', function () { }, ], }, + { + id: '9b83eebd-b064-4edf-92d0-7982a330272b', + pageId: '7b4c19df-7377-4d37-90fb-5b262bb66d1a', + title: 'Sex', + exportFieldTitle: null, + type: 'genderQuestion', + required: false, + position: 9, + content: '', + profileType: 'GENDER', + registrantTypes: [], + rules: [], + }, { adminOnly: 'false', content: {