Skip to content

Commit

Permalink
replace popup by confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
xi committed May 14, 2019
1 parent 1fc233f commit da34155
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
10 changes: 7 additions & 3 deletions static/js/lagerregal.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@
});

$('[data-timeago]').timeago();
$('[data-toggle="popover"]').popover({
sanitize: false,
});
$('#id_duedate').datepicker();

$(document).on('submit', 'form[data-confirm]', function(event) {
var msg = $(this).data('confirm');
if (!window.confirm(msg)) {
event.preventDefault();
}
});
});
})();
41 changes: 18 additions & 23 deletions templates/devices/device_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,24 @@
{% if can_change_device or can_delete_device %}
<li class="divider"></li>{% endif %}
{% if can_change_device %}
<li><a href="#" id="storagebutton"
data-toggle="popover"
data-html="true"
data-placement="left"
data-title="<span class='text-info' style='margin-right:10px'><strong>{% trans "Are you sure?" %}</strong></span>"
data-content="<form action='{% url "device-storage" object.id %}' method='post' class='form-horizontal'>{% csrf_token %}<div class='form-group dropdown-cancel'><label for='id_send_mail' class='col-sm-10 control-label'>Send room-changed email</label><div class='col-sm-'><input id='id_send_mail' name='send_mail' type='checkbox' class='form-control dropdown-cancel'></div></div><button type='button' class='btn btn-default dropdown-cancel' onclick='$(&quot;#storagebutton&quot;).popover(&quot;hide&quot;);'>{% trans "Cancel" %}</button><input type='submit' value='{% trans "Yes" %}' class='btn btn-danger pull-right'style='margin-left:10px;'/></form>"
class="dropdown-cancel"><i class="fa fa-folder" style="margin-right:7px"></i>{% trans "Move to storage" %}</a></li>
<li><a href="#"
id="archivebutton"
data-toggle="popover"
data-html="true"
data-placement="left"
data-title="<span class='text-info' style='margin-right:10px'><strong>{% trans "Are you sure?" %}</strong></span>"
data-content="<form action='{% url "device-archive" object.id %}' method='post' class='form-horizontal'>{% csrf_token %}<button type='button' class='btn btn-default dropdown-cancel' onclick='$(&quot;#archivebutton&quot;).popover(&quot;hide&quot;);'>{% trans "No" %}</button><input type='submit' value='{% trans "Yes" %}' class='btn btn-danger pull-right' style='margin-left:10px;'/></form>"
class="dropdown-cancel"><i class="fa fa-folder" style="margin-right:7px"></i>{% trans "Archive" %}</a></li>
<li><a href="#"
id="trashbutton"
data-toggle="popover"
data-html="true"
data-placement="left"
data-title="<span class='text-info' style='margin-right:10px'><strong> Are you sure? {%if object.used_in%} This object is still used in <a href='{% url 'device-detail' object.used_in.pk %}'>{{object.used_in}}</a>. {% elif usedset%} This object still uses {% for element in usedset %} <a href='{% url 'device-detail' element.pk %}'> {{element}} </a>{% endfor %} .{% endif %} </strong></span>"
data-content="<form action='{% url "device-trash" object.id %}' method='post' class='form-horizontal'>{% csrf_token %}<button type='button' class='btn btn-default dropdown-cancel' onclick='$(&quot;#trashbutton&quot;).popover(&quot;hide&quot;);'>{% trans "No" %}</button><input type='submit' value='{% trans "Yes" %}' class='btn btn-danger pull-right' style='margin-left:10px;'/></form>"
class="dropdown-cancel"><i class="fa fa-trash-o" style="margin-right:7px"></i>{% trans "Trash" %}</a></li>
<li>
<form action="{% url "device-storage" object.id %}" method="post" data-confirm="{% trans "Are you sure?" %}" class="form-inline">
{% csrf_token %}
<button><i class="fa fa-folder" style="margin-right:7px"></i>{% trans "Move to storage" %}</button>
<form>
</li>
<li>
<form action="{% url "device-archive" object.id %}" method="post" data-confirm="{% trans "Are you sure?" %}" class="form-inline">
{% csrf_token %}
<button><i class="fa fa-folder" style="margin-right:7px"></i>{% trans "Archive" %}</button>
<form>
</li>
<li>
<form action="{% url "device-trash" object.id %}" method="post" data-confirm="{% trans "Are you sure?" %} {% if object.used_in %}This object is still used in {{ object.used_in }}.{% elif usedset %}This object still uses {{ usedset|join:"," }}.{% endif %}" class="form-inline">
{% csrf_token %}
<button><i class="fa fa-trash-o" style="margin-right:7px"></i>{% trans "Trash" %}</button>
<form>
</li>
{% endif %}
{% if can_change_device %}
<li>
Expand Down

0 comments on commit da34155

Please sign in to comment.