-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
1,148 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// JS for iRODS request page | ||
$(document).ready(function () { | ||
// Disable "Accept Selected" and "Reject Selected" options by default | ||
$('#sodar-ss-accept-selected').addClass('disabled'); | ||
$('#sodar-ss-reject-selected').addClass('disabled'); | ||
|
||
// Enable "Accept Selected" and "Reject Selected" options if at least one | ||
// checkbox is checked or if the "Select All" checkbox is checked | ||
$('.sodar-ss-checkbox-item').change(function () { | ||
var checkedCheckboxes = $('.sodar-ss-checkbox-item:checked'); | ||
if (checkedCheckboxes.length > 0) { | ||
$('#sodar-ss-accept-selected').removeClass('disabled'); | ||
$('#sodar-ss-reject-selected').removeClass('disabled'); | ||
} else { | ||
$('#sodar-ss-accept-selected').addClass('disabled'); | ||
$('#sodar-ss-reject-selected').addClass('disabled'); | ||
} | ||
// Uncheck "Select All" if any checkbox is unchecked | ||
if (checkedCheckboxes.length < $('.sodar-ss-checkbox-item').length) { | ||
$('#sodar-ss-request-check-all').prop('checked', false); | ||
} else { | ||
$('#sodar-ss-request-check-all').prop('checked', true); | ||
} | ||
}); | ||
}); | ||
|
||
/***************** | ||
Manage checkboxes | ||
*****************/ | ||
function checkAll(elem) { | ||
// Enable if unchecked and disable if checked and show/hide buttons | ||
$('.sodar-ss-checkbox-item').not(':disabled').each(function () { | ||
$(this).prop('checked', elem.checked); | ||
}); | ||
if (elem.checked) { | ||
$('#sodar-ss-accept-selected').removeClass('disabled'); | ||
$('#sodar-ss-reject-selected').removeClass('disabled'); | ||
} | ||
else { | ||
$('#sodar-ss-accept-selected').addClass('disabled'); | ||
$('#sodar-ss-reject-selected').addClass('disabled'); | ||
} | ||
} | ||
|
||
/***************** | ||
* Accept or reject selected | ||
*****************/ | ||
function sendRequest(url) { | ||
var checkboxes = document.querySelectorAll('.sodar-checkbox'); | ||
var selectedRequests = []; | ||
|
||
checkboxes.forEach(function(checkbox) { | ||
if (checkbox.checked && checkbox.value !== 'on') { | ||
selectedRequests.push(checkbox.value); | ||
} | ||
}); | ||
|
||
// Create a form to send the POST request | ||
var form = document.createElement('form'); | ||
form.setAttribute('method', 'post'); | ||
form.setAttribute('action', url); | ||
|
||
// Create a CSRF token input field | ||
var csrfToken = jQuery("[name=csrfmiddlewaretoken]").val(); | ||
var csrfField = document.createElement('input'); | ||
csrfField.setAttribute('type', 'hidden'); | ||
csrfField.setAttribute('name', 'csrfmiddlewaretoken'); | ||
csrfField.setAttribute('value', csrfToken); | ||
form.appendChild(csrfField); | ||
|
||
// Add the data to the form | ||
var hiddenField = document.createElement('input'); | ||
hiddenField.setAttribute('type', 'hidden'); | ||
hiddenField.setAttribute('name', 'irods_requests'); | ||
hiddenField.setAttribute('value', selectedRequests.join(',')); | ||
form.appendChild(hiddenField); | ||
document.body.appendChild(form); | ||
|
||
// Submit the form | ||
form.submit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="btn-group ml-auto" id="sodar-ff-buttons-list"> | ||
{% csrf_token %} | ||
<button class="btn btn-primary dropdown-toggle" | ||
type="button" data-toggle="dropdown" | ||
aria-haspopup="true" aria-expanded="false"> | ||
Request Operations | ||
</button> | ||
<div class="dropdown-menu dropdown-menu-right"> | ||
|
||
{# Create Request #} | ||
<a href="{% url 'samplesheets:irods_request_create' project=project.sodar_uuid %}" | ||
class="dropdown-item" role="button"> | ||
<i class="iconify" data-icon="mdi:plus-thick"></i> Create Request | ||
</a> | ||
|
||
{# Accept Selected #} | ||
<a class="dropdown-item" id="sodar-ss-accept-selected" | ||
href="javascript:{}" | ||
onclick="sendRequest('{% url 'samplesheets:irods_request_accept_batch' project=project.sodar_uuid %}');"> | ||
<i class="iconify" data-icon="mdi:check-bold"></i> Accept Selected | ||
</a> | ||
|
||
{# Reject Selected #} | ||
<a class="dropdown-item" id="sodar-ss-reject-selected" | ||
href="javascript:{}" | ||
onclick="sendRequest('{% url 'samplesheets:irods_request_reject_batch' project=project.sodar_uuid %}');"> | ||
<i class="iconify" data-icon="mdi:close-thick"></i> Reject Selected | ||
</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.