Skip to content

Commit

Permalink
EVENT-825 Campus Question Force Selection Option (#837)
Browse files Browse the repository at this point in the history
Make the Campus Profile question require a predefined selection
  • Loading branch information
caleballdrin committed Aug 15, 2023
1 parent b2e1123 commit b13cbe8
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/scripts/controllers/angularUiTreeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ angular
event.dest.index,
block.defaultTitle,
block.defaultProfile,
block.defaultExportFieldTitle,
);
}
return false; //cancel regular drop action
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/controllers/eventDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,10 @@ angular
});
return {
id: existingChild ? existingChild.id : uuid(),
name: t.name,
childRegistrantTypeId: t.id,
numberOfChildRegistrants: existingChild
? existingChild.numberOfChildRegistrants
: 0,
selected:
existingChild !== undefined &&
existingChild.selected !== false,
};
},
);
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/controllers/eventForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ angular
newPosition,
title,
defaultProfile,
defaultExportFieldTitle,
) {
var newPageIndex = _.findIndex($scope.conference.registrationPages, {
id: newPage,
Expand Down Expand Up @@ -286,6 +287,7 @@ angular
profileType: profileType,
registrantTypes: [],
rules: [],
exportFieldTitle: defaultExportFieldTitle,
};

$scope.conference.registrationPages[newPageIndex].blocks.splice(
Expand Down
14 changes: 11 additions & 3 deletions app/scripts/directives/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,17 @@ angular
restrict: 'E',
controller: function ($scope, $http) {
$scope.searchCampuses = function (val) {
return $http.get('campuses/' + val).then(function (campusNames) {
return campusNames.data;
});
$scope.params = {
limit: 15,
};
$scope.params = $scope.block.content.showInternationalCampuses
? Object.assign($scope.params, { includeInternational: true })
: $scope.params;
return $http
.get('campuses/' + val, { params: $scope.params })
.then(function (campusNames) {
return campusNames.data;
});
};
},
};
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/directives/questionToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ angular
},
{
id: 'campusQuestion',
defaultTitle: 'Campus',
defaultTitle:
'Campus - Type the full name of your campus and choose from the list that appears',
defaultProfile: 'CAMPUS',
iconClass: 'fa-university',
name: 'Campus',
defaultExportFieldTitle: 'Campus',
},
{
id: 'dormitoryQuestion',
Expand Down
4 changes: 4 additions & 0 deletions app/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,7 @@ pick-a-time {
.padding-left-0 {
padding-left: 0px !important;
}
campus-question .dropdown-menu.ng-isolate-scope:not(.ng-hide) {
max-height: 200px !important;
overflow-y: auto !important;
}
14 changes: 11 additions & 3 deletions app/views/blocks/campusQuestion.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
<input
type="text"
ng-model="answer.value"
ng-model-options="{ debounce: 1000 }"
placeholder=""
autocomplete="off"
aria-autocomplete="none"
class="form-control"
show-errors
ng-required="block.required"
uib-typeahead="campus for campus in searchCampuses($viewValue)"
typeahead-loading="loadingCampuses"
typeahead-min-length="4"
typeahead-wait-ms="300"
typeahead-min-length="2"
typeahead-wait-ms="200"
typeahead-editable="false"
typeahead-no-results="campusNotFound"
typeahead-show-hint="true"
/>
<span
class="form-control-feedback"
Expand All @@ -18,4 +23,7 @@
>
<i class="fa fa-spinner fa-spin"></i>
</span>
<span ng-if="campusNotFound" class="help-block" translate
>*Campus not found. Type the full name of your campus.</span
>
</div>
9 changes: 9 additions & 0 deletions app/views/components/blockEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@
<translate>Hide "Graduate Student" option</translate></label
>
</div>
<div class="checkbox" ng-if="block.type === 'campusQuestion'">
<label
><input
type="checkbox"
ng-model="block.content.showInternationalCampuses"
/>
<translate>Include International Campuses</translate></label
>
</div>

<div
class="help-block"
Expand Down
43 changes: 43 additions & 0 deletions test/spec/directives/block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,49 @@ describe('Directive: blocks', () => {
});
});

describe('campusQuestion', () => {
let $compile, $rootScope, $scope;
beforeEach(inject((
_$compile_,
_$rootScope_,
_$timeout_,
$templateCache,
testData,
) => {
$compile = _$compile_;
$rootScope = _$rootScope_;

$scope = $rootScope.$new();
$templateCache.put('views/blocks/campusQuestion.html', '');
$scope.block = _.cloneDeep(
testData.conference.registrationPages[1].blocks[4],
);
$scope.block.content.showInternationalCampuses = true;
}));

it('forms the searchCampuses params correctly', () => {
$scope.block.content.showInternationalCampuses = true;
$compile('<campus-question></campus-question>')($scope);
$scope.$digest();

$scope.searchCampuses('San');

expect($scope.params.limit).toBeDefined();

expect($scope.params.includeInternational).toBeDefined();
});

it("doesn't add includeInternational", () => {
$scope.block.content.showInternationalCampuses = false;
$compile('<campus-question></campus-question>')($scope);
$scope.$digest();

$scope.searchCampuses('San');

expect($scope.params.includeInternational).not.toBeDefined();
});
});

describe('ethnicityQuestion', () => {
let $compile, $rootScope, $scope, $timeout;
beforeEach(inject((
Expand Down

0 comments on commit b13cbe8

Please sign in to comment.