Ersetzfunktion Standard fertig
This commit is contained in:
parent
2104211454
commit
6b3776d3c4
|
|
@ -133,6 +133,7 @@ a.disabled {
|
||||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
||||||
<div class="dropdown-header">Dateioptionen</div>
|
<div class="dropdown-header">Dateioptionen</div>
|
||||||
<a class="dropdown-item" href="javascript:moveFile({{file.pk}})">Verschieben</a>
|
<a class="dropdown-item" href="javascript:moveFile({{file.pk}})">Verschieben</a>
|
||||||
|
<a class="dropdown-item" href="javascript:replaceFile({{file.pk}})">Ersetzen</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item text-danger" href="javascript:delDataFileObje({{file.pk}})" >Löschen</a>
|
<a class="dropdown-item text-danger" href="javascript:delDataFileObje({{file.pk}})" >Löschen</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -247,6 +248,26 @@ a.disabled {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- SelfFile ERROR -->
|
||||||
|
<div class="modal fade" id="replaceerrModal" 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">Ersetzungsfehler</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Sie können die Datei nicht mit sich selbst ersetzen.
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-success" data-dismiss="modal">Schließen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- CONFIRMA DELETE FILE -->
|
<!-- CONFIRMA DELETE FILE -->
|
||||||
<div class="modal fade" id="delDataFile" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="groupDelFunction" aria-hidden="true">
|
<div class="modal fade" id="delDataFile" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="groupDelFunction" aria-hidden="true">
|
||||||
<div class="modal-dialog " role="document">
|
<div class="modal-dialog " role="document">
|
||||||
|
|
@ -259,6 +280,7 @@ a.disabled {
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
Datei <b><span id="filenametodel"></span></b> wirklich löschen?
|
Datei <b><span id="filenametodel"></span></b> wirklich löschen?
|
||||||
|
<div id="connectedStandards"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="javascript:doDelDataFile()">Löschen</button>
|
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="javascript:doDelDataFile()">Löschen</button>
|
||||||
|
|
@ -268,6 +290,47 @@ a.disabled {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- CONFIRMA REPLACE FILE -->
|
||||||
|
<div class="modal fade" id="replaceFileModal" 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 ersetzen</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Datei <b><span id="filenametodel"></span></b> ersetzen mit:
|
||||||
|
<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 files %}
|
||||||
|
<option id="file_{{f.pk}}" value="{{f.name}}">{{f.name}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
<div><span id="choosenfilename"></span></div>
|
||||||
|
|
||||||
|
<div id="connectedStandardsReplace"></div>
|
||||||
|
<hr>
|
||||||
|
<button id="btnDoReplaceFile" type="button" style="float: right" class="btn btn-secondary mt-1 " data-dismiss="modal" onclick="javascript:doreplaceFile(1)" disabled="true">Ersetzen, Alte Datei löschen!</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer" >
|
||||||
|
|
||||||
|
<button id="btnDoReplaceFileSnd" type="button" class="btn btn-danger" data-dismiss="modal" onclick="javascript:doreplaceFile(0)" disabled="true">Ersetzen, Alte Datei <u>nicht</u> löschen!</button>
|
||||||
|
<button type="button" class="btn btn-success" data-dismiss="modal">Abbrechen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- CONFIRMA MOVE/DIR -->
|
<!-- CONFIRMA MOVE/DIR -->
|
||||||
<div class="modal fade" id="moveDataModal" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="groupDelFunction" aria-hidden="true">
|
<div class="modal fade" id="moveDataModal" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="groupDelFunction" aria-hidden="true">
|
||||||
<div class="modal-dialog " role="document">
|
<div class="modal-dialog " role="document">
|
||||||
|
|
@ -377,9 +440,26 @@ a.disabled {
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
var actquotasize = {{actquota}};
|
var actquotasize = {{actquota}};
|
||||||
|
|
||||||
|
var ua = window.navigator.userAgent;
|
||||||
|
var isIE = /MSIE|Trident/.test(ua);
|
||||||
|
if ( isIE ) {
|
||||||
|
//IE specific code goes here
|
||||||
|
setInterval(function()
|
||||||
|
{
|
||||||
|
|
||||||
|
if($('#replaceFileModal').is(':visible')){
|
||||||
|
console.log("HI!");
|
||||||
|
updateLinkedFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},400);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('[data-toggle="popover"]').popover();
|
$('[data-toggle="popover"]').popover();
|
||||||
$(".toast").toast({
|
$(".toast").toast({
|
||||||
|
|
@ -388,6 +468,28 @@ var actquotasize = {{actquota}};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function clearSearchfieldAddFile(){
|
||||||
|
$("#searchfiles").val("");
|
||||||
|
}
|
||||||
|
|
||||||
|
var replace_file_id = "";
|
||||||
|
$("#choosenfilename").html("");
|
||||||
|
|
||||||
|
function updateLinkedFiles(){
|
||||||
|
|
||||||
|
|
||||||
|
var g = $('#searchfiles').val();
|
||||||
|
var id = $('#possfiles').find('option[value="' + g + '"]').attr('id');
|
||||||
|
if(id != undefined && id.length > 0){
|
||||||
|
replace_file_id = id.split("_")[1];
|
||||||
|
console.log(replace_file_id);
|
||||||
|
clearSearchfieldAddFile();
|
||||||
|
$("#choosenfilename").html("<b>Neue Datei: </b>" + g);
|
||||||
|
$("#btnDoReplaceFile").prop("disabled", false);
|
||||||
|
$("#btnDoReplaceFileSnd").prop("disabled", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//GROUPS
|
//GROUPS
|
||||||
function showGroupChangeModal(tochangeid){
|
function showGroupChangeModal(tochangeid){
|
||||||
|
|
@ -427,9 +529,7 @@ function changeGroup(groupid, value){
|
||||||
dirid : workingdirid,
|
dirid : workingdirid,
|
||||||
value : value
|
value : value
|
||||||
},
|
},
|
||||||
success: function( data )
|
success: function( data ) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,11 +554,75 @@ function moveFile(fileid)
|
||||||
html = ['<ul id="simple_list"><li><i class="fa fa-folder"></i> <a href="javascript:targetParentToMove({{rootid}})"><b><u>Heimverzeichnis<u></b></a>'];
|
html = ['<ul id="simple_list"><li><i class="fa fa-folder"></i> <a href="javascript:targetParentToMove({{rootid}})"><b><u>Heimverzeichnis<u></b></a>'];
|
||||||
createList(data["data"]["agencydirlist"], l);
|
createList(data["data"]["agencydirlist"], l);
|
||||||
$("#agencydirlist").html(html);
|
$("#agencydirlist").html(html);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doreplaceFile(dodel){
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
type: "GET",
|
||||||
|
url: "{% url 'cloud-adddir' parentid %}",
|
||||||
|
data:{
|
||||||
|
action : "replacefile",
|
||||||
|
oldid : workingfileid,
|
||||||
|
newid : replace_file_id,
|
||||||
|
delold : dodel
|
||||||
|
},
|
||||||
|
success: function( data )
|
||||||
|
{
|
||||||
|
if(data["data"]["success"]){
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#replaceFileModal").modal("toggle");
|
||||||
|
$('#replaceFileModal').on('hidden.bs.modal', function (e) {
|
||||||
|
$("#replaceerrModal").modal("toggle");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//MOVING OPERATIONS
|
||||||
|
function replaceFile(fileid)
|
||||||
|
{
|
||||||
|
|
||||||
|
workingfileid = fileid;
|
||||||
|
workingdirid = false;
|
||||||
|
replace_file_id = "";
|
||||||
|
$("#choosenfilename").html("");
|
||||||
|
$("#btnDoReplaceFile").prop("disabled", true);
|
||||||
|
$("#btnDoReplaceFileSnd").prop("disabled", true);
|
||||||
|
$("#replaceFileModal").modal("toggle");
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
type: "GET",
|
||||||
|
url: "{% url 'cloud-adddir' parentid %}",
|
||||||
|
data:{
|
||||||
|
action : "getname_file",
|
||||||
|
id : workingfileid
|
||||||
|
},
|
||||||
|
success: function( data )
|
||||||
|
{
|
||||||
|
standardstring = "";
|
||||||
|
if(data["data"]["linked_standards"] != undefined && data["data"]["linked_standards"].length > 0){
|
||||||
|
standardstring = "<hr><b>Achtung!</b> Datei ist mit folgenden Standards verlinkt:<br />";
|
||||||
|
}
|
||||||
|
for(i = 0; i < data["data"]["linked_standards"].length; i++){
|
||||||
|
standardstring += (i+1) + ". " + data["data"]["linked_standards"][i]['name'];
|
||||||
|
if((i+1)< data["data"]["linked_standards"].length){
|
||||||
|
standardstring += "<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#connectedStandardsReplace").html(standardstring);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var html = ['<ul id="simple_list"><li><i class="fa fa-folder"></i> <a href="javascript:targetParentToMove({{rootid}})"><b><u>Heimverzeichnis<u></b></a>'];
|
var html = ['<ul id="simple_list"><li><i class="fa fa-folder"></i> <a href="javascript:targetParentToMove({{rootid}})"><b><u>Heimverzeichnis<u></b></a>'];
|
||||||
|
|
||||||
|
|
@ -647,9 +811,20 @@ function delDataFileObje(fileid){
|
||||||
id : workingfileid
|
id : workingfileid
|
||||||
},
|
},
|
||||||
success: function( data )
|
success: function( data )
|
||||||
{
|
{
|
||||||
$("#filenametodel").html("");
|
standardstring = "";
|
||||||
$("#filenametodel").html(data["data"]["filename"]);
|
if(data["data"]["linked_standards"] != undefined && data["data"]["linked_standards"].length > 0){
|
||||||
|
standardstring = "<hr><b>Achtung!</b> Datei ist mit folgenden Standards verlinkt:<br />";
|
||||||
|
}
|
||||||
|
for(i = 0; i < data["data"]["linked_standards"].length; i++){
|
||||||
|
standardstring += (i+1) + ". " + data["data"]["linked_standards"][i]['name'];
|
||||||
|
if((i+1)< data["data"]["linked_standards"].length){
|
||||||
|
standardstring += "<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#connectedStandards").html(standardstring);
|
||||||
|
$("#filenametodel").html("");
|
||||||
|
$("#filenametodel").html(data["data"]["filename"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ from datetime import datetime
|
||||||
from users.models import AgencyGroup
|
from users.models import AgencyGroup
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import FileResponse
|
from django.http import FileResponse
|
||||||
|
from standards.models import Standards
|
||||||
|
from django.contrib import messages
|
||||||
'''
|
'''
|
||||||
|
|
||||||
Prüft, ob ein Nutzer in diesen Ordner Zugriffsrechte hat. Läuft den gesamten Strang bis nach oben,
|
Prüft, ob ein Nutzer in diesen Ordner Zugriffsrechte hat. Läuft den gesamten Strang bis nach oben,
|
||||||
|
|
@ -150,7 +151,14 @@ def adddirbyajax(request, parent):
|
||||||
# RETURN FILENAME
|
# RETURN FILENAME
|
||||||
elif(request.GET.get("action") == "getname_file"):
|
elif(request.GET.get("action") == "getname_file"):
|
||||||
fileobj = DataFile.objects.get(pk=request.GET.get('id'), agency=request.user.profile.agency)
|
fileobj = DataFile.objects.get(pk=request.GET.get('id'), agency=request.user.profile.agency)
|
||||||
data = {'filename' : fileobj.name}
|
|
||||||
|
linked_standards = Standards.objects.filter(agency=request.user.profile.agency);
|
||||||
|
linked_standards_final = []
|
||||||
|
for ls in linked_standards:
|
||||||
|
if(fileobj in ls.addedfiles.all()):
|
||||||
|
linked_standards_final.append({ "id" : ls.pk, "name" : ls.name });
|
||||||
|
data = {'filename' : fileobj.name, 'linked_standards' : linked_standards_final}
|
||||||
|
|
||||||
# DELETE FILE
|
# DELETE FILE
|
||||||
elif(request.GET.get("action") == "del_file"):
|
elif(request.GET.get("action") == "del_file"):
|
||||||
DataFile.objects.filter(pk=request.GET.get('id'), agency=request.user.profile.agency).delete()
|
DataFile.objects.filter(pk=request.GET.get('id'), agency=request.user.profile.agency).delete()
|
||||||
|
|
@ -188,14 +196,39 @@ def adddirbyajax(request, parent):
|
||||||
|
|
||||||
elif(request.GET.get("action") == "getgroupsofdir"):
|
elif(request.GET.get("action") == "getgroupsofdir"):
|
||||||
dirid = request.GET.get('dirid')
|
dirid = request.GET.get('dirid')
|
||||||
allgroupsofdir = DataDir.objects.get(pk=dirid, agency=request.user.profile.agency).visibleby.all()
|
allgroupsofdir = DataDir.objects.get(pk=dirid, agency=request.user.profile.agency).visibleby.all()
|
||||||
|
|
||||||
grouopsid = []
|
grouopsid = []
|
||||||
for ag in allgroupsofdir:
|
for ag in allgroupsofdir:
|
||||||
grouopsid.append({"id" : ag.pk})
|
grouopsid.append({"id" : ag.pk})
|
||||||
|
|
||||||
data = {"gdir" : grouopsid}
|
data = {"gdir" : grouopsid}
|
||||||
|
|
||||||
|
# REPLACE FILE
|
||||||
|
elif(request.GET.get("action") == "replacefile"):
|
||||||
|
oldid = DataFile.objects.get(pk=request.GET.get('oldid'), agency=request.user.profile.agency)
|
||||||
|
newid = DataFile.objects.get(pk=request.GET.get('newid'), agency=request.user.profile.agency)
|
||||||
|
if(oldid != None and newid != None and oldid != newid):
|
||||||
|
|
||||||
|
linked_standards = Standards.objects.filter(agency=request.user.profile.agency);
|
||||||
|
replacecounter = 0
|
||||||
|
for standard in linked_standards:
|
||||||
|
if(oldid in standard.addedfiles.all()):
|
||||||
|
standard.addedfiles.remove(oldid)
|
||||||
|
standard.addedfiles.add(newid)
|
||||||
|
standard.save()
|
||||||
|
replacecounter += 1
|
||||||
|
|
||||||
|
if(request.GET.get('delold') == "1"):
|
||||||
|
oldid.delete()
|
||||||
|
|
||||||
|
data = {"success" : True}
|
||||||
|
if(replacecounter > 0):
|
||||||
|
if(replacecounter == 1):
|
||||||
|
messages.success(request, f'Datei wurde in einem Standard ersetzt.')
|
||||||
|
else:
|
||||||
|
messages.success(request, f'Datei wurde in '+str(replacecounter)+' Standards ersetzt.')
|
||||||
|
else:
|
||||||
|
data = {"success" : False}
|
||||||
|
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
tempdir = False
|
tempdir = False
|
||||||
tempdir = DataDir.objects.get(pk=parent)
|
tempdir = DataDir.objects.get(pk=parent)
|
||||||
|
|
|
||||||
|
|
@ -327,6 +327,8 @@ if ( isIE ) {
|
||||||
{
|
{
|
||||||
alluserfields = $(".searchuserfieldstask").each(function(key, value){
|
alluserfields = $(".searchuserfieldstask").each(function(key, value){
|
||||||
specific_userfield_id = value['id'].split("_")[1];
|
specific_userfield_id = value['id'].split("_")[1];
|
||||||
|
updateLinkedStandards();
|
||||||
|
updateLinkedFiles();
|
||||||
checkUserVerant();
|
checkUserVerant();
|
||||||
checkUserEx();
|
checkUserEx();
|
||||||
checkUserVer();
|
checkUserVer();
|
||||||
|
|
@ -334,20 +336,6 @@ if ( isIE ) {
|
||||||
},400);
|
},400);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ua = window.navigator.userAgent;
|
|
||||||
var isIE = /MSIE|Trident/.test(ua);
|
|
||||||
if ( isIE ) {
|
|
||||||
//IE specific code goes here
|
|
||||||
setInterval(function()
|
|
||||||
{
|
|
||||||
alluserfields = $(".searchuserfieldstask").each(function(key, value){
|
|
||||||
specific_userfield_id = value['id'].split("_")[1];
|
|
||||||
updateLinkedStandards();
|
|
||||||
updateLinkedFiles();
|
|
||||||
});
|
|
||||||
},400);
|
|
||||||
}
|
|
||||||
|
|
||||||
//USERSTOSTANDARDS
|
//USERSTOSTANDARDS
|
||||||
//Verantwortlicher
|
//Verantwortlicher
|
||||||
act_verant = [];
|
act_verant = [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue