digitaleagenturnc/standards/templates/standards/standards_single_agn.html

260 lines
11 KiB
HTML

{% extends "users/base.html" %}
{% load counter_tag %}
{% block content %}
<div class="content-section col-12">
<h2>{{standard.name}}
{% checkifsharedstandardinagency request.user.profile.agency standard as isshared %}
{% if isshared == False and standard.agency != request.user.profile.agency %}
<span style="float: right">
<a style="float: right" href="{% url 'standard-agn' agnpk %}" type="button" class="btn btn-secondary ml-2" data-toggle="tooltip" data-placement="top" title="Zurück zu Verbundstandards."><i class="fas fa-chevron-circle-left"></i></a>
<button style="float: right" id="favoritbutton" class="btn {% if request.user in standard.favoritfrom.all %}btn-primary {% else %} btn-secondary {% endif %} ml-2" onclick="javascript:markFavorit({{standard.pk}}, {{request.user.pk}})" data-toggle="tooltip" data-placement="top" title="Markieren Sie diesen Standard als Favoriten."><!--<small><i class="fas fa-file-import" ></i></small>--><i class="fas fa-star"></i></button>
<button style="float: right" class="btn btn-primary ml-2" onclick="javascript:askForCopy()" data-toggle="tooltip" data-placement="top" title="Übernehmen Sie diesen Standard in Ihre Agentur."><!--<small><i class="fas fa-file-import" ></i></small>-->Standard in meine Agentur übernehmen</button>
</span>
{% elif standard.agency == request.user.profile.agency %}
<span style="float: right; font-size: 16pt;">
<small>Standard ist aus ihrer Agentur</small>
<a style="float: right" href="{% url 'standard-agn' agnpk %}" type="button" class="btn btn-secondary btn-sm ml-2" data-toggle="tooltip" data-placement="top" title="Zurück zu Verbundstandards."><i class="fas fa-chevron-circle-left"></i></a>
</span>
{% else %}
<span style="float: right;font-size: 16pt;">
<small>Standard übernommen</small>
<a style="float: right" href="{% url 'standard-agn' agnpk %}" type="button" class="btn btn-secondary btn-sm ml-2" data-toggle="tooltip" data-placement="top" title="Zurück zu Verbundstandards."><i class="fas fa-chevron-circle-left"></i></a>
</span>
{% endif %}
</h2>
<hr>
<div class="row col">
{% if standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 %}
<div class="card col-9" style="min-height: 500px">
{% else %}
<div class="card col-12" style="min-height: 500px">
{% endif %}
<div class="card-body">
<h5 class="card-title"></h5>
<p class="card-text">
{{standard.media}}
{{standard.content|safe}}
</p>
</div>
</div>
<div class="col-3">
{% if standard.freefield_title|length > 0 %}
<div class="card col-14 ml-1 mb-2" style="">
<div class="card-body">
<h5 class="card-title">{{standard.freefield_title}}</h5>
<p class="card-text">
{{standard.freefield_content}}
</p>
</div>
</div>
{% endif %}
<!-- FILES -->
{% if standard.addedfiles.all|length > 0 %}
<div class="card col-14 ml-1 mb-2" style="">
<div class="card-body">
<h5 class="card-title">Dateien</h5>
<p class="card-text">
{% for files in standard.addedfiles.all %}
{{files.name|truncatechars:30}}
{% endfor %}
</p>
</div>
</div>
{% endif %}
<!-- STANDARDS -->
</div>
</div>
<div class="mt-2">
<small>
Erstellt in Agentur <b>{{standard.agency.name}}</b> und zuletzt bearbeitet am {{ standard.last_modified_on}}. Der Standard wurde bereits {{standard.agencynetworkcounter}} mal übernommen.
</small>
</div>
<hr>
</div>
<div class="col-6">
<div class="mt-2">
<p><span id="comments_counter">{{comments|length}}</span> <span id="comments_word">{% if comments|length == 1 %} Kommentar {% elif comments|length == 0 %} Kommentare {% else %} Kommentare {% endif %}</span></p>
<div class="form-group">
{% getifuserdidcomment standard request.user as userdidcomment%}
{% if userdidcomment == False %}
<input maxlength="199" type="text" class="form-control" id="newcomment" placeholder="Mein Kommentar zum Standard {{standard.name}}">
{% else %}
Sie haben diesen Standard bereits kommentiert.
{% endif %}
</div>
{% if userdidcomment == False %}
<button type="button" id="newcommentbtn" class="btn btn-primary" onclick="javascript:newComment()">Kommentieren</button>
{% endif %}
</div>
<hr>
<div id="commentsection">
{% for comment in comments %}
{% getcommentstat_user comment.pk request.user as cstat %}
<div id="comment_{{comment.pk}}">
<small>Von {{comment.comment_by.first_name}} {{comment.comment_by.last_name}} am {{comment.last_modified_on|date:"d.m.Y H:i"}}</small><br />
{{comment.content}}<br/>
<div class="mt-2">
<button type="button" id="comment_{{comment.pk}}_rate_down" class="btn btn-sm {% if cstat == 0 %} btn-primary {% elif cstat == 'nostat' %} btn-secondary {% endif %}" {% if comment.comment_by == request.user %} disabled="true" {% endif %} onclick="javascript:rateComment({{comment.pk}}, 0)">
<i class="far fa-thumbs-down"></i>
</button>&nbsp;
{% getcommentsdown comment.pk as cdown %}
{% if cdown > 0 %}{{cdown}}&nbsp;&nbsp;&nbsp;{% endif %}
<button type="button" id="comment_{{comment.pk}}_rate_up" class="btn btn-sm {% if cstat == 1 %} btn-primary {% elif cstat == 'nostat' %} btn-secondary {% endif %}" {% if comment.comment_by == request.user %} disabled="true" {% endif %} onclick="javascript:rateComment({{comment.pk}}, 1)">
<i class="far fa-thumbs-up"></i>
</button>&nbsp;
{% getcommentsup comment.pk as cup %}
{% if cup > 0 %}{{cup}}{% endif %}
{% if comment.comment_by == request.user or standard.created_standard_by == request.user or standard.last_modified_by == request.user %}
<span style="float: right;">
<button type="button" class="btn btn-sm btn-secondary" onclick="javascript:delComment({{comment.pk}})" ><i class="fa fa-trash"></i></button>
</span>
{% endif %}
</div>
<hr>
</div>
{% endfor %}
</div>
<!-- MODEAL NEW GROUP -->
<div class="modal fade" id="askForCopy" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="" aria-hidden="true">
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modTitle">Standard übernehmen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Möchten Sie den Standard <b>{{standard.name}}</b> inkl. aller Dateien und Informationen im Freifeld in Ihre Agentur übernehmen?<br/>
<small>Es wird ein neuer Standard in Ihrer Agentur mit den Informationen dieses Standards erstellt.</small>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Abbrechen</button>&nbsp;
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="javascript:doCopy()">Standard übernehmen</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var comments_counter = {{comments|length}};
function askForCopy(){
$("#askForCopy").modal("toggle");
}
function doCopy(){
location.href = "{% url 'standard-copyagn' standard.pk %}"
}
function newComment(){
$.ajax({
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
data: {
action : 'add_comment',
content : $("#newcomment").val()
},
success: function (data) {
comments_counter = comments_counter + 1;
$("#comments_counter").html(comments_counter);
if(comments_counter < 2){
$("#comments_word").html("Kommentar")
}
else{
$("#comments_word").html("Kommentare")
}
$("#commentsection").prepend('<div id="comment_'+data["sc_id"]+'"><small>Von '+data['sc_user'] +' am '+data['sc_date'] +'</small><br />'+data['sc_c'] +'<br/><div class="mt-2"><button type="button" class="btn btn-sm btn-secondary" disabled="true"><i class="far fa-thumbs-down"></i></button>&nbsp;<button type="button" class="btn btn-sm btn-secondary" disabled="true" ><i class="far fa-thumbs-up"></i></button>&nbsp;<span style="float: right;"><button type="button" class="btn btn-sm btn-secondary" onclick="javascript:delComment('+data['sc_id']+')" ><i class="fa fa-trash"></i></button></span></div><hr></div>');
$("#newcomment").remove();
$("#newcommentbtn").remove();
}
});
}
var workingid = "";
function rateComment(commentid, newstat){
$.ajax({
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
data: {
action : 'update_comment_rate',
id : commentid,
newstat : newstat
},
success: function (data) {
location.reload();
}
});
}
function delComment(id){
workingid = id;
$.ajax({
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
data: {
action : 'del_comment',
id : id
},
success: function (data) {
comments_counter = comments_counter - 1;
$("#comments_counter").html(comments_counter);
if(comments_counter < 2){
$("#comments_word").html("Kommentar")
}
else{
$("#comments_word").html("Kommentare")
}
$("#comment_" + workingid).remove();
}
});
}
function markFavorit(){
$.ajax({
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
data: {
action : 'markingfavorit',
},
success: function (data) {
if(data["added"]){
$("#favoritbutton").removeClass("btn-secondary");
$("#favoritbutton").addClass("btn-primary");
}
else{
$("#favoritbutton").removeClass("btn-primary");
$("#favoritbutton").addClass("btn-secondary");
}
}
});
}
</script>
{% endblock content %}