diff --git a/src/js/app/challenge-details/index.html b/src/js/app/challenge-details/index.html
index 9060667a..d2819ef2 100644
--- a/src/js/app/challenge-details/index.html
+++ b/src/js/app/challenge-details/index.html
@@ -728,6 +728,21 @@
Share:
diff --git a/src/js/app/challenge-details/js/controllers/challenge-details-controller.js b/src/js/app/challenge-details/js/controllers/challenge-details-controller.js
index 7c46fbce..e4e8ab19 100644
--- a/src/js/app/challenge-details/js/controllers/challenge-details-controller.js
+++ b/src/js/app/challenge-details/js/controllers/challenge-details-controller.js
@@ -80,6 +80,7 @@
vm.checkpointPassedScreeningSubmitterPercentage = 0;
vm.checkpointPassedScreeningSubmissionPercentage = 0;
vm.phaseProgram = null;
+ vm.termsList = [];
$interval(function () {
if (vm.challenge && vm.challenge.currentPhaseRemainingTime) {
@@ -161,6 +162,9 @@
* @param ChallengeService
*/
function initChallengeDetail(handle, vm, ChallengeService) {
+ ChallengeService.getChallengeTerms(challengeId).then(function(termsList) {
+ vm.termsList = termsList;
+ });
ChallengeService
.getChallenge(challengeId)
.then(function (challenge) {
diff --git a/src/js/app/challenge-details/js/services/challenge-details-services.js b/src/js/app/challenge-details/js/services/challenge-details-services.js
index d943a5dc..c73f9510 100644
--- a/src/js/app/challenge-details/js/services/challenge-details-services.js
+++ b/src/js/app/challenge-details/js/services/challenge-details-services.js
@@ -100,6 +100,19 @@
return defer.promise;
};
+ service.getChallengeTerms = function(id) {
+ var defer = $q.defer();
+
+ service
+ .one('terms', id)
+ .getList('', {noauth: true, role: 'Submitter'}).then(function(data) {
+ data = data[0].terms;
+ defer.resolve(data);
+ });
+
+ return defer.promise;
+ }
+
service.getPeerReviewResults = function(id) {
var defer = $q.defer();
diff --git a/src/js/terms.js b/src/js/terms.js
index 0033d69c..fae1e09e 100644
--- a/src/js/terms.js
+++ b/src/js/terms.js
@@ -27,102 +27,104 @@ appChallengeTerms = {
},
initDetail: function (tcjwt) {
- if (app.isLoggedIn()) {
- app.setLoading();
- $.ajax({
- type: "GET",
- url: tcconfig.apiURL + "/terms/detail/" + termsOfUseID,
- dataType: 'json',
- headers: {
- 'Authorization': 'Bearer ' + tcjwt.replace(/["]/g, "")
- },
- success: function(data) {
- $(".formContent").addClass("pageContent");
- if (data.title) {
- $(".formContent .terms").show();
- $(".formContent .warning").hide();
- $(".overviewPageTitle").text(data["title"]);
- //Bugfix I-116354
- $('#agreement-section').removeClass('hide');
-
- if (data.agreeabilityType === 'Non-electronically-agreeable') {
- $('#agreement-section').addClass('hide');
- $('.loading').hide();
- $(".termsText").html(data.text);
- } else if (data["agreeabilityType"] !== "Electronically-agreeable" && typeof data["docusignTemplateId"] !== "undefined") {
- //if DocuSign, get URL from docuSign API and output iframe
- $('.agree-label').hide();
- $('#termSubmit').text('Go Back');
- $('.agreement').removeClass('notAgreed');
- var finalDest = escape(tcconfig.mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType + "&cb=" + Math.random());
- $.ajax({
- url: tcconfig.apiURL + '/terms/docusign/viewURL',
- type: 'POST',
- data: {
- templateId: data["docusignTemplateId"],
- returnUrl: tcconfig.mainURL + "/iframe-break/?dest=" + finalDest
- },
- cache: false,
- beforeSend: function(bxhr) {
- bxhr.setRequestHeader('Authorization', 'Bearer ' + tcjwt.replace(/["]/g, ""));
- },
- complete: function(docuData) {
- $('.loading').hide();
- //output iframe when AJAX data returns
- var responseObj = docuData.responseJSON;
- if (typeof responseObj["recipientViewUrl"] !== "undefined") {
- $(".termsText").html('');
- } else {
- //url not in data result, error
- $(".formContent .terms").hide();
- $(".formContent .warning").text(responseObj["description"]);
- $(".formContent .warning").show();
- }
- },
- error: function(jqXHR, textStatus, errorThrown) {
- // Handle errors here
- $(".termsText").html('Sorry, your request could not be completed at this time.');
- }
- });
- } else {
- $('.loading').hide();
- //if not docuSign, output normal terms text
- $(".termsText").html(data["text"]);
+ app.setLoading();
+ $.ajax({
+ type: "GET",
+ url: tcconfig.apiURL + "/terms/detail/" + termsOfUseID + (app.isLoggedIn() ? '' : '?noauth=true'),
+ dataType: 'json',
+ headers: app.isLoggedIn() ? {
+ 'Authorization': 'Bearer ' + tcjwt.replace(/["]/g, "")
+ } : {},
+ success: function(data) {
+ $(".formContent").addClass("pageContent");
+ if (data.title) {
+ $(".formContent .terms").show();
+ $(".formContent .warning").hide();
+ $(".overviewPageTitle").text(data["title"]);
+ //Bugfix I-116354
+ $('#agreement-section').removeClass('hide');
+
+ if (data.agreeabilityType === 'Non-electronically-agreeable') {
+ $('#agreement-section').addClass('hide');
+ $('.loading').hide();
+ $(".termsText").html(data.text);
+ } else if (data["agreeabilityType"] !== "Electronically-agreeable" && typeof data["docusignTemplateId"] !== "undefined") {
+ if (!app.isLoggedIn()) {
+ window.location.href = '/login?next=' + window.location.href;
}
+ //if DocuSign, get URL from docuSign API and output iframe
+ $('.agree-label').hide();
+ $('#termSubmit').text('Go Back');
+ $('.agreement').removeClass('notAgreed');
+ var finalDest = escape(tcconfig.mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType + "&cb=" + Math.random());
+ $.ajax({
+ url: tcconfig.apiURL + '/terms/docusign/viewURL',
+ type: 'POST',
+ data: {
+ templateId: data["docusignTemplateId"],
+ returnUrl: tcconfig.mainURL + "/iframe-break/?dest=" + finalDest
+ },
+ cache: false,
+ beforeSend: function(bxhr) {
+ bxhr.setRequestHeader('Authorization', 'Bearer ' + tcjwt.replace(/["]/g, ""));
+ },
+ complete: function(docuData) {
+ $('.loading').hide();
+ //output iframe when AJAX data returns
+ var responseObj = docuData.responseJSON;
+ if (typeof responseObj["recipientViewUrl"] !== "undefined") {
+ $(".termsText").html('');
+ } else {
+ //url not in data result, error
+ $(".formContent .terms").hide();
+ $(".formContent .warning").text(responseObj["description"]);
+ $(".formContent .warning").show();
+ }
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ // Handle errors here
+ $(".termsText").html('Sorry, your request could not be completed at this time.');
+ }
+ });
} else {
$('.loading').hide();
- $(".formContent .terms").hide();
- $(".formContent .warning").text(data["error"]["details"]);
- $(".formContent .warning").show();
+ //if not docuSign, output normal terms text
+ $(".termsText").html(data["text"]);
}
- $('#agree').change(function () {
- if ($(this).prop('checked')) {
- $(this).closest('section.agreement').removeClass('notAgreed');
- } else {
- $(this).closest('section.agreement').addClass('notAgreed');
- }
- });
- $("#termSubmit").click(function () {
- if ($(this).parents(".notAgreed").length === 0) {
- app.setLoading();
- $.ajax({
- type: "POST",
- url: tcconfig.apiURL + "/terms/" + termsOfUseID + "/agree",
- dataType: 'json',
- headers: {
- 'Authorization': 'Bearer ' + tcjwt.replace(/["]/g, "")
- },
- success: function(data) {
- window.location = tcconfig.mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType;
- $('.loading').hide();
- }
- });
- }
- });
+ } else {
+ $('.loading').hide();
+ $(".formContent .terms").hide();
+ $(".formContent .warning").text(data["error"]["details"]);
+ $(".formContent .warning").show();
}
- });
- } else {
- $('.actionLogin').click();
+ $('#agree').change(function () {
+ if ($(this).prop('checked')) {
+ $(this).closest('section.agreement').removeClass('notAgreed');
+ } else {
+ $(this).closest('section.agreement').addClass('notAgreed');
+ }
+ });
+ $("#termSubmit").click(function () {
+ if ($(this).parents(".notAgreed").length === 0) {
+ app.setLoading();
+ $.ajax({
+ type: "POST",
+ url: tcconfig.apiURL + "/terms/" + termsOfUseID + "/agree",
+ dataType: 'json',
+ headers: {
+ 'Authorization': 'Bearer ' + tcjwt.replace(/["]/g, "")
+ },
+ success: function(data) {
+ window.location = tcconfig.mainURL + "/challenge-details/terms/" + challengeId + "?challenge-type=" + challengeType;
+ $('.loading').hide();
+ }
+ });
+ }
+ });
+ }
+ });
+ if (!app.isLoggedIn()) {
+ $('#submitForm').hide();
}
},