@eeplatform/nuxt-layer-common 1.7.22 → 1.7.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eeplatform/nuxt-layer-common
2
2
 
3
+ ## 1.7.24
4
+
5
+ ### Patch Changes
6
+
7
+ - ed7b645: Restrict last grade and school year options
8
+
9
+ ## 1.7.23
10
+
11
+ ### Patch Changes
12
+
13
+ - ee23a56: Set schoolId asynchronously and add getById
14
+
3
15
  ## 1.7.22
4
16
 
5
17
  ### Patch Changes
@@ -715,10 +715,24 @@
715
715
  required
716
716
  />
717
717
  <v-col cols="12">
718
- <v-text-field
718
+ <v-combobox
719
719
  v-model="enrollment.address.current.municipalityCity"
720
720
  :rules="[requiredRule]"
721
- ></v-text-field>
721
+ :items="citiesMunicipalities"
722
+ item-title="name"
723
+ item-value="name"
724
+ :hide-no-data="false"
725
+ >
726
+ <template v-slot:no-data>
727
+ <v-list-item>
728
+ <v-list-item-title>
729
+ No results matching "<strong>search</strong>".
730
+ Press
731
+ <kbd>enter</kbd> to create a new one
732
+ </v-list-item-title>
733
+ </v-list-item>
734
+ </template>
735
+ </v-combobox>
722
736
  </v-col>
723
737
  </v-row>
724
738
  </v-col>
@@ -731,10 +745,24 @@
731
745
  required
732
746
  />
733
747
  <v-col cols="12">
734
- <v-text-field
748
+ <v-combobox
735
749
  v-model="enrollment.address.current.province"
736
750
  :rules="[requiredRule]"
737
- ></v-text-field>
751
+ :items="provinces"
752
+ item-title="name"
753
+ item-value="name"
754
+ :hide-no-data="false"
755
+ >
756
+ <template v-slot:no-data>
757
+ <v-list-item>
758
+ <v-list-item-title>
759
+ No results matching "<strong>search</strong>".
760
+ Press
761
+ <kbd>enter</kbd> to create a new one
762
+ </v-list-item-title>
763
+ </v-list-item>
764
+ </template>
765
+ </v-combobox>
738
766
  </v-col>
739
767
  </v-row>
740
768
  </v-col>
@@ -750,6 +778,7 @@
750
778
  <v-text-field
751
779
  v-model="enrollment.address.current.country"
752
780
  :rules="[requiredRule]"
781
+ readonly
753
782
  ></v-text-field>
754
783
  </v-col>
755
784
  </v-row>
@@ -847,11 +876,25 @@
847
876
  required
848
877
  />
849
878
  <v-col cols="12">
850
- <v-text-field
879
+ <v-combobox
851
880
  v-model="enrollment.address.permanent.municipalityCity"
852
881
  :rules="[requiredRule]"
853
882
  :readonly="sameAsCurrentAddress"
854
- ></v-text-field>
883
+ :items="citiesMunicipalities"
884
+ item-title="name"
885
+ item-value="name"
886
+ :hide-no-data="false"
887
+ >
888
+ <template v-slot:no-data>
889
+ <v-list-item>
890
+ <v-list-item-title>
891
+ No results matching "<strong>search</strong>".
892
+ Press
893
+ <kbd>enter</kbd> to create a new one
894
+ </v-list-item-title>
895
+ </v-list-item>
896
+ </template>
897
+ </v-combobox>
855
898
  </v-col>
856
899
  </v-row>
857
900
  </v-col>
@@ -864,11 +907,25 @@
864
907
  required
865
908
  />
866
909
  <v-col cols="12">
867
- <v-text-field
910
+ <v-combobox
868
911
  v-model="enrollment.address.permanent.province"
869
912
  :rules="[requiredRule]"
870
913
  :readonly="sameAsCurrentAddress"
871
- ></v-text-field>
914
+ :items="provinces"
915
+ item-title="name"
916
+ item-value="name"
917
+ :hide-no-data="false"
918
+ >
919
+ <template v-slot:no-data>
920
+ <v-list-item>
921
+ <v-list-item-title>
922
+ No results matching "<strong>search</strong>".
923
+ Press
924
+ <kbd>enter</kbd> to create a new one
925
+ </v-list-item-title>
926
+ </v-list-item>
927
+ </template>
928
+ </v-combobox>
872
929
  </v-col>
873
930
  </v-row>
874
931
  </v-col>
@@ -1276,15 +1333,15 @@
1276
1333
  <InputLabel
1277
1334
  class="text-capitalize"
1278
1335
  title="Last Grade Level Completed"
1279
- required
1336
+ :required="!isKindergarten"
1280
1337
  />
1281
1338
  <v-col cols="12">
1282
1339
  <v-autocomplete
1283
1340
  v-model="
1284
1341
  enrollment.returningLearnerInfo.lastGradeLevelCompleted
1285
1342
  "
1286
- :rules="[requiredRule]"
1287
- :items="gradeLevels"
1343
+ :rules="isKindergarten ? [] : [requiredRule]"
1344
+ :items="allowedLastGradeLevels"
1288
1345
  ></v-autocomplete>
1289
1346
  </v-col>
1290
1347
  </v-row>
@@ -1295,14 +1352,14 @@
1295
1352
  <InputLabel
1296
1353
  class="text-capitalize"
1297
1354
  title="Last School Year Completed"
1298
- required
1355
+ :required="!isKindergarten"
1299
1356
  />
1300
1357
  <v-col cols="12">
1301
1358
  <v-autocomplete
1302
1359
  v-model="
1303
1360
  enrollment.returningLearnerInfo.lastSchoolYearCompleted
1304
1361
  "
1305
- :rules="[requiredRule]"
1362
+ :rules="isKindergarten ? [] : [requiredRule]"
1306
1363
  :items="lastSchoolYearOptions"
1307
1364
  ></v-autocomplete>
1308
1365
  </v-col>
@@ -1316,12 +1373,12 @@
1316
1373
  <InputLabel
1317
1374
  class="text-capitalize"
1318
1375
  title="Last School Attended"
1319
- required
1376
+ :required="!isKindergarten"
1320
1377
  />
1321
1378
  <v-col cols="12">
1322
1379
  <v-text-field
1323
1380
  v-model="enrollment.returningLearnerInfo.lastSchoolAttended"
1324
- :rules="[requiredRule]"
1381
+ :rules="isKindergarten ? [] : [requiredRule]"
1325
1382
  ></v-text-field>
1326
1383
  </v-col>
1327
1384
  </v-row>
@@ -1405,11 +1462,21 @@ const enrollment = defineModel<TTLearner>({
1405
1462
  const { cookieConfig } = useRuntimeConfig().public;
1406
1463
 
1407
1464
  if (prop.school) {
1408
- enrollment.value.school = prop.school ?? "school";
1465
+ setTimeout(() => {
1466
+ enrollment.value.schoolId = prop.school ?? "school";
1467
+ }, 1000);
1409
1468
  }
1410
1469
 
1411
1470
  enrollment.value.createdBy = useCookie("user", cookieConfig).value ?? "";
1412
1471
 
1472
+ // Set default country values on mount
1473
+ if (!enrollment.value.address.current.country) {
1474
+ enrollment.value.address.current.country = "Philippines";
1475
+ }
1476
+ if (!enrollment.value.address.permanent.country) {
1477
+ enrollment.value.address.permanent.country = "Philippines";
1478
+ }
1479
+
1413
1480
  const { getAll: getAllPSGC } = usePSGC();
1414
1481
 
1415
1482
  const region = ref("");
@@ -1650,6 +1717,13 @@ watch(selectedSchool, (val) => {
1650
1717
  }
1651
1718
  });
1652
1719
 
1720
+ watch(
1721
+ () => enrollment.value.gradeLevel,
1722
+ () => {
1723
+ enrollment.value.returningLearnerInfo.lastGradeLevelCompleted = "";
1724
+ }
1725
+ );
1726
+
1653
1727
  const { gradeLevels, generateSchoolYears, motherTongueOptions, tracks } =
1654
1728
  useBasicEdu();
1655
1729
 
@@ -1693,11 +1767,81 @@ const isSeniorHighSchool = computed(() => {
1693
1767
  return ["grade-11", "grade-12"].includes(gradeLevel);
1694
1768
  });
1695
1769
 
1770
+ const isKindergarten = computed(() => {
1771
+ const gradeLevel = enrollment.value.gradeLevel;
1772
+ return gradeLevel === "kindergarten" || gradeLevel === "kinder";
1773
+ });
1774
+
1775
+ const allowedLastGradeLevels = computed(() => {
1776
+ const currentGrade = enrollment.value.gradeLevel;
1777
+ if (!currentGrade) return gradeLevels;
1778
+
1779
+ // Define grade level order
1780
+ const gradeOrder = [
1781
+ "kindergarten",
1782
+ "kinder",
1783
+ "grade-1",
1784
+ "grade-2",
1785
+ "grade-3",
1786
+ "grade-4",
1787
+ "grade-5",
1788
+ "grade-6",
1789
+ "grade-7",
1790
+ "grade-8",
1791
+ "grade-9",
1792
+ "grade-10",
1793
+ "grade-11",
1794
+ "grade-12",
1795
+ ];
1796
+
1797
+ const currentIndex = gradeOrder.indexOf(currentGrade);
1798
+ if (currentIndex === -1) return gradeLevels;
1799
+
1800
+ // Get grades that are equal to or one level below current grade
1801
+ const allowedGrades = gradeOrder.slice(
1802
+ Math.max(0, currentIndex - 1),
1803
+ currentIndex + 1
1804
+ );
1805
+
1806
+ // Filter gradeLevels to only include allowed grades
1807
+ return gradeLevels.filter((level) => {
1808
+ if (typeof level === "string") {
1809
+ return allowedGrades.includes(level);
1810
+ }
1811
+ if (typeof level === "object" && level.value) {
1812
+ return allowedGrades.includes(level.value);
1813
+ }
1814
+ return false;
1815
+ });
1816
+ });
1817
+
1696
1818
  const effectiveSchoolYearOptions = computed(() =>
1697
1819
  generateSchoolYears(0, "future")
1698
1820
  );
1699
1821
 
1700
- const lastSchoolYearOptions = generateSchoolYears(50);
1822
+ const lastSchoolYearOptions = computed(() => {
1823
+ const currentSchoolYear = enrollment.value.schoolYear;
1824
+ const allYears = generateSchoolYears(50);
1825
+
1826
+ if (!currentSchoolYear) {
1827
+ // If no school year is selected, exclude only future years (after current school year)
1828
+ const today = new Date();
1829
+ const currentYear = today.getFullYear();
1830
+ const currentMonth = today.getMonth();
1831
+ // School year typically starts in August (month 7), so if we're before August,
1832
+ // the current school year is previous year - current year
1833
+ const currentSchoolYearStart =
1834
+ currentMonth < 7 ? currentYear - 1 : currentYear;
1835
+ const currentSchoolYearStr = `${currentSchoolYearStart}-${
1836
+ currentSchoolYearStart + 1
1837
+ }`;
1838
+
1839
+ return allYears.filter((year) => year <= currentSchoolYearStr);
1840
+ }
1841
+
1842
+ // Filter out years that are >= the selected enrollment school year
1843
+ return allYears.filter((year) => year < currentSchoolYear);
1844
+ });
1701
1845
 
1702
1846
  const indigenousCommunitiesPhilippines = [
1703
1847
  // Luzon (Northern Philippines) - Cordillera Groups (Igorot Subgroups)
@@ -1792,7 +1936,7 @@ watch(enrollment, (val) => {
1792
1936
  enrollment.value.address.current.barangay = "";
1793
1937
  enrollment.value.address.current.municipalityCity = "";
1794
1938
  enrollment.value.address.current.province = "";
1795
- enrollment.value.address.current.country = "";
1939
+ enrollment.value.address.current.country = "Philippines";
1796
1940
  enrollment.value.address.current.zipCode = "";
1797
1941
  enrollment.value.address.permanent.houseNumber = "";
1798
1942
  enrollment.value.address.permanent.streetName = "";
@@ -1800,7 +1944,7 @@ watch(enrollment, (val) => {
1800
1944
  enrollment.value.address.permanent.barangay = "";
1801
1945
  enrollment.value.address.permanent.municipalityCity = "";
1802
1946
  enrollment.value.address.permanent.province = "";
1803
- enrollment.value.address.permanent.country = "";
1947
+ enrollment.value.address.permanent.country = "Philippines";
1804
1948
  enrollment.value.address.permanent.zipCode = "";
1805
1949
  }
1806
1950
  });
@@ -1820,7 +1964,7 @@ watchEffect(() => {
1820
1964
  enrollment.value.address.permanent.province =
1821
1965
  enrollment.value.address.current.province;
1822
1966
  enrollment.value.address.permanent.country =
1823
- enrollment.value.address.current.country;
1967
+ enrollment.value.address.current.country || "Philippines";
1824
1968
  enrollment.value.address.permanent.zipCode =
1825
1969
  enrollment.value.address.current.zipCode;
1826
1970
  } else {
@@ -1830,7 +1974,7 @@ watchEffect(() => {
1830
1974
  enrollment.value.address.permanent.barangay = "";
1831
1975
  enrollment.value.address.permanent.municipalityCity = "";
1832
1976
  enrollment.value.address.permanent.province = "";
1833
- enrollment.value.address.permanent.country = "";
1977
+ enrollment.value.address.permanent.country = "Philippines";
1834
1978
  enrollment.value.address.permanent.zipCode = "";
1835
1979
  }
1836
1980
  });
@@ -14,7 +14,14 @@ export default function useSchool() {
14
14
  );
15
15
  }
16
16
 
17
+ function getById(id: string) {
18
+ return useNuxtApp().$api<Record<string, any>>(
19
+ `/api/basic-education/schools/id/${id}`
20
+ );
21
+ }
22
+
17
23
  return {
18
24
  getAll,
25
+ getById,
19
26
  };
20
27
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@eeplatform/nuxt-layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.7.22",
5
+ "version": "1.7.24",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"