mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Display stock item status
This commit is contained in:
parent
dbc2a7b12b
commit
ce2a866384
@ -8,13 +8,10 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:image/image.dart';
|
||||
|
||||
import 'package:InvenTree/widget/dialogs.dart';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,13 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:InvenTree/inventree/part.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'model.dart';
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:InvenTree/api.dart';
|
||||
|
||||
|
||||
@ -49,6 +49,51 @@ class InvenTreeStockItemTestResult extends InvenTreeModel {
|
||||
|
||||
class InvenTreeStockItem extends InvenTreeModel {
|
||||
|
||||
// Stock status codes
|
||||
static const int OK = 10;
|
||||
static const int ATTENTION = 50;
|
||||
static const int DAMAGED = 55;
|
||||
static const int DESTROYED = 60;
|
||||
static const int REJECTED = 65;
|
||||
static const int LOST = 70;
|
||||
|
||||
String statusLabel(BuildContext context) {
|
||||
|
||||
switch (status) {
|
||||
case OK:
|
||||
return I18N.of(context).ok;
|
||||
case ATTENTION:
|
||||
return I18N.of(context).attention;
|
||||
case DAMAGED:
|
||||
return I18N.of(context).damaged;
|
||||
case DESTROYED:
|
||||
return I18N.of(context).destroyed;
|
||||
case REJECTED:
|
||||
return I18N.of(context).rejected;
|
||||
case LOST:
|
||||
return I18N.of(context).lost;
|
||||
default:
|
||||
return status.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Return color associated with stock status
|
||||
Color get statusColor {
|
||||
switch (status) {
|
||||
case OK:
|
||||
return Color(0xFF50aa51);
|
||||
case ATTENTION:
|
||||
return Color(0xFFfdc82a);
|
||||
case DAMAGED:
|
||||
case DESTROYED:
|
||||
case REJECTED:
|
||||
return Color(0xFFe35a57);
|
||||
case LOST:
|
||||
default:
|
||||
return Color(0xFFAAAAAA);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String NAME = "StockItem";
|
||||
|
||||
@ -168,6 +213,8 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
|
||||
String get uid => jsondata['uid'] ?? '';
|
||||
|
||||
int get status => jsondata['status'] ?? -1;
|
||||
|
||||
int get partId => jsondata['part'] ?? -1;
|
||||
|
||||
int get trackingItemCount => jsondata['tracking_items'] as int ?? 0;
|
||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
||||
Subproject commit 90f3bbf1fae86efd0bb0686bef12452a09507669
|
||||
Subproject commit 249e4964a08b79e53df7e1ea18b051de0d307905
|
@ -99,6 +99,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
child: ListTile(
|
||||
title: Text(I18N.of(context).stockLocations),
|
||||
subtitle: Text(I18N.of(context).stockTopLevel),
|
||||
leading: FaIcon(FontAwesomeIcons.levelUpAlt),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
@ -112,6 +113,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
ListTile(
|
||||
title: Text("Parent Category"),
|
||||
subtitle: Text("${location.parentpathstring}"),
|
||||
leading: FaIcon(FontAwesomeIcons.levelUpAlt),
|
||||
onTap: () {
|
||||
if (location.parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
||||
|
@ -303,7 +303,13 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
title: Text("${item.partName}"),
|
||||
subtitle: Text("${item.partDescription}"),
|
||||
leading: InvenTreeAPI().getImage(item.partImage),
|
||||
trailing: Text(item.serialOrQuantityDisplay()),
|
||||
trailing: Text(
|
||||
item.statusLabel(context),
|
||||
style: TextStyle(
|
||||
color: item.statusColor
|
||||
)
|
||||
),
|
||||
//trailing: Text(item.serialOrQuantityDisplay()),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user