mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-14 03:05:32 +00:00
Enable multi-line text editing for API forms
- User can edit part notes - User can edit stock item notes
This commit is contained in:
@ -8,10 +8,6 @@ import 'package:inventree/widget/progress.dart';
|
||||
|
||||
import 'package:inventree/l10.dart';
|
||||
|
||||
|
||||
import 'package:inventree/widget/fields.dart';
|
||||
import 'package:inventree/widget/dialogs.dart';
|
||||
import 'package:inventree/widget/snacks.dart';
|
||||
import 'package:inventree/widget/part_detail.dart';
|
||||
import 'package:inventree/widget/refreshable_state.dart';
|
||||
import 'package:inventree/widget/paginator.dart';
|
||||
|
@ -8,9 +8,6 @@ import 'package:inventree/inventree/stock.dart';
|
||||
import 'package:inventree/widget/progress.dart';
|
||||
|
||||
import 'package:inventree/widget/refreshable_state.dart';
|
||||
import 'package:inventree/widget/fields.dart';
|
||||
import 'package:inventree/widget/dialogs.dart';
|
||||
import 'package:inventree/widget/snacks.dart';
|
||||
import 'package:inventree/widget/stock_detail.dart';
|
||||
import 'package:inventree/widget/paginator.dart';
|
||||
import 'package:inventree/l10.dart';
|
||||
@ -37,8 +34,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
final InvenTreeStockLocation? location;
|
||||
|
||||
final _editLocationKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) { return L10().stockLocation; }
|
||||
|
||||
@ -101,14 +96,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
modelData: _loc.jsondata,
|
||||
onSuccess: refresh
|
||||
);
|
||||
|
||||
// Values which an be edited
|
||||
var _name;
|
||||
var _description;
|
||||
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_LocationDisplayState(this.location);
|
||||
|
@ -37,7 +37,6 @@ class PartDetailWidget extends StatefulWidget {
|
||||
class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
final _editImageKey = GlobalKey<FormState>();
|
||||
final _editPartKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().partDetails;
|
||||
@ -104,23 +103,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
void _savePart(Map<String, String> values) async {
|
||||
|
||||
final bool result = await part.update(values: values);
|
||||
|
||||
if (result) {
|
||||
showSnackIcon(L10().partEdited, success: true);
|
||||
}
|
||||
/*
|
||||
showSnackIcon(
|
||||
result ? "Part edited" : "Part editing failed",
|
||||
success: result
|
||||
);
|
||||
*/
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload image for this Part.
|
||||
* Show a SnackBar with upload result.
|
||||
@ -411,22 +393,20 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
// Notes field?
|
||||
if (part.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: FaIcon(FontAwesomeIcons.stickyNote, color: COLOR_CLICK),
|
||||
trailing: Text(""),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => PartNotesWidget(part))
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
// Notes field
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: FaIcon(FontAwesomeIcons.stickyNote, color: COLOR_CLICK),
|
||||
trailing: Text(""),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => PartNotesWidget(part))
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
return tiles;
|
||||
|
||||
|
@ -1,9 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:inventree/api.dart';
|
||||
import 'package:inventree/inventree/part.dart';
|
||||
import 'package:inventree/widget/refreshable_state.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:inventree/l10.dart';
|
||||
|
||||
import '../api_form.dart';
|
||||
|
||||
|
||||
class PartNotesWidget extends StatefulWidget {
|
||||
|
||||
@ -22,9 +27,47 @@ class _PartNotesState extends RefreshableState<PartNotesWidget> {
|
||||
|
||||
_PartNotesState(this.part);
|
||||
|
||||
@override
|
||||
Future<void> request() async {
|
||||
await part.reload();
|
||||
}
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().partNotes;
|
||||
|
||||
@override
|
||||
List<Widget> getAppBarActions(BuildContext context) {
|
||||
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (InvenTreeAPI().checkPermission('part', 'change')) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: FaIcon(FontAwesomeIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().editNotes,
|
||||
part.url,
|
||||
{
|
||||
"notes": {
|
||||
"multiline": true,
|
||||
}
|
||||
},
|
||||
modelData: part.jsondata,
|
||||
onSuccess: () async {
|
||||
refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return Markdown(
|
||||
|
@ -47,7 +47,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
final _removeStockKey = GlobalKey<FormState>();
|
||||
final _countStockKey = GlobalKey<FormState>();
|
||||
final _moveStockKey = GlobalKey<FormState>();
|
||||
final _editStockKey = GlobalKey<FormState>();
|
||||
|
||||
_StockItemDisplayState(this.item);
|
||||
|
||||
@ -291,9 +290,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
void _transferStockDialog(BuildContext context) async {
|
||||
|
||||
var locations = await InvenTreeStockLocation().list();
|
||||
final _selectedController = TextEditingController();
|
||||
|
||||
int? location_pk;
|
||||
|
||||
_quantityController.text = "${item.quantityString}";
|
||||
@ -563,22 +559,21 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
if (item.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: FaIcon(FontAwesomeIcons.stickyNote, color: COLOR_CLICK),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => StockNotesWidget(item))
|
||||
);
|
||||
// TODO: Load notes in markdown viewer widget
|
||||
// TODO: Make this widget editable?
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
// Notes field
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: FaIcon(FontAwesomeIcons.stickyNote, color: COLOR_CLICK),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => StockNotesWidget(item))
|
||||
);
|
||||
// TODO: Load notes in markdown viewer widget
|
||||
// TODO: Make this widget editable?
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:inventree/inventree/stock.dart';
|
||||
import 'package:inventree/widget/refreshable_state.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:inventree/l10.dart';
|
||||
|
||||
import '../api.dart';
|
||||
import '../api_form.dart';
|
||||
|
||||
|
||||
class StockNotesWidget extends StatefulWidget {
|
||||
|
||||
@ -26,6 +31,43 @@ class _StockNotesState extends RefreshableState<StockNotesWidget> {
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().stockItemNotes;
|
||||
|
||||
@override
|
||||
Future<void> request() async {
|
||||
await item.reload();
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getAppBarActions(BuildContext context) {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (InvenTreeAPI().checkPermission('stock', 'change')) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: FaIcon(FontAwesomeIcons.edit),
|
||||
tooltip: L10().edit,
|
||||
onPressed: () {
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().editNotes,
|
||||
item.url,
|
||||
{
|
||||
"notes": {
|
||||
"multiline": true,
|
||||
}
|
||||
},
|
||||
modelData: item.jsondata,
|
||||
onSuccess: () {
|
||||
refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return Markdown(
|
||||
|
Reference in New Issue
Block a user