2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-07-06 05:40:41 +00:00

Label fix (#411)

* Cleanup label printing options

- Improve calls to setState()
- Should fix potential race conditions

* Use name if description not available

* Code simplification

* Fetch plugins even if the server reports "plugins enabled"

- Builtin plugins are still a thing!

* Use name *and* description to display label
This commit is contained in:
Oliver
2023-08-12 20:41:11 +10:00
committed by GitHub
parent d81f0d532d
commit 8200140976
5 changed files with 40 additions and 30 deletions

View File

@ -56,7 +56,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
bool showParameters = false;
bool showBom = false;
bool allowLabelPrinting = true;
int attachmentCount = 0;
int bomCount = 0;
@ -121,7 +120,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
);
}
if (allowLabelPrinting && labels.isNotEmpty) {
if (labels.isNotEmpty) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.print),
@ -244,15 +243,21 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
}
});
allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
allowLabelPrinting &= api.getPlugins(mixin: "labels").isNotEmpty;
List<Map<String, dynamic>> _labels = [];
bool allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
allowLabelPrinting &= api.supportsMixin("labels");
if (allowLabelPrinting) {
labels.clear();
labels = await getLabelTemplates("part", {
_labels = await getLabelTemplates("part", {
"part": widget.part.pk.toString(),
});
}
if (mounted) {
setState(() {
labels = _labels;
});
}
}
void _editPartDialog(BuildContext context) {