Skip to content

Commit 208bbe1

Browse files
authored
Merge pull request #55 from pvdthings/fix-ppl-items
Fix: Handle Items at PPL Location
2 parents c5b2e75 + 6fa50f9 commit 208bbe1

File tree

11 files changed

+61
-131
lines changed

11 files changed

+61
-131
lines changed

apps/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pvdthings-api",
3-
"version": "1.18.2",
3+
"version": "1.18.3",
44
"description": "",
55
"main": "server.js",
66
"scripts": {

apps/api/services/inventory/mapItem.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function mapItem(record) {
1515
estimatedValue: record.get('Estimated Value'),
1616
eyeProtection: Boolean(record.get('Eye Protection')),
1717
condition: record.get('Condition'),
18+
location: record.get('Location')?.[0],
1819
totalLoans: record.get('Total Loans'),
1920
images: record.get('Picture')?.map(image => image.thumbnails.large.url) || [],
2021
manuals: record.get('Manuals')?.map(manual => ({

apps/api/services/inventory/service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const inventoryFields = [
1010
'Eye Protection',
1111
'Active Loans',
1212
'Total Loans',
13+
'Location',
1314
'Manuals',
1415
'Picture',
1516
'Hidden',

apps/librarian/lib/core/api/models/item_model.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ItemModel {
1515
this.condition,
1616
this.description,
1717
this.estimatedValue,
18+
this.location,
1819
});
1920

2021
final String id;
@@ -23,6 +24,7 @@ class ItemModel {
2324
final String? description;
2425
final String? brand;
2526
final String? condition;
27+
final String? location;
2628
final double? estimatedValue;
2729
final bool available;
2830
final bool hidden;
@@ -42,6 +44,7 @@ class ItemModel {
4244
totalLoans: json['totalLoans'] as int,
4345
brand: json['brand'] as String?,
4446
condition: json['condition'] as String?,
47+
location: json['location'] as String?,
4548
estimatedValue: json['estimatedValue'] as double?,
4649
eyeProtection: json['eyeProtection'] as bool,
4750
imageUrls: (json['images'] as List).cast<String>(),
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:librarian_app/core/api/models/item_model.dart';
3+
4+
const checkedInIcon = Tooltip(
5+
message: 'Available',
6+
child: Icon(Icons.circle, color: Colors.green, size: 16),
7+
);
8+
9+
const checkedOutIcon = Tooltip(
10+
message: 'Unavailable',
11+
child: Icon(Icons.circle, color: Colors.amber, size: 16),
12+
);
13+
14+
const partnerLocationIcon = Tooltip(
15+
message: 'Partner Location',
16+
child: Icon(Icons.circle, color: Colors.grey, size: 16),
17+
);
18+
19+
const hiddenIcon = Tooltip(
20+
message: 'Hidden',
21+
child: Icon(Icons.circle, color: Colors.red, size: 16),
22+
);
23+
24+
Widget getIcon(ItemModel item) {
25+
if (item.hidden) {
26+
return hiddenIcon;
27+
}
28+
29+
if (item.location == 'Providence Public Library') {
30+
return partnerLocationIcon;
31+
}
32+
33+
return item.available ? checkedInIcon : checkedOutIcon;
34+
}

apps/librarian/lib/modules/things/details/inventory/item_details_drawer/drawer.dart renamed to apps/librarian/lib/modules/things/details/inventory/item_details/drawer.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import 'package:flutter/material.dart';
2+
import 'package:librarian_app/modules/things/details/inventory/icons.dart';
23
import 'package:librarian_app/modules/things/details/inventory/item_details/item_details_controller.dart';
34
import 'package:librarian_app/widgets/filled_progress_button.dart';
45

5-
import '../item_details/item_details.dart';
6+
import 'item_details.dart';
67

78
class ItemDetailsDrawer extends StatefulWidget {
89
const ItemDetailsDrawer({
@@ -38,11 +39,14 @@ class _ItemDetailsDrawerState extends State<ItemDetailsDrawer> {
3839
Padding(
3940
padding: const EdgeInsets.all(16),
4041
child: Row(
41-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
4242
children: [
43-
Text(
44-
'#${widget.controller.item!.number}',
45-
style: Theme.of(context).textTheme.titleLarge,
43+
getIcon(widget.controller.item!),
44+
const SizedBox(width: 8.0),
45+
Expanded(
46+
child: Text(
47+
'#${widget.controller.item!.number}',
48+
style: Theme.of(context).textTheme.titleLarge,
49+
),
4650
),
4751
MenuAnchor(
4852
controller: menuController,

apps/librarian/lib/modules/things/details/inventory/item_details/item_details.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ class ItemDetails extends ConsumerWidget {
166166
},
167167
value: controller.conditionNotifier.value,
168168
),
169+
const SizedBox(height: 16),
170+
TextFormField(
171+
decoration: const InputDecoration(
172+
labelText: 'Location',
173+
),
174+
enabled: false,
175+
initialValue: controller.item?.location,
176+
readOnly: true,
177+
),
169178
],
170179
),
171180
),

apps/librarian/lib/modules/things/details/inventory/item_details/item_details_dialog.dart

Lines changed: 0 additions & 100 deletions
This file was deleted.

apps/librarian/lib/modules/things/details/inventory/items_card.dart

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:librarian_app/widgets/hint_text.dart';
77

88
import '../../../../core/api/models/item_model.dart';
99
import '../../../../widgets/details_card/card_header.dart';
10+
import 'icons.dart';
1011

1112
class ItemsCard extends ConsumerWidget {
1213
const ItemsCard({
@@ -104,27 +105,4 @@ class ItemsCard extends ConsumerWidget {
104105
),
105106
);
106107
}
107-
108-
Widget getIcon(ItemModel item) {
109-
if (item.hidden) {
110-
return hiddenIcon;
111-
}
112-
113-
return item.available ? checkedInIcon : checkedOutIcon;
114-
}
115108
}
116-
117-
const checkedInIcon = Tooltip(
118-
message: 'Available',
119-
child: Icon(Icons.circle, color: Colors.green, size: 16),
120-
);
121-
122-
const checkedOutIcon = Tooltip(
123-
message: 'Unavailable',
124-
child: Icon(Icons.circle, color: Colors.amber, size: 16),
125-
);
126-
127-
const hiddenIcon = Tooltip(
128-
message: 'Hidden',
129-
child: Icon(Icons.circle, color: Colors.red, size: 16),
130-
);

apps/librarian/lib/modules/things/details/inventory_details.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
44
import 'package:flutter_riverpod/flutter_riverpod.dart';
55
import 'package:librarian_app/dashboard/providers/end_drawer_provider.dart';
66
import 'package:librarian_app/modules/things/details/inventory/create_items/create_items_dialog.dart';
7-
import 'package:librarian_app/modules/things/details/inventory/item_details_drawer/drawer.dart';
7+
import 'package:librarian_app/modules/things/details/inventory/item_details/drawer.dart';
88
import 'package:librarian_app/modules/things/details/thing_details/thing_details_card.dart';
99
import 'package:librarian_app/core/api/models/updated_image_model.dart';
1010
import 'package:librarian_app/modules/things/details/inventory/item_details_page.dart';

apps/librarian/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1010
# followed by an optional build number separated by a +.
1111
# Both the version and the builder number may be overridden in flutter
1212
# build by specifying --build-name and --build-number, respectively.
13-
version: 1.0.0+14
13+
version: 1.0.0+15
1414

1515
environment:
1616
sdk: '>=3.0.0'

0 commit comments

Comments
 (0)