feat: make server own products
This commit is contained in:
@@ -12,6 +12,8 @@ import '../models/product.dart';
|
||||
import '../utils/money.dart';
|
||||
import '../utils/navigation.dart';
|
||||
import '../viewmodels/product_list_view_model.dart';
|
||||
import '../viewmodels/remote_sync_view_model.dart';
|
||||
import 'widgets/managed_on_website_notice.dart';
|
||||
|
||||
class ProductFormView extends StatefulWidget {
|
||||
final String? productId;
|
||||
@@ -313,6 +315,9 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final title = widget.isEditing ? l10n.editProduct : l10n.addProduct;
|
||||
// A paired tablet gets its products from the website: only the stock and
|
||||
// the picture are changed here
|
||||
final managedOnWebsite = context.watch<RemoteSyncViewModel>().isConfigured;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -322,7 +327,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
onPressed: _leaveProductForm,
|
||||
),
|
||||
actions: [
|
||||
if (widget.isEditing)
|
||||
if (widget.isEditing && !managedOnWebsite)
|
||||
IconButton(
|
||||
onPressed: _delete,
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
@@ -342,10 +347,15 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
padding: const EdgeInsets.all(24),
|
||||
children: [
|
||||
if (managedOnWebsite) ...[
|
||||
const ManagedOnWebsiteNotice(),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
_buildImagePicker(context),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
enabled: !managedOnWebsite,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.productName,
|
||||
border: OutlineInputBorder(),
|
||||
@@ -366,6 +376,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
builder: (context, constraints) {
|
||||
return DropdownMenu<String>(
|
||||
width: constraints.maxWidth,
|
||||
enabled: !managedOnWebsite,
|
||||
initialSelection: _selectedCategory,
|
||||
enableFilter: true,
|
||||
enableSearch: true,
|
||||
@@ -395,6 +406,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _priceController,
|
||||
enabled: !managedOnWebsite,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.price,
|
||||
prefixText: '€ ',
|
||||
@@ -455,6 +467,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _lowStockController,
|
||||
enabled: !managedOnWebsite,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.lowStockThreshold,
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
Reference in New Issue
Block a user