More work on the CSV dump.
This commit is contained in:
parent
e6847d0504
commit
1ec15328b0
2 changed files with 18 additions and 2 deletions
|
@ -50,7 +50,7 @@ def list_inventory():
|
||||||
header=inventory_headers,
|
header=inventory_headers,
|
||||||
rows=[{"id": item.id, "cells": [row_fn(item) for row_fn in inventory_headers.values()]} for item in inventory],
|
rows=[{"id": item.id, "cells": [row_fn(item) for row_fn in inventory_headers.values()]} for item in inventory],
|
||||||
entry_route = 'inventory_item',
|
entry_route = 'inventory_item',
|
||||||
table=inventory
|
csv_route = 'inventory'
|
||||||
)
|
)
|
||||||
|
|
||||||
@main.route("/inventory/index")
|
@main.route("/inventory/index")
|
||||||
|
@ -209,7 +209,7 @@ def delete_inventory_item(id):
|
||||||
|
|
||||||
@main.route("/api/inventory/export", methods=["GET"])
|
@main.route("/api/inventory/export", methods=["GET"])
|
||||||
def get_inventory_csv():
|
def get_inventory_csv():
|
||||||
return "Oh boy!"
|
return jsonify({"success": True}), 200
|
||||||
|
|
||||||
@main.route("/inventory_available")
|
@main.route("/inventory_available")
|
||||||
def inventory_available():
|
def inventory_available():
|
||||||
|
|
|
@ -8,6 +8,22 @@
|
||||||
window.location.href = '/{{ entry_route }}/new';
|
window.location.href = '/{{ entry_route }}/new';
|
||||||
{% endset %}
|
{% endset %}
|
||||||
{% set exportButtonLogic %}
|
{% set exportButtonLogic %}
|
||||||
|
const payload = {ids: [{% for row in rows %}{{ row['id'] }}, {% endfor %}]}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/{{ csv_route }}/export', {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
console.log(result);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
{% endset %}
|
{% endset %}
|
||||||
{% set toolbarButtons %}
|
{% set toolbarButtons %}
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue