mirror of
https://github.com/inventree/inventree-app.git
synced 2025-09-17 08:21:21 +00:00
Label print updates (#399)
* Allow download of printed label * Add setting for controlling label printing * Control display of label printing via setting * Refactor label printing functionality - Move to helpers.dart - Will be used for other label types also * Factor out request for label templates * Add label printing support for part * Support label printing for stock location * update release notes
This commit is contained in:
@@ -11,6 +11,7 @@ import "package:inventree/helpers.dart";
|
||||
import "package:inventree/inventree/bom.dart";
|
||||
import "package:inventree/inventree/part.dart";
|
||||
import "package:inventree/inventree/stock.dart";
|
||||
import "package:inventree/labels.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
import "package:inventree/widget/attachment_widget.dart";
|
||||
@@ -54,17 +55,16 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
int parameterCount = 0;
|
||||
|
||||
bool showParameters = false;
|
||||
|
||||
bool showBom = false;
|
||||
bool allowLabelPrinting = true;
|
||||
|
||||
int attachmentCount = 0;
|
||||
|
||||
int bomCount = 0;
|
||||
|
||||
int usedInCount = 0;
|
||||
|
||||
int variantCount = 0;
|
||||
|
||||
List<Map<String, dynamic>> labels = [];
|
||||
|
||||
@override
|
||||
String getAppBarTitle() => L10().partDetails;
|
||||
|
||||
@@ -110,12 +110,29 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeStockItem().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: FaIcon(FontAwesomeIcons.box),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () {
|
||||
_newStockItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (allowLabelPrinting && labels.isNotEmpty) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: FaIcon(FontAwesomeIcons.box),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () {
|
||||
_newStockItem(context);
|
||||
child: FaIcon(FontAwesomeIcons.print),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(
|
||||
context,
|
||||
labels,
|
||||
"part",
|
||||
"part=${widget.part.pk}"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -226,6 +243,16 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
allowLabelPrinting &= api.getPlugins(mixin: "labels").isNotEmpty;
|
||||
|
||||
if (allowLabelPrinting) {
|
||||
labels.clear();
|
||||
labels = await getLabelTemplates("part", {
|
||||
"part": widget.part.pk.toString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _editPartDialog(BuildContext context) {
|
||||
|
Reference in New Issue
Block a user