2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00
Oliver 4f8dddc597
JS translation fix (#6288)
* Implement {% jstrans %} template

- Forces string escaping in translated text
- Required for js written in templates

* Fix part_base.html

* Update .html files

- Change any templated javascript code to use {% jstrans %}

* Update .js files

- Explicitly use {% jstrans %}

* Update CI checks
2024-01-19 01:16:17 +00: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 '{% jstrans "No news found" %}';
},
columns: [
{
field: 'pk',
title: '{% jstrans "ID" %}',
visible: false,
switchable: false,
},
{
field: 'title',
title: '{% jstrans "Title" %}',
sortable: 'true',
formatter: function(value, row) {
return `<a href="` + row.link + `">` + value + `</a>`;
}
},
{
field: 'summary',
title: '{% jstrans "Summary" %}',
},
{
field: 'author',
title: '{% jstrans "Author" %}',
},
{
field: 'published',
title: '{% jstrans "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');
}
}
);
});
}