Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVENT-822 Change Gender to Sex #836

Merged
merged 5 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions app/scripts/directives/blockEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -325,18 +325,25 @@ angular.module('confRegistrationWebApp').directive('blockEditor', function () {
});
});
if (profileCount > 1) {
$scope.pType =
$scope.block.profileType == 'GENDER'
? 'Sex'
: $scope.block.profileType.charAt(0).toUpperCase() +
$scope.block.profileType
.split('_')
.join(' ')
.slice(1)
.toLowerCase();
modalMessage.error(
'Only one ' +
$scope.block.profileType.charAt(0).toUpperCase() +
$scope.block.profileType.slice(1).toLowerCase() +
$scope.pType +
' profile block can be used per form.',
);
$scope.block.profileType = null;
$scope.profileCheck = false;
}
}
};

$scope.registrationTypeName = function (id) {
if (!id) {
return;
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/directives/questionToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ angular
},
{
id: 'genderQuestion',
defaultTitle: 'Gender',
defaultTitle: 'Sex',
defaultProfile: 'GENDER',
iconClass: 'fa-male',
name: 'Gender',
name: 'Sex',
},
{
id: 'yearInSchoolQuestion',
Expand Down
2 changes: 1 addition & 1 deletion app/views/components/blockEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
<translate>Question Rules can depend on questions of</translate>
<a
href=""
uib-tooltip="{{'Multiple Choice, Dropdown, Number, Date, Gender or Year in School' | translate}}"
uib-tooltip="{{'Multiple Choice, Dropdown, Number, Date, Sex or Year in School' | translate}}"
translate
>these types</a
>
Expand Down
2 changes: 1 addition & 1 deletion languages/ert.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions test/spec/directives/blockEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
15 changes: 14 additions & 1 deletion test/spec/testData.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand Down
Loading