diff --git a/projectroles/static/projectroles/js/project_detail.js b/projectroles/static/projectroles/js/project_detail.js index 676ddb26..51dc2b4f 100644 --- a/projectroles/static/projectroles/js/project_detail.js +++ b/projectroles/static/projectroles/js/project_detail.js @@ -1 +1,40 @@ -// TODO: Add remote site link updating here \ No newline at end of file +/* Project detail view specific JQuery */ + +/* Update target/peer remote project links once accessed */ +var updateRemoteProjectLinks = function() { + var linkUuids = []; + $('.sodar-pr-link-remote').each(function() { + if (!$(this).hasClass('sodar-pr-link-remote-source') + && $(this).attr('disabled') === 'disabled') { + linkUuids.push($(this).attr('data-uuid')); + } + }); + if (linkUuids.length > 0) { + var queryParams = [] + for (var i = 0; i < linkUuids.length; i++) { + queryParams.push(['rp', linkUuids[i]]) + } + $.ajax({ + url: window.remoteLinkUrl + '?' + new URLSearchParams(queryParams), + method: 'GET', + dataType: 'JSON', + }).done(function (data) { + for (var k in data) { + var elem = $('a[data-uuid="' +k + '"]'); + if (elem.attr('disabled') === 'disabled' && data[k] === true) { + elem.removeAttr('disabled'); + } + } + }); + }}; + +$(document).ready(function() { + // Set up remote project link updating, omit categories + if ($('div#sodar-pr-page-container-detail').attr( + 'data-project-type') === 'PROJECT') { + updateRemoteProjectLinks(); + setInterval(function () { + updateRemoteProjectLinks(); + }, 5000); + } +}); diff --git a/projectroles/templates/projectroles/_remote_project_link.html b/projectroles/templates/projectroles/_remote_project_link.html index 3a08b8ad..ef493081 100644 --- a/projectroles/templates/projectroles/_remote_project_link.html +++ b/projectroles/templates/projectroles/_remote_project_link.html @@ -1,10 +1,9 @@ {% load projectroles_common_tags %} -{# TODO: Add UUID as data attribute #} -{# TODO: Add JQuery to enable accessed target projects #} +
{# Links to remote projects #} {% if object.type == 'PROJECT' %} {% if target_projects %} @@ -120,12 +122,17 @@

{% block javascript %} {{ block.super }} + {% if object.type == 'CATEGORY' %} {% endif %} + +