2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00
Oliver 92930d475c
Fix JS linting workflow (#4915)
* Add bad .js code

- Call function which has not been defined
- Should throw JS lint error

* update eslint

- Move to newer version of eslint
- Change default rules

* Fixes for tables.js

* Fixes for table_filters.js

* Fixes for stock.js

* Fix for sales_order.js and search.js

* Fix return_order.js

* Fixes for purchase_order.js

* More updates

- part.js
- plugin.js
- pricing.js

* Updates

- order.js

* Even morerer updates

- label.js
- modals.js
- model_renderers.js
- news.js
- notification.js

* More, MORE!

- build.js
- company.js
- charts.js
- filters.js
- forms.js
- helpers.js

* Final?

- api.js
- attachment.js
- barcode.js
- bom.js

* Fix 'useless-escape'

* Disable no-useless-escape rule
2023-05-30 22:55:53 +10: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');
}
}
);
});
}