Skip to content

Commit

Permalink
Merge pull request #84 from pvdthings/dev
Browse files Browse the repository at this point in the history
Release: Rename Item Description to Notes
  • Loading branch information
dillonfagan authored Oct 24, 2024
2 parents db7f5f4 + 38c4268 commit 363c8a6
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 79 deletions.
8 changes: 4 additions & 4 deletions apps/api/apps/librarian/routes/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ router.get('/:id', async (req, res) => {
});

router.put('/', async (req, res) => {
const { thingId, quantity, brand, condition, description, estimatedValue, hidden, image, manuals } = req.body;
const { thingId, quantity, brand, condition, notes, estimatedValue, hidden, image, manuals } = req.body;

try {
res.send(await createItems(thingId, { quantity, brand, condition, description, estimatedValue, hidden, image, manuals }));
res.send(await createItems(thingId, { quantity, brand, condition, notes, estimatedValue, hidden, image, manuals }));
} catch (error) {
console.error(error);
res.status(error.status || 500).send({ errors: [error] });
}
});

router.patch('/:id', async (req, res) => {
const { brand, description, estimatedValue, hidden, condition, image, manuals } = req.body;
const { brand, notes, estimatedValue, hidden, condition, image, manuals } = req.body;

try {
await updateItem(req.params.id, { brand, description, estimatedValue, hidden, condition, image, manuals });
await updateItem(req.params.id, { brand, notes, estimatedValue, hidden, condition, image, manuals });
res.status(204).send();
} catch (error) {
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pvdthings-api",
"version": "1.21.2",
"version": "1.21.3",
"description": "",
"main": "server.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/services/inventory/mapItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function mapItem(record) {
&& !isThingHidden,
hidden: hidden || isThingHidden,
brand: record.get('Brand'),
description: record.get('Description'),
notes: record.get('Notes'),
dueBack: record.get('Due Back')?.[0],
estimatedValue: record.get('Estimated Value'),
eyeProtection: Boolean(record.get('Eye Protection')),
Expand Down
12 changes: 6 additions & 6 deletions apps/api/services/inventory/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const inventoryFields = [
'Thing',
'Name',
'Brand',
'Description',
'Notes',
'Due Back',
'Eye Protection',
'Active Loans',
Expand Down Expand Up @@ -53,13 +53,13 @@ const fetchItem = async (id, { recordId } = { recordId: undefined }) => {
return mapItem(records[0]);
}

const createItems = async (thingId, { quantity, brand, description, estimatedValue, hidden, condition, image, manuals }) => {
const createItems = async (thingId, { quantity, brand, notes, estimatedValue, hidden, condition, image, manuals }) => {
const inventoryData = Array.from(Array(Number(quantity))).map(() => ({
fields: {
'Thing': [thingId],
'Brand': brand,
'Condition': condition,
'Description': description,
'Notes': notes,
'Estimated Value': Number(estimatedValue),
'Hidden': hidden,
'Picture': image?.url ? [{ url: image.url }] : [],
Expand All @@ -71,15 +71,15 @@ const createItems = async (thingId, { quantity, brand, description, estimatedVal
return records.map(mapItem);
}

const updateItem = async (id, { brand, description, estimatedValue, hidden, condition, image, manuals }) => {
const updateItem = async (id, { brand, notes, estimatedValue, hidden, condition, image, manuals }) => {
let updatedFields = {};

if (brand !== null) {
updatedFields['Brand'] = brand;
}

if (description !== null) {
updatedFields['Description'] = description;
if (notes !== null) {
updatedFields['Notes'] = notes;
}

if (estimatedValue !== null) {
Expand Down
8 changes: 4 additions & 4 deletions apps/librarian/lib/core/api/inventory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Future<Response> createInventoryItems(
required int quantity,
required String? brand,
String? condition,
required String? description,
required String? notes,
required double? estimatedValue,
bool? hidden,
ImageDTO? image,
Expand All @@ -24,7 +24,7 @@ Future<Response> createInventoryItems(
'quantity': quantity,
'brand': brand,
'condition': condition,
'description': description,
'notes': notes,
'estimatedValue': estimatedValue,
'hidden': hidden,
'image': {
Expand All @@ -38,7 +38,7 @@ Future<Response> updateInventoryItem(
String id, {
String? brand,
String? condition,
String? description,
String? notes,
double? estimatedValue,
bool? hidden,
ImageDTO? image,
Expand All @@ -47,7 +47,7 @@ Future<Response> updateInventoryItem(
return await DioClient.instance.patch('/inventory/$id', data: {
'brand': brand,
'condition': condition,
'description': description,
'notes': notes,
'estimatedValue': estimatedValue,
'hidden': hidden,
'image': image != null ? {'url': image.url} : null,
Expand Down
6 changes: 3 additions & 3 deletions apps/librarian/lib/core/api/models/item_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ItemModel {
required this.linkedThingIds,
this.brand,
this.condition,
this.description,
this.notes,
this.estimatedValue,
this.location,
});
Expand All @@ -24,7 +24,7 @@ class ItemModel {
final String thingId;
final int number;
final String name;
final String? description;
final String? notes;
final String? brand;
final String? condition;
final String? location;
Expand All @@ -48,7 +48,7 @@ class ItemModel {
thingId: json['thingId'] as String,
number: json['number'] as int,
name: json['name'] as String? ?? 'Unknown Thing',
description: json['description'] as String?,
notes: json['notes'] as String?,
available: json['available'] as bool,
hidden: json['hidden'] as bool,
totalLoans: json['totalLoans'] as int,
Expand Down
8 changes: 4 additions & 4 deletions apps/librarian/lib/core/data/inventory_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class InventoryRepository extends Notifier<Future<List<ThingModel>>> {
required int quantity,
required String? brand,
required String? condition,
required String? description,
required String? notes,
required double? estimatedValue,
required bool? hidden,
required UpdatedImageModel? image,
Expand All @@ -146,7 +146,7 @@ class InventoryRepository extends Notifier<Future<List<ThingModel>>> {
quantity: quantity,
brand: brand,
condition: condition,
description: description,
notes: notes,
estimatedValue: estimatedValue,
hidden: hidden,
image: image == null ? null : api.ImageDTO(url: imageUrl),
Expand All @@ -158,7 +158,7 @@ class InventoryRepository extends Notifier<Future<List<ThingModel>>> {
Future<void> updateItem(
String id, {
String? brand,
String? description,
String? notes,
String? condition,
double? estimatedValue,
bool? hidden,
Expand All @@ -175,7 +175,7 @@ class InventoryRepository extends Notifier<Future<List<ThingModel>>> {
id,
brand: brand,
condition: condition,
description: description,
notes: notes,
estimatedValue: estimatedValue,
hidden: hidden,
image: image == null ? null : api.ImageDTO(url: imageUrl),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CreateItems extends ConsumerWidget {
),
const SizedBox(height: 16),
TextFormField(
controller: controller.descriptionController,
controller: controller.notesController,
decoration: inputDecoration.copyWith(labelText: 'Description'),
enabled: !controller.isLoading,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CreateItemsController extends ChangeNotifier {
late final brandController = TextEditingController()
..addListener(notifyListeners);

late final descriptionController = TextEditingController()
late final notesController = TextEditingController()
..addListener(notifyListeners);

late final estimatedValueController = TextEditingController()
Expand Down Expand Up @@ -105,7 +105,7 @@ class CreateItemsController extends ChangeNotifier {
quantity: quantity,
brand: brandController.text,
condition: conditionNotifier.value,
description: descriptionController.text,
notes: notesController.text,
estimatedValue: estimatedValue,
hidden: hiddenNotifier.value,
image: createUpdatedImageModel(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ConditionDropdown extends StatelessWidget {
Widget build(BuildContext context) {
return DropdownButtonFormField<ConditionDropdownOption>(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Condition',
),
items: editable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,40 @@ class ItemDetails extends ConsumerWidget {
value: controller.conditionNotifier.value,
),
),
_HiddenCheckboxListTile(
isItemDamaged: _isItemDamaged,
isThingHidden: isThingHidden,
isManagedByPartner: item.isManagedByPartner,
value: controller.hiddenNotifier.value,
onChanged: (value) {
controller.hiddenNotifier.value = value ?? false;
},
const Divider(height: 1),
Padding(
padding: const EdgeInsets.all(16.0),
child: TextFormField(
controller: controller.notesController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Needs a new part installed.',
labelText: 'Notes',
),
enabled: !controller.isLoading,
maxLines: 128,
minLines: 3,
),
),
],
),
),
const SizedBox(height: 32),
Card(
clipBehavior: Clip.antiAlias,
elevation: isMobile(context) ? 1 : 0,
margin: EdgeInsets.zero,
child: _HiddenCheckboxListTile(
isItemDamaged: _isItemDamaged,
isThingHidden: isThingHidden,
isManagedByPartner: item.isManagedByPartner,
value: controller.hiddenNotifier.value,
onChanged: (value) {
controller.hiddenNotifier.value = value ?? false;
},
),
),
const SizedBox(height: 32),
Card(
clipBehavior: Clip.antiAlias,
elevation: isMobile(context) ? 1 : 0,
Expand All @@ -102,14 +123,18 @@ class ItemDetails extends ConsumerWidget {
readOnly: true,
controller: controller.nameController,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'Thing',
suffix: Tooltip(
message: 'Convert',
child: IconButton(
onPressed: () {
controller.convertThing(context);
},
icon: const Icon(convertIcon),
suffixIcon: Padding(
padding: const EdgeInsets.only(right: 8),
child: Tooltip(
message: 'Convert',
child: IconButton(
onPressed: () {
controller.convertThing(context);
},
icon: const Icon(convertIcon),
),
),
),
),
Expand All @@ -119,23 +144,17 @@ class ItemDetails extends ConsumerWidget {
TextFormField(
controller: controller.brandController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Brand',
hintText: 'Generic',
),
enabled: !controller.isLoading,
),
const SizedBox(height: 16),
TextFormField(
controller: controller.descriptionController,
decoration: const InputDecoration(
labelText: 'Description',
),
enabled: !controller.isLoading,
),
const SizedBox(height: 16),
TextFormField(
controller: controller.estimatedValueController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Estimated Value (\$)',
prefixText: '\$ ',
),
Expand All @@ -148,6 +167,7 @@ class ItemDetails extends ConsumerWidget {
const SizedBox(height: 16),
TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Location',
),
enabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ItemDetailsController extends ChangeNotifier {
late TextEditingController nameController;
late ValueNotifier<bool> hiddenNotifier;
late TextEditingController brandController;
late TextEditingController descriptionController;
late TextEditingController notesController;
late TextEditingController estimatedValueController;
late ValueNotifier<String?> conditionNotifier;
late ValueNotifier<List<ManualData>> manualsNotifier;
Expand All @@ -45,8 +45,7 @@ class ItemDetailsController extends ChangeNotifier {
nameController = TextEditingController(text: item!.name);
hiddenNotifier = ValueNotifier(false)..addListener(notifyListeners);
brandController = TextEditingController()..addListener(notifyListeners);
descriptionController = TextEditingController()
..addListener(notifyListeners);
notesController = TextEditingController()..addListener(notifyListeners);
estimatedValueController = TextEditingController()
..addListener(notifyListeners);
conditionNotifier = ValueNotifier(null)..addListener(notifyListeners);
Expand All @@ -58,8 +57,8 @@ class ItemDetailsController extends ChangeNotifier {
brandController.text = item!.brand!;
}

if (item?.description != null) {
descriptionController.text = item!.description!;
if (item?.notes != null) {
notesController.text = item!.notes!;
}

final estimatedValue = formatNumber(item?.estimatedValue);
Expand Down Expand Up @@ -163,7 +162,7 @@ class ItemDetailsController extends ChangeNotifier {
await repository?.updateItem(
item!.id,
brand: brandController.text,
description: descriptionController.text,
notes: notesController.text,
condition: conditionNotifier.value,
estimatedValue: estimatedValue,
hidden: hiddenNotifier.value,
Expand Down Expand Up @@ -226,7 +225,7 @@ class ItemDetailsController extends ChangeNotifier {
!listEquals(manualsNotifier.value, _originalManuals) ||
hiddenNotifier.value != (item?.hidden ?? false) ||
brandController.text != (item?.brand ?? '') ||
descriptionController.text != (item?.description ?? '') ||
notesController.text != (item?.notes ?? '') ||
estimatedValueController.text !=
(formatNumber(item?.estimatedValue) ?? '') ||
conditionNotifier.value != item?.condition ||
Expand Down
Loading

0 comments on commit 363c8a6

Please sign in to comment.