forked from enviPath/enviPy
Implement functionality to assigne Licenses to Packages and show existing Licenses (#17)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#17
This commit is contained in:
153
templates/modals/objects/set_license_modal.html
Normal file
153
templates/modals/objects/set_license_modal.html
Normal file
@ -0,0 +1,153 @@
|
||||
<div class="modal fade"
|
||||
tabindex="-1"
|
||||
id="set_license_modal"
|
||||
role="dialog"
|
||||
aria-labelledby="set_license_modal"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button"
|
||||
class="close"
|
||||
data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
<span class="sr-only">Close</span>
|
||||
</button>
|
||||
<h3 class="modal-title">Set License</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<p>
|
||||
Set the license for all data in this package:
|
||||
<br> <br>
|
||||
(For more information please visit our <a target="#"
|
||||
href="https://wiki.envipath.org/index.php/License">wiki</a>.)
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div id="ccfig"></div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="set_license_form" accept-charset="UTF-8" action="" data-remote="true" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="optlicense" onclick="cc()" id="ccradio">Creative commons license</label>
|
||||
</div>
|
||||
<div>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" value="" onclick="cc()" id="ccremix" disabled>Allow adaptations of your work to be shared</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" value="" onclick="cc()" id="ccnocom" disabled>Prohibit commercial use</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" value="" onclick="cc()" id="ccalike" disabled>Share only if others share alike</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="optlicense" onclick="cc()" id="noccradio">No creative commons license, contact package owner for license information</label>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="license" name="license">
|
||||
<input type="hidden" id="license-link" name="license-link">
|
||||
<input type="hidden" id="license-image-link" name="license-image-link">
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="set_license_form_submit" class="btn btn-primary">Submit</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
function ccstring(ccremix, ccnocom, ccalike){
|
||||
var ccstring = "by";
|
||||
|
||||
if(ccnocom){
|
||||
ccstring +="-nc";
|
||||
}
|
||||
|
||||
if(!ccremix){
|
||||
ccstring +="-nd";
|
||||
} else{
|
||||
if(ccalike){
|
||||
ccstring +="-sa";
|
||||
}
|
||||
}
|
||||
return ccstring;
|
||||
}
|
||||
|
||||
function cc() {
|
||||
var nocc = $('#noccradio').prop('checked')
|
||||
var iscc = $('#ccradio').prop('checked');
|
||||
|
||||
if(nocc) {
|
||||
$('#ccradio').prop('checked', false);
|
||||
$('#ccremix').prop('checked', false);
|
||||
$('#ccnocom').prop('checked', false);
|
||||
$('#ccalike').prop('checked', false);
|
||||
|
||||
$('#ccremix').prop('disabled', true);
|
||||
$('#ccnocom').prop('disabled', true);
|
||||
$('#ccalike').prop('disabled', true);
|
||||
} else if (iscc) {
|
||||
$('#ccremix').prop('disabled', false);
|
||||
$('#ccnocom').prop('disabled', false);
|
||||
|
||||
if ($('#ccremix').prop('checked')) {
|
||||
$('#ccalike').prop('disabled', false);
|
||||
} else {
|
||||
$('#ccalike').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
var remix = $('#ccremix').prop('checked');
|
||||
var nocom = $('#ccnocom').prop('checked');
|
||||
var alike = $('#ccalike').prop('checked');
|
||||
|
||||
if(nocc) {
|
||||
$('#set_license_form_submit').prop('disabled', false);
|
||||
$('#ccfig').empty();
|
||||
$('#license').val('no-license')
|
||||
} else if(iscc) {
|
||||
$('#set_license_form_submit').prop('disabled', false);
|
||||
$('#ccfig').empty();
|
||||
var ccstr = ccstring(remix, nocom, alike)
|
||||
|
||||
var link = `https://creativecommons.org/licenses/${ccstr}/4.0/`;
|
||||
var imageLink = `https://licensebuttons.net/l/${ccstr}/4.0/88x31.png`;
|
||||
|
||||
var img_tpl = `<a href='${link}' target="_blank">
|
||||
<img src='${imageLink}'>
|
||||
</a>`;
|
||||
|
||||
$('#ccfig').append(img_tpl);
|
||||
$('#license').val(ccstr);
|
||||
$('#license-link').val(link);
|
||||
$('#license-image-link').val(imageLink);
|
||||
} else {
|
||||
$('#ccfig').empty();
|
||||
$('#set_license_form_submit').prop('disabled', true);
|
||||
$('#license').val('no-license')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// Disable by default as nothing is selected
|
||||
|
||||
cc();
|
||||
$('#set_license_form_submit').prop('disabled', true);
|
||||
|
||||
$('#set_license_form_submit').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('#set_license_form').submit();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user