nk20/apps/note/templates/note/transactiontemplate_list.html

64 lines
2.2 KiB
HTML
Raw Normal View History

2019-08-11 17:55:04 +00:00
{% extends "base.html" %}
2020-02-03 14:20:37 +00:00
{% load pretty_money %}
2020-03-23 19:21:25 +00:00
{% load i18n %}
{% load render_table from django_tables2 %}
2019-08-11 17:55:04 +00:00
{% block content %}
2020-03-23 19:21:25 +00:00
<div class="row justify-content-center mb-4">
<div class="col-md-10 text-center">
<input class="form-control mx-auto w-25" type="text" id="search_field" placeholder="{% trans "Name of the button..." %}">
2020-03-23 19:21:25 +00:00
<hr>
<a class="btn btn-primary text-center my-1" href="{% url 'note:template_create' %}" data-turbolinks="false">{% trans "New button" %}</a>
2020-03-23 19:21:25 +00:00
</div>
</div>
<div class="row justify-content-center">
2020-03-24 23:03:48 +00:00
<div class="col-md-10">
<div class="card card-border shadow">
<div class="card-header text-center">
<h5> {% trans "buttons listing "%}</h5>
</div>
<div class="card-body px-0 py-0" id="buttons_table">
{% render_table table %}
</div>
2020-03-24 21:12:44 +00:00
</div>
</div>
2020-03-23 19:21:25 +00:00
</div>
2019-08-11 17:55:04 +00:00
{% endblock %}
2020-03-23 23:07:25 +00:00
{% block extrajavascript %}
2020-07-30 13:49:59 +00:00
<script type="text/javascript">
$(document).ready(function() {
let searchbar_obj = $("#search_field");
var timer_on = false;
var timer;
2020-07-30 13:49:59 +00:00
function reloadTable() {
let pattern = searchbar_obj.val();
$("#buttons_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + " #buttons_table");
}
2020-07-30 13:49:59 +00:00
searchbar_obj.keyup(function() {
if (timer_on)
clearTimeout(timer);
timer_on = true;
2020-07-30 13:49:59 +00:00
setTimeout(reloadTable, 0);
});
});
// on click of button "delete" , call the API
function delete_button(button_id) {
$.ajax({
2020-07-30 13:49:59 +00:00
url:"/api/note/transaction/template/" + button_id + "/",
method:"DELETE",
headers: {"X-CSRFTOKEN": CSRF_TOKEN}
})
2020-07-30 13:49:59 +00:00
.done(function() {
addMsg('{% trans "button successfully deleted "%}','success');
2020-07-30 13:49:59 +00:00
$("#buttons_table").load(location.pathname + "?search=" + $("#search_field").val().replace(" ", "%20") + " #buttons_table");
})
2020-07-30 13:49:59 +00:00
.fail(function() {
addMsg('{% trans "Unable to delete button "%} #' + button_id, 'danger')
});
}
2020-03-23 23:07:25 +00:00
</script>
{% endblock %}