From 0935df2db73abc625290dd5ffeeb13dae742d4b1 Mon Sep 17 00:00:00 2001 From: Paul Van Eck Date: Tue, 5 Jul 2016 15:03:18 -0700 Subject: [PATCH] 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 --- refstack-ui/app/components/guidelines/guidelines.html | 8 +++++--- .../app/components/guidelines/guidelinesController.js | 4 +++- .../components/results-report/resultsReportController.js | 4 +++- refstack-ui/tests/unit/ControllerSpec.js | 8 +++++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/refstack-ui/app/components/guidelines/guidelines.html b/refstack-ui/app/components/guidelines/guidelines.html index ce0fe691..06ba6e3a 100644 --- a/refstack-ui/app/components/guidelines/guidelines.html +++ b/refstack-ui/app/components/guidelines/guidelines.html @@ -4,9 +4,11 @@
Version: -
diff --git a/refstack-ui/app/components/guidelines/guidelinesController.js b/refstack-ui/app/components/guidelines/guidelinesController.js index b23eb32c..2153911d 100644 --- a/refstack-ui/app/components/guidelines/guidelinesController.js +++ b/refstack-ui/app/components/guidelines/guidelinesController.js @@ -66,7 +66,9 @@ ctrl.versionsRequest = $http.get(content_url).success(function (data) { 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(); }).error(function (error) { ctrl.showError = true; diff --git a/refstack-ui/app/components/results-report/resultsReportController.js b/refstack-ui/app/components/results-report/resultsReportController.js index b3aaf42b..24826d72 100644 --- a/refstack-ui/app/components/results-report/resultsReportController.js +++ b/refstack-ui/app/components/results-report/resultsReportController.js @@ -90,7 +90,9 @@ $http.get(content_url).success(function (data) { ctrl.versionList = data.sort().reverse(); 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(); }).error(function (error) { diff --git a/refstack-ui/tests/unit/ControllerSpec.js b/refstack-ui/tests/unit/ControllerSpec.js index c078ec02..b54dd721 100644 --- a/refstack-ui/tests/unit/ControllerSpec.js +++ b/refstack-ui/tests/unit/ControllerSpec.js @@ -91,14 +91,16 @@ describe('Refstack controllers', function () { }; $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. $httpBackend.expectGET(fakeApiUrl + '/guidelines/2015.04.json').respond(fakeCaps); $httpBackend.flush(); // The version list should be sorted latest first. - expect(ctrl.versionList).toEqual(['2015.04.json', - '2015.03.json']); + expect(ctrl.versionList).toEqual(['next.json', + '2015.04.json', + '2015.03.json']); expect(ctrl.guidelines).toEqual(fakeCaps); // The guideline status should be approved. expect(ctrl.guidelines.status).toEqual('approved');