2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Forms actions fix (#6493)

* Handle case where OPTIONS.actions is not present

* Specify stock.change permission

* Hide table button based on user permission

* Fix for permission check class
This commit is contained in:
Oliver
2024-02-16 08:47:05 +11:00
committed by GitHub
parent 38fac47e39
commit 21f209f7cc
5 changed files with 16 additions and 2 deletions

View File

@ -346,7 +346,11 @@ function constructForm(url, options={}) {
getApiEndpointOptions(url, function(OPTIONS) {
// Copy across entire actions struct
options.actions = OPTIONS.actions.POST || OPTIONS.actions.PUT || OPTIONS.actions.PATCH || OPTIONS.actions.DELETE || {};
if (OPTIONS && OPTIONS.actions) {
options.actions = OPTIONS.actions.POST || OPTIONS.actions.PUT || OPTIONS.actions.PATCH || OPTIONS.actions.DELETE || {};
} else {
options.actions = {};
}
// Extract any custom 'context' information from the OPTIONS data
options.context = OPTIONS.context || {};

View File

@ -3101,11 +3101,14 @@ function loadInstalledInTable(table, options) {
field: 'buttons',
title: '',
switchable: false,
visible: options.can_edit,
formatter: function(value, row) {
let pk = row.pk;
let html = '';
html += makeIconButton('fa-unlink', 'button-uninstall', pk, '{% trans "Uninstall Stock Item" %}');
if (options.can_edit) {
html += makeIconButton('fa-unlink', 'button-uninstall', pk, '{% trans "Uninstall Stock Item" %}');
}
return wrapButtons(html);
}