366 lines
15 KiB
HTML
366 lines
15 KiB
HTML
{% extends "users/base.html" %}
|
|
{% load crispy_forms_tags %}
|
|
{% load counter_tag %}
|
|
{% block content %}
|
|
<div class="content-section col-12">
|
|
<h3>Standard bearbeiten{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Aktualisieren Sie hier die Informationen des Standards." class="far fa-question-circle"></i></small>{% endif %}</h3>
|
|
<hr>
|
|
<form method="POST" id="taskareaform">
|
|
{% csrf_token %}
|
|
|
|
<div class="row"><div class="col-8">
|
|
{% for field in normalForm %}
|
|
{% if forloop.counter|divisibleby:5 %}
|
|
</div><div class="col-3">
|
|
{{field|as_crispy_field }}
|
|
{% else %}
|
|
{{field|as_crispy_field }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
<!-- COLLAPSE AREA FOR GROUPS FILES AND LINKED STANDARDS -->
|
|
<div class="accordion" style="margin-top: 47px" id="additionalStandardInfos">
|
|
<div class="card">
|
|
<div class="card-header" id="st_groups">
|
|
<h5 class="mb-0">
|
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#stgroups_content" aria-expanded="false" aria-controls="stgroups_content">
|
|
Gruppen{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Legen Sie fest, welche Gruppe diesen Standard sehen kann. Ist keine ausgewählt, ist der Standard für alle sichtbar." class="far fa-question-circle"></i></small>{% endif %}
|
|
</button>
|
|
</h5>
|
|
</div>
|
|
<div id="stgroups_content" class="collapse" aria-labelledby="st_groups" data-parent="#additionalStandardInfos">
|
|
<div class="card-body">
|
|
{% for g in agencygroups %}
|
|
<div class="custom-control custom-checkbox mb-2">
|
|
{% if g in standard.visibleby.all %}
|
|
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:groupsChange({{g.pk}}, this.checked)" name="group_{{g.pk}}" id="group_{{g.pk}}" checked="true">
|
|
{% else %}
|
|
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:groupsChange({{g.pk}}, this.checked)" name="group_{{g.pk}}" id="group_{{g.pk}}">
|
|
{% endif %}
|
|
|
|
<label class="custom-control-label" for="group_{{g.pk}}" >{{g.agencygroupname}}</label>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% if request.user.profile.agency.module_files %}
|
|
<div class="card">
|
|
<div class="card-header" id="st_files">
|
|
<h5 class="mb-0">
|
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#st_files_content" aria-expanded="false" aria-controls="st_files_content">
|
|
Dateien{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Fügen Sie ihren Standards Dateien zu. Diese liegen entweder bereits unter Dateien oder können iher direkt hochgeladen werden. Neu hochgeladene Dateien werden im Heimverzeichnis gespeichert." class="far fa-question-circle"></i></small>{% endif %}
|
|
</button>
|
|
</h5>
|
|
</div>
|
|
<div id="st_files_content" class="collapse" aria-labelledby="st_files" data-parent="#additionalStandardInfos">
|
|
<div class="card-body">
|
|
<div class="input-group mb-3">
|
|
<input class="form-control searchuserfieldstask" list="possfiles" id="searchfiles" type="text" onkeyup="javascript:updateLinkedFiles()" >
|
|
<div class="input-group-append">
|
|
<button type="button" onclick="javascript:clearSearchfieldAddFile()" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
|
</div>
|
|
<datalist id="possfiles">
|
|
{% for f in possibleFilesByVisible %}
|
|
<option id="file_{{f.pk}}" value="{{f.name}}">{{f.name}}</option>
|
|
{% endfor %}
|
|
</datalist>
|
|
</div>
|
|
Verlinkte Dateien:
|
|
<table id="linkedfiles" class="table table-hover table-sm">
|
|
{% for f in standard.addedfiles.all %}
|
|
<tr id="fileadded_{{f.pk}}"><td>{{f.name|truncatechars:30}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remFile({{f.pk}}, '{{f.name}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
|
{% endfor %}
|
|
</table>
|
|
<input type="file" id="uploadedfile" name="uploadedfile" style="display:none">
|
|
{% if user|usergperm:"filesmanager" %}
|
|
<div class="alert alert-secondary text-center mt-5" id="directdiv" role="alert" style="line-height: 17px; text-align: center;">
|
|
<button type="button" class="btn btn-primary btn-sm" id="uploadButton" onclick="javascript:uploadButtonPush()"><i class="fas fa-plus"></i></button> <small>klicken/hineinziehen<p class="mt-2">Dateien werden im <b>Heimverzeichnis</b>gespeichert.
|
|
</small></p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
<div class="card">
|
|
<div class="card-header" id="st_linked">
|
|
<h5 class="mb-0">
|
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#st_linked_content" aria-expanded="false" aria-controls="st_linked_content">
|
|
Standards{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Verlinken Sie hier andere Standards, die etwas mit diesem Standard zutun haben." class="far fa-question-circle"></i></small>{% endif %}
|
|
</button>
|
|
</h5>
|
|
</div>
|
|
<div id="st_linked_content" class="collapse" aria-labelledby="st_linked" data-parent="#additionalStandardInfos">
|
|
<div class="card-body">
|
|
<div class="input-group mb-3">
|
|
<input class="form-control" list="possstandards" id="searchstandards" type="text" onkeyup="javascript:updateLinkedStandards()" >
|
|
<div class="input-group-append">
|
|
<button type="button" onclick="javascript:clearSearchfieldAddStandard()" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
|
</div>
|
|
<datalist id="possstandards">
|
|
{% for s in possiblestandards %}
|
|
{% if s.pk != standard.pk %}
|
|
<option id="standard_{{s.pk}}" value="{{s.name|truncatechars:30}}">{{s.name|truncatechars:30}}</option>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</datalist>
|
|
</div>
|
|
Verlinkte Standards:
|
|
<table id="linkedstandards" class="table table-hover table-sm">
|
|
{% for s in standard.linked_standards.all %}
|
|
<tr id="standardadded_{{s.pk}}"><td>{{s.name|truncatechars:30}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remStandard({{s.pk}}, '{{s.name|truncatechars:30}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
|
{% endfor %}
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<p>Wenn ein Standard bearbeitet wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> wieder veröffentlicht werden. Ein Standard wird nach Bearbeitung als <i>Nicht veröffentlicht</i> gesetzt.</p>
|
|
<hr>
|
|
<button type="submit" class="btn btn-success" href="{% url 'standard-update' standard_id %} ">Aktualisieren</button>
|
|
|
|
{% if perms.users.standard_management %}
|
|
{% if standard_status == False %}
|
|
<a class="btn btn-primary" href="{% url 'standard-status' standard_id %} ">Standard veröffentlichen</a>
|
|
{% else %}
|
|
<a class="btn btn-warning" href="{% url 'standard-status' standard_id %} ">Veröffentlichung aufheben</a>
|
|
{% endif %}
|
|
{% endif %}
|
|
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- FILE FORBIDDEN DELETE FILE -->
|
|
<div class="modal fade" id="forbiddenFileType" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="groupDelFunction" aria-hidden="true">
|
|
<div class="modal-dialog " role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="exampleModalLongTitle">Datei nicht erlaubt</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
Diesen Dateitypen dürfen Sie nicht hochladen.
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-success" data-dismiss="modal">Schließen</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
//STANDARD
|
|
function clearSearchfieldAddStandard(){
|
|
$("#searchstandards").val("");
|
|
}
|
|
|
|
|
|
function remStandard(id, name){
|
|
$('#possstandards').append('<option id="standard_'+id+'" value="'+ name +'">'+ name +'</option>');
|
|
$("#standardadded_" + id).remove();
|
|
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_remstandard',
|
|
standardid : id
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
|
|
function updateLinkedStandards(){
|
|
var g = $('#searchstandards').val();
|
|
var id = $('#possstandards').find('option[value="' + g + '"]').attr('id');
|
|
if(id != undefined && id.length > 0){
|
|
tempid_standard = id.split("_")[1];
|
|
clearSearchfieldAddStandard();
|
|
$("#" + id).remove();
|
|
$("#linkedstandards").append('<tr id="standardadded_'+tempid_standard+'"><td>' + g + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remStandard('+tempid_standard+', \''+g+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
|
}
|
|
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_addstandard',
|
|
standardid : tempid_standard
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
|
|
//FILES
|
|
function remFile(fileid, filename){
|
|
console.log(fileid);
|
|
$("#fileadded_" + fileid).remove();
|
|
$('#possfiles').append('<option id="file_'+fileid+'" value="'+ filename +'">'+ filename +'</option>');
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_remfile',
|
|
fileid : fileid
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
|
|
function clearSearchfieldAddFile(){
|
|
$("#searchfiles").val("");
|
|
}
|
|
|
|
function updateLinkedFiles(){
|
|
var g = $('#searchfiles').val();
|
|
var id = $('#possfiles').find('option[value="' + g + '"]').attr('id');
|
|
if(id != undefined && id.length > 0){
|
|
tempid_file = id.split("_")[1];
|
|
clearSearchfieldAddFile();
|
|
$("#" + id).remove();
|
|
$("#linkedfiles") .append('<tr id="fileadded_'+tempid_file+'"><td>' + g + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remFile('+tempid_file+', \''+g+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
|
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_addfile',
|
|
fileid : tempid_file
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
//FILES
|
|
// preventing page from redirecting
|
|
$("html").on("dragover", function(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
});
|
|
$("html").on("drop", function(e) { e.preventDefault(); e.stopPropagation(); });
|
|
|
|
$( "#directdiv" ).on('dragenter', function (e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
currentid = e["currentTarget"]['id'];
|
|
$("#directdiv").addClass('bg-secondary');
|
|
});
|
|
|
|
|
|
$('#directdiv').on('drop', function (e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
$("#directdiv").removeClass('bg-secondary');
|
|
uploadAction(e.originalEvent.dataTransfer.files[0], e["currentTarget"]['id'].split("_")[0]);
|
|
});
|
|
|
|
$('#directdiv').on('dragleave', function (e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
currentid = e["currentTarget"]['id'];
|
|
$("#directdiv").removeClass('bg-secondary');
|
|
});
|
|
|
|
allowedtypes = "application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, text/plain, application/pdf, image/*"
|
|
|
|
|
|
|
|
function uploadButtonPush(){
|
|
$("#uploadedfile").click();
|
|
}
|
|
|
|
$('#uploadedfile').on('change', function() {
|
|
uploadAction($("#uploadedfile")[0]['files'][0], {{parentid}});
|
|
});
|
|
|
|
function uploadAction(filetodo){
|
|
var formData = new FormData();
|
|
formData.append("uploadedfile", filetodo);
|
|
formData.append("uploadsource", "standards");
|
|
if(allowedtypes.includes(filetodo.type) && filetodo.type.length > 0){
|
|
$.ajax({
|
|
url: "{% url 'cloud-adddir' parentid %}",
|
|
headers: {
|
|
"X-CSRFTOKEN": "{{ csrf_token }}"
|
|
},
|
|
data: formData,
|
|
type: 'POST',
|
|
cache: false,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
if(data["success"] == true){
|
|
$("#linkedfiles") .append('<tr id="fileadded_'+data["data"]["savedobj_id"]+'"><td>' + data["data"]["savedobj_name"] + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remFile('+data["data"]["savedobj_id"]+', \''+data["data"]["savedobj_name"]+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_addfile',
|
|
fileid : data["data"]["savedobj_id"]
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
else{
|
|
$("#forbiddenFileType").modal("toggle")
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
else{
|
|
$("#forbiddenFileType").modal("toggle")
|
|
}
|
|
}
|
|
|
|
//GROUP CHANGE
|
|
function groupsChange(groupid, value){
|
|
if(value){
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_addgroup',
|
|
groupid : groupid
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
else{
|
|
$.ajax({
|
|
url: "{% url 'update_standard_by_ajax' standard.pk %}",
|
|
data: {
|
|
action : 's_remgroup',
|
|
groupid : groupid
|
|
},
|
|
success: function (data) {}
|
|
});
|
|
}
|
|
}
|
|
/*
|
|
Ajax-Request zum nachladen der Aufgaben nach Auswahl der Bereiche
|
|
*/
|
|
$("#id_area").change(function () {
|
|
var areaid = $(this).val();
|
|
$.ajax({
|
|
url: "/standards/ajax/loadtasks/",
|
|
data: {
|
|
'areaid': areaid
|
|
},
|
|
success: function (data) {
|
|
$("#id_task").html(data);
|
|
}
|
|
});
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
$('#id_content').summernote({
|
|
height: 400
|
|
});
|
|
});
|
|
|
|
</script>
|
|
{% endblock content %}
|