Skip to content

Commit a89e5f8

Browse files
WIP learning support plan, added current available learning support plan filters
1 parent 8c8a229 commit a89e5f8

22 files changed

Lines changed: 673 additions & 286 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
private/
2+
school_data_hub_website/
23
insights/
34
legal/
45
.cursor/
-1.93 KB
Loading
6.06 KB
Loading
-960 Bytes
Loading
2.17 KB
Loading

school_data_hub_flutter/lib/common/widgets/growth_dropdown.dart

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class GrowthDropdown extends StatelessWidget {
3232
}
3333
},
3434
alignment: Alignment.center,
35+
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
36+
itemHeight: 55, // Controls vertical spacing between items
3537
),
3638
),
3739
),
@@ -49,57 +51,69 @@ List<DropdownMenuItem<int>> competenceCheckDropdownItems = [
4951
),
5052
DropdownMenuItem(
5153
value: 1,
52-
child: Container(
53-
decoration: BoxDecoration(
54-
color: AppColors.growthIconColor1,
55-
shape: BoxShape.circle,
56-
),
57-
child: Image.asset(
58-
'assets/images/growth_icons/growth_1-4.png',
59-
width: 50,
60-
height: 50,
54+
child: Padding(
55+
padding: const EdgeInsets.all(4),
56+
child: Container(
57+
decoration: BoxDecoration(
58+
color: AppColors.growthIconColor1,
59+
shape: BoxShape.circle,
60+
),
61+
child: Image.asset(
62+
'assets/images/growth_icons/growth_1-4.png',
63+
width: 50,
64+
height: 50,
65+
),
6166
),
6267
),
6368
),
6469
DropdownMenuItem(
6570
value: 2,
66-
child: Container(
67-
decoration: BoxDecoration(
68-
color: AppColors.growthIconColor2,
69-
shape: BoxShape.circle,
70-
),
71-
child: Image.asset(
72-
'assets/images/growth_icons/growth_2-4.png',
73-
width: 50,
74-
height: 50,
71+
child: Padding(
72+
padding: const EdgeInsets.all(4.0),
73+
child: Container(
74+
decoration: BoxDecoration(
75+
color: AppColors.growthIconColor2,
76+
shape: BoxShape.circle,
77+
),
78+
child: Image.asset(
79+
'assets/images/growth_icons/growth_2-4.png',
80+
width: 50,
81+
height: 50,
82+
),
7583
),
7684
),
7785
),
7886
DropdownMenuItem(
7987
value: 3,
80-
child: Container(
81-
decoration: BoxDecoration(
82-
color: AppColors.growthIconColor3,
83-
shape: BoxShape.circle,
84-
),
85-
child: Image.asset(
86-
'assets/images/growth_icons/growth_3-4.png',
87-
width: 50,
88-
height: 50,
88+
child: Padding(
89+
padding: const EdgeInsets.all(4.0),
90+
child: Container(
91+
decoration: BoxDecoration(
92+
color: AppColors.growthIconColor3,
93+
shape: BoxShape.circle,
94+
),
95+
child: Image.asset(
96+
'assets/images/growth_icons/growth_3-4.png',
97+
width: 50,
98+
height: 50,
99+
),
89100
),
90101
),
91102
),
92103
DropdownMenuItem(
93104
value: 4,
94-
child: Container(
95-
decoration: BoxDecoration(
96-
color: AppColors.growthIconColor4,
97-
shape: BoxShape.circle,
98-
),
99-
child: Image.asset(
100-
'assets/images/growth_icons/growth_4-4.png',
101-
width: 50,
102-
height: 50,
105+
child: Padding(
106+
padding: const EdgeInsets.all(2.0),
107+
child: Container(
108+
decoration: BoxDecoration(
109+
color: AppColors.growthIconColor4,
110+
shape: BoxShape.circle,
111+
),
112+
child: Image.asset(
113+
'assets/images/growth_icons/growth_4-4.png',
114+
width: 50,
115+
height: 50,
116+
),
103117
),
104118
),
105119
),

school_data_hub_flutter/lib/features/learning/presentation/pupil_list_learning_page/widgets/pupil_competence_checks/competence_check_card.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class CompetenceCheckCard extends StatelessWidget {
5959
child: Padding(
6060
padding: const EdgeInsets.all(10),
6161
child: Column(
62+
crossAxisAlignment: CrossAxisAlignment.start,
6263
children: [
6364
Row(
6465
mainAxisAlignment: MainAxisAlignment.start,
@@ -156,11 +157,6 @@ class CompetenceCheckCard extends StatelessWidget {
156157
child: Row(
157158
mainAxisSize: MainAxisSize.min,
158159
children: [
159-
Icon(
160-
Icons.label_outline,
161-
size: 16,
162-
color: AppColors.backgroundColor,
163-
),
164160
const Gap(6),
165161
Text(
166162
competenceCheck.groupCheckName!,

school_data_hub_flutter/lib/features/learning_support/domain/filters/learning_support_filter_manager.dart

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:collection/collection.dart';
22
import 'package:flutter/foundation.dart';
3+
import 'package:flutter_it/flutter_it.dart';
34
import 'package:school_data_hub_flutter/common/domain/filters/filters_state_manager.dart';
45
import 'package:school_data_hub_flutter/features/learning_support/domain/models/learning_support_enums.dart';
56
import 'package:school_data_hub_flutter/features/learning_support/domain/support_category_manager.dart';
@@ -8,10 +9,14 @@ import 'package:school_data_hub_flutter/features/pupil/domain/filters/pupil_filt
89
import 'package:school_data_hub_flutter/features/pupil/domain/filters/pupils_filter.dart';
910
import 'package:school_data_hub_flutter/features/pupil/domain/models/pupil_proxy.dart';
1011
import 'package:school_data_hub_flutter/features/pupil/domain/pupil_proxy_helper.dart';
11-
import 'package:flutter_it/flutter_it.dart';
12+
import 'package:school_data_hub_flutter/features/school_calendar/domain/school_calendar_manager.dart';
1213

1314
typedef SupportLevelFilterRecord = ({SupportLevelType filter, bool value});
1415
typedef SupportAreaFilterRecord = ({SupportArea filter, bool value});
16+
typedef CurrentLearningSupportPlanFilterRecord = ({
17+
CurrentLearningSupportPlan filter,
18+
bool value,
19+
});
1520

1621
class LearningSupportFilterManager {
1722
FiltersStateManager get _filtersStateManager => di<FiltersStateManager>();
@@ -28,6 +33,18 @@ class LearningSupportFilterManager {
2833
final _supportAreaFiltersState = ValueNotifier<Map<SupportArea, bool>>(
2934
initialSupportAreaFilterValues,
3035
);
36+
37+
ValueListenable<Map<CurrentLearningSupportPlan, bool>>
38+
get currentLearningSupportFilterState =>
39+
_currentLearningSupportPlanFilterState;
40+
41+
final _currentLearningSupportPlanFilterState =
42+
ValueNotifier<Map<CurrentLearningSupportPlan, bool>>(
43+
initialCurrentLearningSupportPlanFilterValues,
44+
);
45+
bool get currentLearningSupportPlanFiltersActive =>
46+
_currentLearningSupportPlanFilterState.value.containsValue(true);
47+
3148
ValueListenable<Map<SupportArea, bool>> get supportAreaFilterState =>
3249
_supportAreaFiltersState;
3350
bool get supportLevelFiltersActive =>
@@ -40,6 +57,7 @@ class LearningSupportFilterManager {
4057
void dispose() {
4158
_supportLevelFilterState.dispose();
4259
_supportAreaFiltersState.dispose();
60+
_currentLearningSupportPlanFilterState.dispose();
4361
return;
4462
}
4563

@@ -69,9 +87,9 @@ class LearningSupportFilterManager {
6987
_pupilsFilter.refreshs();
7088
}
7189

72-
// We pass a list of [SupportAreaFilterRecord] to this function
73-
// because we want to be able to set multiple filters at once
74-
// in the case of filters that are mutually exclusive
90+
/// We pass a list of [SupportAreaFilterRecord] to this function
91+
/// because we want to be able to set multiple filters at once
92+
/// in the case of filters that are mutually exclusive
7593
void setSupportAreaFilter({
7694
required List<SupportAreaFilterRecord> supportAreaFilterRecords,
7795
}) {
@@ -101,9 +119,43 @@ class LearningSupportFilterManager {
101119
_pupilsFilter.refreshs();
102120
}
103121

122+
void setCurrentLearningSupportPlanFilter({
123+
required List<CurrentLearningSupportPlanFilterRecord>
124+
currentLearningSupportPlanFilterRecords,
125+
}) {
126+
for (final record in currentLearningSupportPlanFilterRecords) {
127+
_currentLearningSupportPlanFilterState.value = {
128+
..._currentLearningSupportPlanFilterState.value,
129+
record.filter: record.value,
130+
};
131+
}
132+
final bool currentLearningSupportPlanFilterStateEqualsInitialState =
133+
const MapEquality().equals(
134+
_currentLearningSupportPlanFilterState.value,
135+
initialCurrentLearningSupportPlanFilterValues,
136+
);
137+
138+
if (currentLearningSupportPlanFilterStateEqualsInitialState) {
139+
_filtersStateManager.setFilterState(
140+
filterState: FilterState.pupilLegacy,
141+
value: false,
142+
);
143+
} else {
144+
_filtersStateManager.setFilterState(
145+
filterState: FilterState.pupilLegacy,
146+
value: true,
147+
);
148+
}
149+
150+
_pupilsFilter.refreshs();
151+
}
152+
104153
void resetFilters() {
105154
_supportLevelFilterState.value = {...initialSupportLevelFilterValues};
106155
_supportAreaFiltersState.value = {...initialSupportAreaFilterValues};
156+
_currentLearningSupportPlanFilterState.value = {
157+
...initialCurrentLearningSupportPlanFilterValues,
158+
};
107159
}
108160

109161
bool matchSupportLevelFilters(PupilProxy pupil) {
@@ -277,4 +329,31 @@ class LearningSupportFilterManager {
277329
}
278330
return false;
279331
}
332+
333+
bool matchCurrentLearningSupportPlanFilters(PupilProxy pupil) {
334+
final Map<CurrentLearningSupportPlan, bool> activeFilters =
335+
_currentLearningSupportPlanFilterState.value;
336+
final bool needsCurrentLearningSupportPlan =
337+
pupil.latestSupportLevel != null;
338+
final bool hasCurrentLearningSupportPlan =
339+
needsCurrentLearningSupportPlan &&
340+
pupil.learningSupportPlans != null &&
341+
pupil.learningSupportPlans!.any(
342+
(element) =>
343+
element.schoolSemester != null &&
344+
element.schoolSemester!.id ==
345+
di<SchoolCalendarManager>().currentSemester.value!.id,
346+
);
347+
if (activeFilters[CurrentLearningSupportPlan.available]! &&
348+
hasCurrentLearningSupportPlan) {
349+
return true;
350+
}
351+
if (activeFilters[CurrentLearningSupportPlan.notAvailable]! &&
352+
!hasCurrentLearningSupportPlan &&
353+
needsCurrentLearningSupportPlan) {
354+
return true;
355+
}
356+
357+
return false;
358+
}
280359
}

school_data_hub_flutter/lib/features/learning_support/domain/learning_support_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class LearningSupportManager {
202202
);
203203
return;
204204
}
205-
final encryptedComment = comment != null
205+
final encryptedComment = comment != null && comment != ''
206206
? customEncrypter.encryptString(comment)
207207
: null;
208208
final updatedPupil = await ClientHelper.apiCall(

school_data_hub_flutter/lib/features/learning_support/domain/models/learning_support_enums.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ Map<SupportLevelType, bool> initialSupportLevelFilterValues = {
1616
SupportLevelType.migrationSupport: false,
1717
};
1818

19+
enum CurrentLearningSupportPlan { available, notAvailable }
20+
21+
Map<CurrentLearningSupportPlan, bool>
22+
initialCurrentLearningSupportPlanFilterValues = {
23+
CurrentLearningSupportPlan.available: false,
24+
CurrentLearningSupportPlan.notAvailable: false,
25+
};
26+
1927
enum SupportArea {
2028
motorics(1),
2129
emotions(2),

0 commit comments

Comments
 (0)