2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00
Files
InvenTree/InvenTree/templates/js/translated/news.js
Oliver 4b5fcd4e69 Remove {% jstrans %} tag (#6298)
* Revert {% jstrans %} for .js files

- file extension is enough

* Remove custom jstrans templatetag

* Replace jstrans calls for .html files

- Add "escape=True"

* Allow for custom "escape" argument

* Update custom trans tag

- Cannot pass kwargs in the same way
- Add the "escape" attribute

* Update js translations in html files
2024-01-21 22:47:47 +11:00

90 lines
2.2 KiB
JavaScript

{% load i18n %}
{% load inventree_extras %}
/* globals
getReadEditButton,
inventreePut,
renderDate,
setupFilterList,
*/
/* exported
loadNewsFeedTable,
*/
/*
* Load notification table
*/
function loadNewsFeedTable(table, options={}, enableDelete=false) {
setupFilterList('news', table);
$(table).inventreeTable({
url: options.url,
name: 'news',
groupBy: false,
queryParams: {
ordering: '-published',
read: false,
},
paginationVAlign: 'bottom',
formatNoMatches: function() {
return '{% trans "No news found" %}';
},
columns: [
{
field: 'pk',
title: '{% trans "ID" %}',
visible: false,
switchable: false,
},
{
field: 'title',
title: '{% trans "Title" %}',
sortable: 'true',
formatter: function(value, row) {
return `<a href="` + row.link + `">` + value + `</a>`;
}
},
{
field: 'summary',
title: '{% trans "Summary" %}',
},
{
field: 'author',
title: '{% trans "Author" %}',
},
{
field: 'published',
title: '{% trans "Published" %}',
sortable: 'true',
formatter: function(value, row) {
var html = renderDate(value);
var buttons = getReadEditButton(row.pk, row.read);
html += `<div class='btn-group float-right' role='group'>${buttons}</div>`;
return html;
}
},
]
});
$(table).on('click', '.notification-read', function() {
var pk = $(this).attr('pk');
var url = `/api/news/${pk}/`;
inventreePut(url,
{
read: true,
},
{
method: 'PATCH',
success: function() {
$(table).bootstrapTable('refresh');
}
}
);
});
}