2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00
- Specify image size in list view
- Move "edit" button to app bar
- Display part keywords
- Allow editing of part keywords
This commit is contained in:
Oliver Walters 2021-01-21 20:53:49 +11:00
parent 65a01ff98c
commit 3096a6d25f
5 changed files with 88 additions and 43 deletions

View File

@ -380,7 +380,7 @@ class InvenTreeAPI {
* Load image from the InvenTree server,
* or from local cache (if it has been cached!)
*/
CachedNetworkImage getImage(String imageUrl) {
CachedNetworkImage getImage(String imageUrl, {double height, double width}) {
if (imageUrl.isEmpty) {
imageUrl = staticImage;
}
@ -392,6 +392,8 @@ class InvenTreeAPI {
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(FontAwesomeIcons.exclamation),
httpHeaders: defaultHeaders(),
height: height,
width: width,
);
}
}

View File

@ -47,13 +47,15 @@ class InvenTreeModel {
String get description => jsondata['description'] ?? '';
String get notes => jsondata['notes'] ?? '';
String get notes => jsondata['notes'] as String ?? '';
int get parentId => jsondata['parent'] ?? -1;
int get parentId => jsondata['parent'] as int ?? -1;
// Legacy API provided external link as "URL", while newer API uses "link"
String get link => jsondata['link'] ?? jsondata['URL'] ?? '';
String get keywords => jsondata['keywords'] as String ?? '';
// Create a new object from JSON data (not a constructor!)
InvenTreeModel createFromJson(Map<String, dynamic> json) {

View File

@ -31,6 +31,17 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
@override
String getAppBarTitle(BuildContext context) { return "Part Category"; }
@override
List<Widget> getAppBarActions(BuildContext context) {
return <Widget>[
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: 'Edit',
onPressed: null,
)
];
}
_CategoryDisplayState(this.category) {}
// The local InvenTreePartCategory object
@ -94,10 +105,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
ListTile(
title: Text("${category.name}"),
subtitle: Text("${category.description}"),
trailing: IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
onPressed: null,
),
),
ListTile(
title: Text("Parent Category"),
@ -260,7 +267,11 @@ class PartList extends StatelessWidget {
return ListTile(
title: Text("${part.name}"),
subtitle: Text("${part.description}"),
leading: InvenTreeAPI().getImage(part.thumbnail),
leading: InvenTreeAPI().getImage(
part.thumbnail,
width: 40,
height: 40,
),
onTap: () {
_openPart(context, part.pk);
},

View File

@ -28,6 +28,18 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
@override
String getAppBarTitle(BuildContext context) { return "Stock Location"; }
@override
List<Widget> getAppBarActions(BuildContext context) {
return <Widget>[
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: "Edit",
// TODO - Edit stock location
onPressed: null,
)
];
}
_LocationDisplayState(this.location) {}
List<InvenTreeStockLocation> _sublocations = List<InvenTreeStockLocation>();
@ -98,10 +110,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
ListTile(
title: Text("${location.name}"),
subtitle: Text("${location.description}"),
trailing: IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
onPressed: null,
),
),
ListTile(
title: Text("Parent Category"),
@ -245,7 +253,11 @@ class StockList extends StatelessWidget {
return ListTile(
title: Text("${item.partName}"),
subtitle: Text("${item.partDescription}"),
leading: InvenTreeAPI().getImage(item.partThumbnail),
leading: InvenTreeAPI().getImage(
item.partThumbnail,
width: 40,
height: 40,
),
trailing: Text("${item.displayQuantity}",
style: TextStyle(fontWeight: FontWeight.bold),
),

View File

@ -87,6 +87,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
var _description;
var _ipn;
var _revision;
var _keywords;
showFormDialog(context, "Edit Part",
key: _editPartKey,
@ -107,6 +108,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
"name": _name,
"description": _description,
"IPN": _ipn,
"keywords": _keywords,
});
}
},
@ -128,6 +130,12 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
initial: part.IPN,
allowEmpty: true,
onSaved: (value) => _ipn = value,
),
StringField(
label: "Keywords",
initial: part.keywords,
allowEmpty: true,
onSaved: (value) => _keywords = value,
)
]
@ -183,18 +191,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
);
}
// External link?
if (part.link.isNotEmpty) {
tiles.add(
ListTile(
title: Text("${part.link}"),
leading: FaIcon(FontAwesomeIcons.link),
trailing: Text(""),
onTap: null,
)
);
}
// Stock information
tiles.add(
ListTile(
@ -255,6 +251,28 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
);
}
// Keywords?
if (part.keywords.isNotEmpty) {
tiles.add(
ListTile(
title: Text("${part.keywords}"),
leading: FaIcon(FontAwesomeIcons.key),
)
);
}
// External link?
if (part.link.isNotEmpty) {
tiles.add(
ListTile(
title: Text("${part.link}"),
leading: FaIcon(FontAwesomeIcons.link),
trailing: Text(""),
onTap: null,
)
);
}
if (part.isTrackable) {
tiles.add(ListTile(
title: Text("Required Tests"),