Default guideline to latest approved guideline

On the guidelines and results report page, the default guideline
selected should not be the draft 'next.json' guideline, but should
instead be the most recent approved guideline.

Change-Id: Ia21bd05046c2faeb75efd069cf99d81369fc5abf
This commit is contained in:
Paul Van Eck 2016-07-05 15:03:18 -07:00
parent a74df017ae
commit 0935df2db7
4 changed files with 16 additions and 8 deletions

View File

@ -4,9 +4,11 @@
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<strong>Version:</strong> <strong>Version:</strong>
<select ng-model="ctrl.version" ng-change="ctrl.update()" class="form-control"> <!-- Slicing the version file name here gets rid of the '.json' file extension -->
<!-- Slicing the version file name here gets rid of the '.json' file extension. --> <select ng-model="ctrl.version"
<option ng-repeat="versionFile in ctrl.versionList" value="{{versionFile}}">{{versionFile.slice(0, -5)}}</option> ng-change="ctrl.update()"
class="form-control"
ng-options="versionFile.slice(0,-5) for versionFile in ctrl.versionList">
</select> </select>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">

View File

@ -66,7 +66,9 @@
ctrl.versionsRequest = ctrl.versionsRequest =
$http.get(content_url).success(function (data) { $http.get(content_url).success(function (data) {
ctrl.versionList = data.sort().reverse(); ctrl.versionList = data.sort().reverse();
ctrl.version = ctrl.versionList[0]; // Default to the first approved guideline which is expected
// to be at index 1.
ctrl.version = ctrl.versionList[1];
ctrl.update(); ctrl.update();
}).error(function (error) { }).error(function (error) {
ctrl.showError = true; ctrl.showError = true;

View File

@ -90,7 +90,9 @@
$http.get(content_url).success(function (data) { $http.get(content_url).success(function (data) {
ctrl.versionList = data.sort().reverse(); ctrl.versionList = data.sort().reverse();
if (!ctrl.version) { if (!ctrl.version) {
ctrl.version = ctrl.versionList[0]; // Default to the first approved guideline which is
// expected to be at index 1.
ctrl.version = ctrl.versionList[1];
} }
ctrl.updateGuidelines(); ctrl.updateGuidelines();
}).error(function (error) { }).error(function (error) {

View File

@ -91,14 +91,16 @@ describe('Refstack controllers', function () {
}; };
$httpBackend.expectGET(fakeApiUrl + $httpBackend.expectGET(fakeApiUrl +
'/guidelines').respond(['2015.03.json', '2015.04.json']); '/guidelines').respond(['next.json', '2015.03.json',
'2015.04.json']);
// Should call request with latest version. // Should call request with latest version.
$httpBackend.expectGET(fakeApiUrl + $httpBackend.expectGET(fakeApiUrl +
'/guidelines/2015.04.json').respond(fakeCaps); '/guidelines/2015.04.json').respond(fakeCaps);
$httpBackend.flush(); $httpBackend.flush();
// The version list should be sorted latest first. // The version list should be sorted latest first.
expect(ctrl.versionList).toEqual(['2015.04.json', expect(ctrl.versionList).toEqual(['next.json',
'2015.03.json']); '2015.04.json',
'2015.03.json']);
expect(ctrl.guidelines).toEqual(fakeCaps); expect(ctrl.guidelines).toEqual(fakeCaps);
// The guideline status should be approved. // The guideline status should be approved.
expect(ctrl.guidelines.status).toEqual('approved'); expect(ctrl.guidelines.status).toEqual('approved');