Skip to content

Commit eb80146

Browse files
added book lendings for users, many fixes
1 parent 6b702b4 commit eb80146

62 files changed

Lines changed: 30603 additions & 616 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/model_relations/school_data_hub_server.svg

Lines changed: 1 addition & 1 deletion
Loading

school_data_hub_client/lib/src/protocol/_features/books/models/pupil_book_lending.dart

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:serverpod_client/serverpod_client.dart' as _i1;
1313
import '../../../_features/pupil/models/pupil_data/pupil_data.dart' as _i2;
1414
import '../../../_features/books/models/library_book.dart' as _i3;
1515
import '../../../_shared/models/hub_document.dart' as _i4;
16+
import '../../../_features/user/models/staff_user.dart' as _i5;
1617

1718
abstract class PupilBookLending implements _i1.SerializableModel {
1819
PupilBookLending._({
@@ -25,12 +26,15 @@ abstract class PupilBookLending implements _i1.SerializableModel {
2526
required this.lentBy,
2627
this.returnedAt,
2728
this.receivedBy,
28-
required this.pupilId,
29+
this.pupilId,
2930
this.pupil,
3031
required this.isbn,
3132
required this.libraryBookId,
3233
this.libraryBook,
3334
this.pupilBookLendingFiles,
35+
this.borrowerUserId,
36+
this.borrowerUser,
37+
this.borrowerType,
3438
});
3539

3640
factory PupilBookLending({
@@ -43,12 +47,15 @@ abstract class PupilBookLending implements _i1.SerializableModel {
4347
required String lentBy,
4448
DateTime? returnedAt,
4549
String? receivedBy,
46-
required int pupilId,
50+
int? pupilId,
4751
_i2.PupilData? pupil,
4852
required int isbn,
4953
required int libraryBookId,
5054
_i3.LibraryBook? libraryBook,
5155
List<_i4.HubDocument>? pupilBookLendingFiles,
56+
int? borrowerUserId,
57+
_i5.User? borrowerUser,
58+
String? borrowerType,
5259
}) = _PupilBookLendingImpl;
5360

5461
factory PupilBookLending.fromJson(Map<String, dynamic> jsonSerialization) {
@@ -64,7 +71,7 @@ abstract class PupilBookLending implements _i1.SerializableModel {
6471
? null
6572
: _i1.DateTimeJsonExtension.fromJson(jsonSerialization['returnedAt']),
6673
receivedBy: jsonSerialization['receivedBy'] as String?,
67-
pupilId: jsonSerialization['pupilId'] as int,
74+
pupilId: jsonSerialization['pupilId'] as int?,
6875
pupil: jsonSerialization['pupil'] == null
6976
? null
7077
: _i2.PupilData.fromJson(
@@ -79,6 +86,12 @@ abstract class PupilBookLending implements _i1.SerializableModel {
7986
as List?)
8087
?.map((e) => _i4.HubDocument.fromJson((e as Map<String, dynamic>)))
8188
.toList(),
89+
borrowerUserId: jsonSerialization['borrowerUserId'] as int?,
90+
borrowerUser: jsonSerialization['borrowerUser'] == null
91+
? null
92+
: _i5.User.fromJson(
93+
(jsonSerialization['borrowerUser'] as Map<String, dynamic>)),
94+
borrowerType: jsonSerialization['borrowerType'] as String?,
8295
);
8396
}
8497

@@ -103,7 +116,7 @@ abstract class PupilBookLending implements _i1.SerializableModel {
103116

104117
String? receivedBy;
105118

106-
int pupilId;
119+
int? pupilId;
107120

108121
_i2.PupilData? pupil;
109122

@@ -115,6 +128,12 @@ abstract class PupilBookLending implements _i1.SerializableModel {
115128

116129
List<_i4.HubDocument>? pupilBookLendingFiles;
117130

131+
int? borrowerUserId;
132+
133+
_i5.User? borrowerUser;
134+
135+
String? borrowerType;
136+
118137
/// Returns a shallow copy of this [PupilBookLending]
119138
/// with some or all fields replaced by the given arguments.
120139
@_i1.useResult
@@ -134,6 +153,9 @@ abstract class PupilBookLending implements _i1.SerializableModel {
134153
int? libraryBookId,
135154
_i3.LibraryBook? libraryBook,
136155
List<_i4.HubDocument>? pupilBookLendingFiles,
156+
int? borrowerUserId,
157+
_i5.User? borrowerUser,
158+
String? borrowerType,
137159
});
138160
@override
139161
Map<String, dynamic> toJson() {
@@ -147,14 +169,17 @@ abstract class PupilBookLending implements _i1.SerializableModel {
147169
'lentBy': lentBy,
148170
if (returnedAt != null) 'returnedAt': returnedAt?.toJson(),
149171
if (receivedBy != null) 'receivedBy': receivedBy,
150-
'pupilId': pupilId,
172+
if (pupilId != null) 'pupilId': pupilId,
151173
if (pupil != null) 'pupil': pupil?.toJson(),
152174
'isbn': isbn,
153175
'libraryBookId': libraryBookId,
154176
if (libraryBook != null) 'libraryBook': libraryBook?.toJson(),
155177
if (pupilBookLendingFiles != null)
156178
'pupilBookLendingFiles':
157179
pupilBookLendingFiles?.toJson(valueToJson: (v) => v.toJson()),
180+
if (borrowerUserId != null) 'borrowerUserId': borrowerUserId,
181+
if (borrowerUser != null) 'borrowerUser': borrowerUser?.toJson(),
182+
if (borrowerType != null) 'borrowerType': borrowerType,
158183
};
159184
}
160185

@@ -177,12 +202,15 @@ class _PupilBookLendingImpl extends PupilBookLending {
177202
required String lentBy,
178203
DateTime? returnedAt,
179204
String? receivedBy,
180-
required int pupilId,
205+
int? pupilId,
181206
_i2.PupilData? pupil,
182207
required int isbn,
183208
required int libraryBookId,
184209
_i3.LibraryBook? libraryBook,
185210
List<_i4.HubDocument>? pupilBookLendingFiles,
211+
int? borrowerUserId,
212+
_i5.User? borrowerUser,
213+
String? borrowerType,
186214
}) : super._(
187215
id: id,
188216
lendingId: lendingId,
@@ -199,6 +227,9 @@ class _PupilBookLendingImpl extends PupilBookLending {
199227
libraryBookId: libraryBookId,
200228
libraryBook: libraryBook,
201229
pupilBookLendingFiles: pupilBookLendingFiles,
230+
borrowerUserId: borrowerUserId,
231+
borrowerUser: borrowerUser,
232+
borrowerType: borrowerType,
202233
);
203234

204235
/// Returns a shallow copy of this [PupilBookLending]
@@ -215,12 +246,15 @@ class _PupilBookLendingImpl extends PupilBookLending {
215246
String? lentBy,
216247
Object? returnedAt = _Undefined,
217248
Object? receivedBy = _Undefined,
218-
int? pupilId,
249+
Object? pupilId = _Undefined,
219250
Object? pupil = _Undefined,
220251
int? isbn,
221252
int? libraryBookId,
222253
Object? libraryBook = _Undefined,
223254
Object? pupilBookLendingFiles = _Undefined,
255+
Object? borrowerUserId = _Undefined,
256+
Object? borrowerUser = _Undefined,
257+
Object? borrowerType = _Undefined,
224258
}) {
225259
return PupilBookLending(
226260
id: id is int? ? id : this.id,
@@ -232,7 +266,7 @@ class _PupilBookLendingImpl extends PupilBookLending {
232266
lentBy: lentBy ?? this.lentBy,
233267
returnedAt: returnedAt is DateTime? ? returnedAt : this.returnedAt,
234268
receivedBy: receivedBy is String? ? receivedBy : this.receivedBy,
235-
pupilId: pupilId ?? this.pupilId,
269+
pupilId: pupilId is int? ? pupilId : this.pupilId,
236270
pupil: pupil is _i2.PupilData? ? pupil : this.pupil?.copyWith(),
237271
isbn: isbn ?? this.isbn,
238272
libraryBookId: libraryBookId ?? this.libraryBookId,
@@ -242,6 +276,12 @@ class _PupilBookLendingImpl extends PupilBookLending {
242276
pupilBookLendingFiles: pupilBookLendingFiles is List<_i4.HubDocument>?
243277
? pupilBookLendingFiles
244278
: this.pupilBookLendingFiles?.map((e0) => e0.copyWith()).toList(),
279+
borrowerUserId:
280+
borrowerUserId is int? ? borrowerUserId : this.borrowerUserId,
281+
borrowerUser: borrowerUser is _i5.User?
282+
? borrowerUser
283+
: this.borrowerUser?.copyWith(),
284+
borrowerType: borrowerType is String? ? borrowerType : this.borrowerType,
245285
);
246286
}
247287
}

school_data_hub_client/lib/src/protocol/_features/user/models/staff_user.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../../../_features/timetable/models/junction_models/scheduled_lesson_tea
1717
import '../../../_features/timetable/models/junction_models/lesson_teacher.dart'
1818
as _i5;
1919
import '../../../_features/user/models/user_flags.dart' as _i6;
20+
import '../../../_features/books/models/pupil_book_lending.dart' as _i7;
2021

2122
abstract class User implements _i1.SerializableModel {
2223
User._({
@@ -33,6 +34,7 @@ abstract class User implements _i1.SerializableModel {
3334
this.schooldayEventsProcessingTeam,
3435
required this.credit,
3536
required this.userFlags,
37+
this.bookLendings,
3638
});
3739

3840
factory User({
@@ -49,6 +51,7 @@ abstract class User implements _i1.SerializableModel {
4951
String? schooldayEventsProcessingTeam,
5052
required int credit,
5153
required _i6.UserFlags userFlags,
54+
List<_i7.PupilBookLending>? bookLendings,
5255
}) = _UserImpl;
5356

5457
factory User.fromJson(Map<String, dynamic> jsonSerialization) {
@@ -81,6 +84,10 @@ abstract class User implements _i1.SerializableModel {
8184
credit: jsonSerialization['credit'] as int,
8285
userFlags: _i6.UserFlags.fromJson(
8386
(jsonSerialization['userFlags'] as Map<String, dynamic>)),
87+
bookLendings: (jsonSerialization['bookLendings'] as List?)
88+
?.map(
89+
(e) => _i7.PupilBookLending.fromJson((e as Map<String, dynamic>)))
90+
.toList(),
8491
);
8592
}
8693

@@ -113,6 +120,8 @@ abstract class User implements _i1.SerializableModel {
113120

114121
_i6.UserFlags userFlags;
115122

123+
List<_i7.PupilBookLending>? bookLendings;
124+
116125
/// Returns a shallow copy of this [User]
117126
/// with some or all fields replaced by the given arguments.
118127
@_i1.useResult
@@ -130,6 +139,7 @@ abstract class User implements _i1.SerializableModel {
130139
String? schooldayEventsProcessingTeam,
131140
int? credit,
132141
_i6.UserFlags? userFlags,
142+
List<_i7.PupilBookLending>? bookLendings,
133143
});
134144
@override
135145
Map<String, dynamic> toJson() {
@@ -152,6 +162,8 @@ abstract class User implements _i1.SerializableModel {
152162
'schooldayEventsProcessingTeam': schooldayEventsProcessingTeam,
153163
'credit': credit,
154164
'userFlags': userFlags.toJson(),
165+
if (bookLendings != null)
166+
'bookLendings': bookLendings?.toJson(valueToJson: (v) => v.toJson()),
155167
};
156168
}
157169

@@ -178,6 +190,7 @@ class _UserImpl extends User {
178190
String? schooldayEventsProcessingTeam,
179191
required int credit,
180192
required _i6.UserFlags userFlags,
193+
List<_i7.PupilBookLending>? bookLendings,
181194
}) : super._(
182195
id: id,
183196
userInfoId: userInfoId,
@@ -192,6 +205,7 @@ class _UserImpl extends User {
192205
schooldayEventsProcessingTeam: schooldayEventsProcessingTeam,
193206
credit: credit,
194207
userFlags: userFlags,
208+
bookLendings: bookLendings,
195209
);
196210

197211
/// Returns a shallow copy of this [User]
@@ -212,6 +226,7 @@ class _UserImpl extends User {
212226
Object? schooldayEventsProcessingTeam = _Undefined,
213227
int? credit,
214228
_i6.UserFlags? userFlags,
229+
Object? bookLendings = _Undefined,
215230
}) {
216231
return User(
217232
id: id is int? ? id : this.id,
@@ -237,6 +252,9 @@ class _UserImpl extends User {
237252
: this.schooldayEventsProcessingTeam,
238253
credit: credit ?? this.credit,
239254
userFlags: userFlags ?? this.userFlags.copyWith(),
255+
bookLendings: bookLendings is List<_i7.PupilBookLending>?
256+
? bookLendings
257+
: this.bookLendings?.map((e0) => e0.copyWith()).toList(),
240258
);
241259
}
242260
}

school_data_hub_client/lib/src/protocol/client.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,21 @@ class EndpointPupilBookLending extends _i1.EndpointRef {
983983
},
984984
);
985985

986+
_i2.Future<_i31.PupilBookLending> postUserBookLending(
987+
int userId,
988+
String libraryId,
989+
String lentBy,
990+
) =>
991+
caller.callServerEndpoint<_i31.PupilBookLending>(
992+
'pupilBookLending',
993+
'postUserBookLending',
994+
{
995+
'userId': userId,
996+
'libraryId': libraryId,
997+
'lentBy': lentBy,
998+
},
999+
);
1000+
9861001
_i2.Future<List<_i31.PupilBookLending>> fetchPupilBookLendings() =>
9871002
caller.callServerEndpoint<List<_i31.PupilBookLending>>(
9881003
'pupilBookLending',

school_data_hub_client/lib/src/protocol/protocol.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,13 @@ class Protocol extends _i1.SerializationManager {
14071407
? (data as List).map((e) => deserialize<int>(e)).toSet()
14081408
: null) as T;
14091409
}
1410+
if (t == _i1.getType<List<_i27.PupilBookLending>?>()) {
1411+
return (data != null
1412+
? (data as List)
1413+
.map((e) => deserialize<_i27.PupilBookLending>(e))
1414+
.toList()
1415+
: null) as T;
1416+
}
14101417
if (t == List<_i17.UserDevice>) {
14111418
return (data as List).map((e) => deserialize<_i17.UserDevice>(e)).toList()
14121419
as T;

school_data_hub_flutter/assets/school_data_hub_server.svg

Lines changed: 1 addition & 1 deletion
Loading

school_data_hub_flutter/lib/common/widgets/bottom_nav_bar/bottom_nav_bar_layouts.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import 'package:school_data_hub_flutter/common/theme/app_colors.dart';
55

66
class BottomNavBarLayout extends StatelessWidget {
77
final Widget bottomNavBar;
8-
const BottomNavBarLayout({required this.bottomNavBar, super.key});
8+
final bool? isMainNavigation;
9+
const BottomNavBarLayout({
10+
required this.bottomNavBar,
11+
this.isMainNavigation,
12+
super.key,
13+
});
914

1015
@override
1116
Widget build(BuildContext context) {
@@ -14,7 +19,9 @@ class BottomNavBarLayout extends StatelessWidget {
1419
? const EdgeInsets.only(left: 5, right: 5, bottom: 20)
1520
: const EdgeInsets.only(left: 5, right: 5, bottom: 20),
1621
child: SizedBox(
17-
height: kBottomNavigationBarHeight + 30,
22+
height: isMainNavigation == true
23+
? kBottomNavigationBarHeight + 30
24+
: kBottomNavigationBarHeight,
1825
child: Align(
1926
alignment: Alignment.bottomCenter,
2027
child: ConstrainedBox(

0 commit comments

Comments
 (0)