From a028cdcaf12540dccfa4e5b42660ab6bdd898cb4 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Wed, 27 Dec 2017 08:56:28 +0100 Subject: [PATCH] Add hidden comments column to items table Column not visible but searchable. Allow to search comments and TAG number for items imported from JIRA. --- app/inventory/views.py | 1 + app/static/js/items.js | 7 ++++++- app/templates/inventory/items.html | 1 + tests/functional/test_web.py | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/inventory/views.py b/app/inventory/views.py index c91f8d8..20a9a36 100644 --- a/app/inventory/views.py +++ b/app/inventory/views.py @@ -35,6 +35,7 @@ def retrieve_items(): utils.format_field(item.location), utils.format_field(item.status), utils.format_field(item.parent), + '\n'.join([comment.body for comment in item.comments]), ] for item in items] return jsonify(data=data) diff --git a/app/static/js/items.js b/app/static/js/items.js index e32d90a..d9ecbd2 100644 --- a/app/static/js/items.js +++ b/app/static/js/items.js @@ -74,7 +74,12 @@ $(document).ready(function() { var url = $SCRIPT_ROOT + "/inventory/items/view/" + data; return '<a href="'+ url + '">' + data + '</a>'; } - } + }, + { + "targets": [10], + "visible": false, + "searchable": true + }, ] }); diff --git a/app/templates/inventory/items.html b/app/templates/inventory/items.html index 9e4edba..c566b50 100644 --- a/app/templates/inventory/items.html +++ b/app/templates/inventory/items.html @@ -31,6 +31,7 @@ <th>Location</th> <th>Status</th> <th>Parent</th> + <th>Comments</th> </tr> </thead> </table> diff --git a/tests/functional/test_web.py b/tests/functional/test_web.py index 1d8dac3..644b41d 100644 --- a/tests/functional/test_web.py +++ b/tests/functional/test_web.py @@ -80,4 +80,4 @@ def test_retrieve_items(logged_client, item_factory): response = get(logged_client, '/inventory/_retrieve_items') items = response.json['data'] assert set(serial_numbers) == set(item[4] for item in items) - assert len(items[0]) == 10 + assert len(items[0]) == 11 -- GitLab