Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
29 changes: 29 additions & 0 deletions src/js/app/challenge-details/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,21 @@ <h3>Challenge Links:</h3>
</div>

</li>
<li ng-if="!CD.isDesign && CD.termsList.length > 0" class="slide">
<div class="slideBox">
<h3>Challenge Terms:</h3>
<div class="inner">
<ul>
<li ng-repeat="terms in CD.termsList">
<a class="termsListLink" target="_blank" href="/challenge-details/terms/detail/{{terms.termsOfUseId}}/">
{{terms.title}}
</a>
</li>
</ul>
</div>
</div>
</li>

<li ng-hide="CD.isDesign || CD.isPeerReviewed" class="slide">

<div class="umltoolLinks slideBox">
Expand Down Expand Up @@ -811,6 +826,20 @@ <h3>Submission Limit:</h3>
</div>
</div>
</li>
<li ng-if="CD.isDesign && CD.termsList.length > 0" class="slide">
<div class="slideBox">
<h3>Challenge Terms:</h3>
<div class="inner">
<ul>
<li ng-repeat="terms in CD.termsList">
<a class="termsListLink" target="_blank" href="/challenge-details/terms/detail/{{terms.termsOfUseId}}/">
{{terms.title}}
</a>
</li>
</ul>
</div>
</div>
</li>
<li class="slide">
<div class="slideBox">
<h3>Share:</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
vm.checkpointPassedScreeningSubmitterPercentage = 0;
vm.checkpointPassedScreeningSubmissionPercentage = 0;
vm.phaseProgram = null;
vm.termsList = [];

$interval(function () {
if (vm.challenge && vm.challenge.currentPhaseRemainingTime) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
184 changes: 93 additions & 91 deletions src/js/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<iframe class="termsFrame" src="' + responseObj["recipientViewUrl"] + '"></iframe>');
} 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('<iframe class="termsFrame" src="' + responseObj["recipientViewUrl"] + '"></iframe>');
} 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();
}
},

Expand Down