mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-01 15:06:49 +00:00
Hide actions if user does not have correct permissions
This commit is contained in:
parent
04f03188e2
commit
096c4e86dc
@ -62,7 +62,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (category != null) {
|
if ((category != null) && InvenTreeAPI().checkPermission('part_category', 'change')) {
|
||||||
actions.add(
|
actions.add(
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: FaIcon(FontAwesomeIcons.edit),
|
icon: FaIcon(FontAwesomeIcons.edit),
|
||||||
|
@ -62,7 +62,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (location != null) {
|
if ((location != null) && (InvenTreeAPI().checkPermission('stock_location', 'change'))) {
|
||||||
actions.add(
|
actions.add(
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: FaIcon(FontAwesomeIcons.edit),
|
icon: FaIcon(FontAwesomeIcons.edit),
|
||||||
@ -320,22 +320,29 @@ List<Widget> detailTiles() {
|
|||||||
|
|
||||||
tiles.add(locationDescriptionCard());
|
tiles.add(locationDescriptionCard());
|
||||||
|
|
||||||
|
// Stock adjustment actions
|
||||||
|
if (InvenTreeAPI().checkPermission('stock', 'change')) {
|
||||||
// Scan items into location
|
// Scan items into location
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(I18N.of(context).barcodeScanInItems),
|
title: Text(I18N
|
||||||
|
.of(context)
|
||||||
|
.barcodeScanInItems),
|
||||||
leading: FaIcon(FontAwesomeIcons.exchangeAlt),
|
leading: FaIcon(FontAwesomeIcons.exchangeAlt),
|
||||||
trailing: FaIcon(FontAwesomeIcons.qrcode),
|
trailing: FaIcon(FontAwesomeIcons.qrcode),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => InvenTreeQRView(StockLocationScanInItemsHandler(location)))
|
MaterialPageRoute(builder: (context) =>
|
||||||
|
InvenTreeQRView(
|
||||||
|
StockLocationScanInItemsHandler(location)))
|
||||||
).then((context) {
|
).then((context) {
|
||||||
refresh();
|
refresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Move location into another location
|
// Move location into another location
|
||||||
// TODO: Implement this!
|
// TODO: Implement this!
|
||||||
|
@ -41,18 +41,29 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<Widget> getAppBarActions(BuildContext context) {
|
List<Widget> getAppBarActions(BuildContext context) {
|
||||||
return <Widget>[
|
|
||||||
|
List<Widget> actions = [];
|
||||||
|
|
||||||
|
if (InvenTreeAPI().checkPermission('part', 'view')) {
|
||||||
|
actions.add(
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: FaIcon(FontAwesomeIcons.globe),
|
icon: FaIcon(FontAwesomeIcons.globe),
|
||||||
onPressed: _openInvenTreePage,
|
onPressed: _openInvenTreePage,
|
||||||
),
|
),
|
||||||
// TODO: Hide the 'edit' button if the user does not have permission!!
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InvenTreeAPI().checkPermission('part', 'change')) {
|
||||||
|
actions.add(
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: FaIcon(FontAwesomeIcons.edit),
|
icon: FaIcon(FontAwesomeIcons.edit),
|
||||||
tooltip: I18N.of(context).edit,
|
tooltip: I18N.of(context).edit,
|
||||||
onPressed: _editPartDialog,
|
onPressed: _editPartDialog,
|
||||||
)
|
)
|
||||||
];
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PartDisplayState(this.part) {
|
_PartDisplayState(this.part) {
|
||||||
@ -82,9 +93,12 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _toggleStar() async {
|
void _toggleStar() async {
|
||||||
|
|
||||||
|
if (InvenTreeAPI().checkPermission('part', 'change')) {
|
||||||
await part.update(context, values: {"starred": "${!part.starred}"});
|
await part.update(context, values: {"starred": "${!part.starred}"});
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _savePart(Map<String, String> values) async {
|
void _savePart(Map<String, String> values) async {
|
||||||
|
|
||||||
|
@ -140,10 +140,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
void _stockUpdateMessage(bool result) {
|
void _stockUpdateMessage(bool result) {
|
||||||
|
|
||||||
showSnackIcon(
|
if (result) {
|
||||||
result ? "Stock item updated" : "Stock item updated failed",
|
showSnackIcon("Stock item updated", success: true);
|
||||||
success: result
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _removeStock() async {
|
void _removeStock() async {
|
||||||
@ -514,6 +513,24 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
tiles.add(headerTile());
|
tiles.add(headerTile());
|
||||||
|
|
||||||
|
// First check that the user has the required permissions to adjust stock
|
||||||
|
if (!InvenTreeAPI().checkPermission('stock', 'change')) {
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text("Permission Required"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.userTimes)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
subtitle: Text("Your account does not have permission to perform stock adjustments"),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return tiles;
|
||||||
|
}
|
||||||
|
|
||||||
if (!item.isSerialized()) {
|
if (!item.isSerialized()) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user