Share url view

* adds modal for rendering the share url
* adds new custom_widget text-to-clipboard-input.html
  * provides a copy button for writing the text input's value into the client's clipboard
* adds translation
This commit is contained in:
mipel
2021-07-30 14:34:36 +02:00
parent b4f9105120
commit d13ad5ff7d
5 changed files with 66 additions and 39 deletions

View File

@@ -0,0 +1,5 @@
{% comment %}
This is an empty template.
It's used to dismiss a default widget for a django_filter filter and to use a predefined input directly in the
template without losing the comfort of matching the filter methods declared in the filter
{% endcomment %}

View File

@@ -0,0 +1,18 @@
{% load i18n fontawesome_5 %}
<div class="input-group" title="{{ widget.value|stringformat:'s' }}">
<input aria-describedby="copy-btn" type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %}>
<div class="input-group-append" onclick="copyClipboard()">
<span id="copy-btn" class="btn btn-default" value="{% trans 'Copy to clipboard' %}" title="{% trans 'Copy to clipboard' %}">{% fa5_icon 'clipboard' 'far' %}</span>
</div>
</div>
<script>
function copyClipboard() {
var copyText = document.getElementById("id_{{ widget.name }}");
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
document.execCommand("copy");
alert("{% trans 'Copied to clipboard' %}");
}
</script>