@eeplatform/nuxt-layer-common 1.7.28 → 1.7.29

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,11 @@
1
1
  # @eeplatform/nuxt-layer-common
2
2
 
3
+ ## 1.7.29
4
+
5
+ ### Patch Changes
6
+
7
+ - 7bcbb5e: Refactor location handling; remove guardian flags
8
+
3
9
  ## 1.7.28
4
10
 
5
11
  ### Patch Changes
@@ -27,8 +27,9 @@
27
27
  :items="provinces"
28
28
  item-title="name"
29
29
  item-value="code"
30
+ :return-object="false"
30
31
  :loading="provincesStatus"
31
- :disabled="provincesStatus"
32
+ :disabled="provincesStatus || !enrollment.region"
32
33
  ></v-autocomplete>
33
34
  </v-col>
34
35
  </v-row>
@@ -44,7 +45,7 @@
44
45
  item-title="name"
45
46
  item-value="code"
46
47
  :loading="citiesMunicipalitiesStatus"
47
- :disabled="citiesMunicipalitiesStatus"
48
+ :disabled="citiesMunicipalitiesStatus || !enrollment.province"
48
49
  >
49
50
  </v-autocomplete>
50
51
  </v-col>
@@ -318,14 +319,11 @@
318
319
 
319
320
  <v-col cols="4">
320
321
  <v-row no-gutters>
321
- <InputLabel
322
- v-model="enrollment.learnerInfo.middleName"
323
- class="text-capitalize"
324
- title="Middle Name"
325
- required
326
- />
322
+ <InputLabel class="text-capitalize" title="Middle Name" />
327
323
  <v-col cols="12">
328
- <v-text-field></v-text-field>
324
+ <v-text-field
325
+ v-model="enrollment.learnerInfo.middleName"
326
+ ></v-text-field>
329
327
  </v-col>
330
328
  </v-row>
331
329
  </v-col>
@@ -713,17 +711,20 @@
713
711
  <v-row no-gutters>
714
712
  <InputLabel
715
713
  class="text-capitalize"
716
- title="Municipality/City"
714
+ title="Province"
717
715
  required
718
716
  />
719
717
  <v-col cols="12">
720
718
  <v-combobox
721
- v-model="enrollment.address.current.municipalityCity"
719
+ v-model="enrollment.address.current.province"
722
720
  :rules="[requiredRule]"
723
- :items="citiesMunicipalities"
721
+ :items="currentProvinces"
724
722
  item-title="name"
725
723
  item-value="name"
724
+ :return-object="false"
726
725
  :hide-no-data="false"
726
+ :loading="loadingCurrentProvinces"
727
+ @keydown.enter="getCurrentCityMun()"
727
728
  >
728
729
  <template v-slot:no-data>
729
730
  <v-list-item>
@@ -743,17 +744,20 @@
743
744
  <v-row no-gutters>
744
745
  <InputLabel
745
746
  class="text-capitalize"
746
- title="Province"
747
+ title="Municipality/City"
747
748
  required
748
749
  />
749
750
  <v-col cols="12">
750
751
  <v-combobox
751
- v-model="enrollment.address.current.province"
752
+ v-model="enrollment.address.current.municipalityCity"
752
753
  :rules="[requiredRule]"
753
- :items="provinces"
754
+ :items="currentCitiesMunicipalities"
754
755
  item-title="name"
755
756
  item-value="name"
757
+ :return-object="false"
756
758
  :hide-no-data="false"
759
+ :disabled="!enrollment.address.current.province"
760
+ :loading="loadingCurrentCityMun"
757
761
  >
758
762
  <template v-slot:no-data>
759
763
  <v-list-item>
@@ -874,18 +878,21 @@
874
878
  <v-row no-gutters>
875
879
  <InputLabel
876
880
  class="text-capitalize"
877
- title="Municipality/City"
881
+ title="Province"
878
882
  required
879
883
  />
880
884
  <v-col cols="12">
881
885
  <v-combobox
882
- v-model="enrollment.address.permanent.municipalityCity"
886
+ v-model="enrollment.address.permanent.province"
883
887
  :rules="[requiredRule]"
884
888
  :readonly="sameAsCurrentAddress"
885
- :items="citiesMunicipalities"
889
+ :items="permanentProvinces"
886
890
  item-title="name"
887
891
  item-value="name"
892
+ :return-object="false"
888
893
  :hide-no-data="false"
894
+ :loading="loadingPermanentProvinces"
895
+ @keydown.enter="getPermanentCityMun()"
889
896
  >
890
897
  <template v-slot:no-data>
891
898
  <v-list-item>
@@ -905,18 +912,21 @@
905
912
  <v-row no-gutters>
906
913
  <InputLabel
907
914
  class="text-capitalize"
908
- title="Province"
915
+ title="Municipality/City"
909
916
  required
910
917
  />
911
918
  <v-col cols="12">
912
919
  <v-combobox
913
- v-model="enrollment.address.permanent.province"
920
+ v-model="enrollment.address.permanent.municipalityCity"
914
921
  :rules="[requiredRule]"
915
922
  :readonly="sameAsCurrentAddress"
916
- :items="provinces"
923
+ :items="permanentCitiesMunicipalities"
917
924
  item-title="name"
918
925
  item-value="name"
926
+ :return-object="false"
919
927
  :hide-no-data="false"
928
+ :disabled="!enrollment.address.permanent.province"
929
+ :loading="loadingPermanentCityMun"
920
930
  >
921
931
  <template v-slot:no-data>
922
932
  <v-list-item>
@@ -988,15 +998,10 @@
988
998
  <v-row>
989
999
  <v-col cols="3">
990
1000
  <v-row no-gutters>
991
- <InputLabel
992
- class="text-capitalize"
993
- title="Last Name"
994
- required
995
- />
1001
+ <InputLabel class="text-capitalize" title="Last Name" />
996
1002
  <v-col cols="12">
997
1003
  <v-text-field
998
1004
  v-model="enrollment.parentGuardianInfo.father.lastName"
999
- :rules="[requiredRule]"
1000
1005
  ></v-text-field>
1001
1006
  </v-col>
1002
1007
  </v-row>
@@ -1004,15 +1009,10 @@
1004
1009
 
1005
1010
  <v-col cols="3">
1006
1011
  <v-row no-gutters>
1007
- <InputLabel
1008
- class="text-capitalize"
1009
- title="First Name"
1010
- required
1011
- />
1012
+ <InputLabel class="text-capitalize" title="First Name" />
1012
1013
  <v-col cols="12">
1013
1014
  <v-text-field
1014
1015
  v-model="enrollment.parentGuardianInfo.father.firstName"
1015
- :rules="[requiredRule]"
1016
1016
  ></v-text-field>
1017
1017
  </v-col>
1018
1018
  </v-row>
@@ -1144,42 +1144,16 @@
1144
1144
  </span>
1145
1145
  </v-col>
1146
1146
 
1147
- <v-col cols="3">
1148
- <v-checkbox
1149
- v-model="fatherLegalGuardianSame"
1150
- label="Father is the Legal Guardian"
1151
- hide-details
1152
- density="compact"
1153
- ></v-checkbox>
1154
- </v-col>
1155
-
1156
- <v-col cols="3">
1157
- <v-checkbox
1158
- v-model="motherLegalGuardianSame"
1159
- label="Mother is the Legal Guardian"
1160
- hide-details
1161
- density="compact"
1162
- ></v-checkbox>
1163
- </v-col>
1164
-
1165
1147
  <v-col cols="12">
1166
1148
  <v-row>
1167
1149
  <v-col cols="3">
1168
1150
  <v-row no-gutters>
1169
- <InputLabel
1170
- class="text-capitalize"
1171
- title="Last Name"
1172
- required
1173
- />
1151
+ <InputLabel class="text-capitalize" title="Last Name" />
1174
1152
  <v-col cols="12">
1175
1153
  <v-text-field
1176
1154
  v-model="
1177
1155
  enrollment.parentGuardianInfo.legalGuardian.lastName
1178
1156
  "
1179
- :rules="[requiredRule]"
1180
- :readonly="
1181
- fatherLegalGuardianSame || motherLegalGuardianSame
1182
- "
1183
1157
  ></v-text-field>
1184
1158
  </v-col>
1185
1159
  </v-row>
@@ -1190,17 +1164,14 @@
1190
1164
  <InputLabel
1191
1165
  class="text-capitalize"
1192
1166
  title="First Name"
1193
- required
1167
+ :required="isGuardianRequired"
1194
1168
  />
1195
1169
  <v-col cols="12">
1196
1170
  <v-text-field
1197
1171
  v-model="
1198
1172
  enrollment.parentGuardianInfo.legalGuardian.firstName
1199
1173
  "
1200
- :rules="[requiredRule]"
1201
- :readonly="
1202
- fatherLegalGuardianSame || motherLegalGuardianSame
1203
- "
1174
+ :rules="isGuardianRequired ? [requiredRule] : []"
1204
1175
  ></v-text-field>
1205
1176
  </v-col>
1206
1177
  </v-row>
@@ -1214,9 +1185,6 @@
1214
1185
  v-model="
1215
1186
  enrollment.parentGuardianInfo.legalGuardian.middleName
1216
1187
  "
1217
- :readonly="
1218
- fatherLegalGuardianSame || motherLegalGuardianSame
1219
- "
1220
1188
  ></v-text-field>
1221
1189
  </v-col>
1222
1190
  </v-row>
@@ -1243,9 +1211,6 @@
1243
1211
  placeholder="09XX-XXX-XXXX"
1244
1212
  variant="outlined"
1245
1213
  density="comfortable"
1246
- :readonly="
1247
- fatherLegalGuardianSame || motherLegalGuardianSame
1248
- "
1249
1214
  ></v-mask-input>
1250
1215
  </v-col>
1251
1216
  </v-row>
@@ -1459,7 +1424,7 @@ const prop = defineProps({
1459
1424
  });
1460
1425
 
1461
1426
  import { VMaskInput } from "vuetify/labs/VMaskInput";
1462
- const { requiredRule } = useUtils();
1427
+ const { requiredRule, debounce } = useUtils();
1463
1428
 
1464
1429
  const enrollment = defineModel<TTLearner>({
1465
1430
  default: () => useEnrollment().enrollment,
@@ -1483,10 +1448,15 @@ if (!enrollment.value.address.permanent.country) {
1483
1448
  enrollment.value.address.permanent.country = "Philippines";
1484
1449
  }
1485
1450
 
1451
+ const isGuardianRequired = computed(
1452
+ () => !!enrollment.value.parentGuardianInfo.legalGuardian.lastName
1453
+ );
1454
+
1486
1455
  const { getAll: getAllPSGC } = usePSGC();
1487
1456
 
1488
1457
  const region = ref("");
1489
1458
  const regions = ref<Array<Record<string, any>>>([]);
1459
+ const selectCurrentRegion = computed(() => enrollment.value.region);
1490
1460
 
1491
1461
  const { data: getAllRegPSGCData, status: getAllRegionStatus } =
1492
1462
  await useLazyAsyncData("get-all-psgc-region", () =>
@@ -1504,12 +1474,25 @@ watchEffect(() => {
1504
1474
  const provinces = ref<Array<Record<string, any>>>([]);
1505
1475
  const province = ref("");
1506
1476
 
1477
+ const selectedProvince = computed(() => enrollment.value.province);
1478
+
1479
+ const selectCurrentProvince = computed(() =>
1480
+ provinces.value.find(
1481
+ (p) => p.name === enrollment.value.address.current.province
1482
+ )
1483
+ );
1484
+
1507
1485
  const { data: getAllPSGCProvData, status: getAllProvStatus } =
1508
1486
  await useLazyAsyncData(
1509
1487
  "get-all-psgc-provinces",
1510
- () => getAllPSGC({ type: "Prov", prefix: region.value.slice(0, 2) }),
1488
+ () =>
1489
+ getAllPSGC({
1490
+ type: "Prov",
1491
+ prefix: selectCurrentRegion.value.slice(0, 2),
1492
+ limit: 100,
1493
+ }),
1511
1494
  {
1512
- watch: [region],
1495
+ watch: [selectCurrentRegion],
1513
1496
  }
1514
1497
  );
1515
1498
 
@@ -1521,9 +1504,37 @@ watchEffect(() => {
1521
1504
  }
1522
1505
  });
1523
1506
 
1507
+ const currentProvinces = ref<Array<Record<string, any>>>([]);
1508
+
1509
+ const { data: dataCurrentProvinces, status: statusCurrentProvinces } =
1510
+ await useLazyAsyncData(
1511
+ "get-all-psgc-current-provinces",
1512
+ () =>
1513
+ getAllPSGC({
1514
+ type: "Prov",
1515
+ limit: 100,
1516
+ }),
1517
+ {
1518
+ watch: [selectCurrentRegion],
1519
+ }
1520
+ );
1521
+
1522
+ const loadingCurrentProvinces = computed(
1523
+ () => statusCurrentProvinces.value === "pending"
1524
+ );
1525
+
1526
+ watchEffect(() => {
1527
+ if (dataCurrentProvinces.value) {
1528
+ currentProvinces.value = dataCurrentProvinces.value.items;
1529
+ }
1530
+ });
1531
+
1524
1532
  const citiesMunicipalities = ref<Array<Record<string, any>>>([]);
1525
1533
  const cityMunicipality = ref("");
1526
1534
 
1535
+ // Flag to prevent cascade when clearing location fields programmatically
1536
+ const isLocationClearingSchool = ref(false);
1537
+
1527
1538
  watch(province, () => {
1528
1539
  cityMunicipality.value = "";
1529
1540
  });
@@ -1533,6 +1544,33 @@ watch(region, () => {
1533
1544
  cityMunicipality.value = "";
1534
1545
  });
1535
1546
 
1547
+ watch(
1548
+ () => enrollment.value.province,
1549
+ (val) => {
1550
+ if (!val) {
1551
+ enrollment.value.cityMunicipality = "";
1552
+ isLocationClearingSchool.value = true;
1553
+ enrollment.value.schoolId = "";
1554
+ nextTick(() => {
1555
+ isLocationClearingSchool.value = false;
1556
+ });
1557
+ }
1558
+ }
1559
+ );
1560
+
1561
+ watch(
1562
+ () => enrollment.value.cityMunicipality,
1563
+ (val) => {
1564
+ if (!val) {
1565
+ isLocationClearingSchool.value = true;
1566
+ enrollment.value.schoolId = "";
1567
+ nextTick(() => {
1568
+ isLocationClearingSchool.value = false;
1569
+ });
1570
+ }
1571
+ }
1572
+ );
1573
+
1536
1574
  const cityMunicipalityPrefix = computed(() => {
1537
1575
  let prefix = "";
1538
1576
  if (region.value) {
@@ -1552,11 +1590,11 @@ const { data: getAllPSGCCityMunData, status: getAllCityMunStatus } =
1552
1590
  () =>
1553
1591
  getAllPSGC({
1554
1592
  type: "City",
1555
- prefix: cityMunicipalityPrefix.value,
1593
+ prefix: selectedProvince.value.slice(0, 5),
1556
1594
  limit: 2000,
1557
1595
  }),
1558
1596
  {
1559
- watch: [cityMunicipalityPrefix],
1597
+ watch: [selectedProvince],
1560
1598
  }
1561
1599
  );
1562
1600
 
@@ -1570,6 +1608,107 @@ watchEffect(() => {
1570
1608
  }
1571
1609
  });
1572
1610
 
1611
+ const currentCitiesMunicipalities = ref<Array<Record<string, any>>>([]);
1612
+ const selectedCurrentProvince = computed(() => {
1613
+ const province = currentProvinces.value.find(
1614
+ (p) => p.name === enrollment.value.address.current.province
1615
+ );
1616
+
1617
+ if (!province) {
1618
+ return "";
1619
+ }
1620
+
1621
+ return province.code;
1622
+ });
1623
+
1624
+ const loadingCurrentCityMun = ref(false);
1625
+
1626
+ const getCurrentCityMun = debounce(async () => {
1627
+ if (!selectedCurrentProvince.value) {
1628
+ currentCitiesMunicipalities.value = [];
1629
+ return;
1630
+ }
1631
+
1632
+ try {
1633
+ loadingCurrentCityMun.value = true;
1634
+ const res = await getAllPSGC({
1635
+ type: "City",
1636
+ prefix: selectedCurrentProvince.value.slice(0, 5),
1637
+ limit: 2000,
1638
+ });
1639
+ currentCitiesMunicipalities.value = res.items;
1640
+ } catch (error) {
1641
+ currentCitiesMunicipalities.value = [];
1642
+ } finally {
1643
+ loadingCurrentCityMun.value = false;
1644
+ }
1645
+ }, 500);
1646
+
1647
+ watch(selectedCurrentProvince, () => {
1648
+ getCurrentCityMun();
1649
+ });
1650
+
1651
+ // Permanent Address - Province and City/Municipality
1652
+ const permanentProvinces = ref<Array<Record<string, any>>>([]);
1653
+
1654
+ const { data: dataPermanentProvinces, status: statusPermanentProvinces } =
1655
+ await useLazyAsyncData("get-all-psgc-permanent-provinces", () =>
1656
+ getAllPSGC({
1657
+ type: "Prov",
1658
+ limit: 100,
1659
+ })
1660
+ );
1661
+
1662
+ const loadingPermanentProvinces = computed(
1663
+ () => statusPermanentProvinces.value === "pending"
1664
+ );
1665
+
1666
+ watchEffect(() => {
1667
+ if (dataPermanentProvinces.value) {
1668
+ permanentProvinces.value = dataPermanentProvinces.value.items;
1669
+ }
1670
+ });
1671
+
1672
+ const permanentCitiesMunicipalities = ref<Array<Record<string, any>>>([]);
1673
+ const selectedPermanentProvince = computed(() => {
1674
+ const province = permanentProvinces.value.find(
1675
+ (p) => p.name === enrollment.value.address.permanent.province
1676
+ );
1677
+
1678
+ if (!province) {
1679
+ return "";
1680
+ }
1681
+
1682
+ return province.code;
1683
+ });
1684
+
1685
+ const loadingPermanentCityMun = ref(false);
1686
+
1687
+ const getPermanentCityMun = debounce(async () => {
1688
+ if (!selectedPermanentProvince.value) {
1689
+ permanentCitiesMunicipalities.value = [];
1690
+ return;
1691
+ }
1692
+
1693
+ try {
1694
+ loadingPermanentCityMun.value = true;
1695
+ const res = await getAllPSGC({
1696
+ type: "City",
1697
+ prefix: selectedPermanentProvince.value.slice(0, 5),
1698
+ limit: 2000,
1699
+ });
1700
+ permanentCitiesMunicipalities.value = res.items;
1701
+ } catch (error) {
1702
+ permanentCitiesMunicipalities.value = [];
1703
+ } finally {
1704
+ loadingPermanentCityMun.value = false;
1705
+ }
1706
+ }, 500);
1707
+
1708
+ watch(selectedPermanentProvince, () => {
1709
+ getPermanentCityMun();
1710
+ });
1711
+
1573
1712
  const { getAll } = useProgram();
1574
1713
 
1575
1714
  const programs = ref<Array<Record<string, any>>>([]);
@@ -1687,6 +1826,17 @@ const selectedSchool = computed(() => enrollment.value.schoolId);
1687
1826
 
1688
1827
  watch(selectedSchool, (val) => {
1689
1828
  enrollment.value.gradeLevel = "";
1829
+
1830
+ // Clear region, province, and cityMunicipality when schoolId is removed by user (not programmatically)
1831
+ if (!val) {
1832
+ if (!isLocationClearingSchool.value) {
1833
+ enrollment.value.region = "";
1834
+ enrollment.value.province = "";
1835
+ enrollment.value.cityMunicipality = "";
1836
+ }
1837
+ return;
1838
+ }
1839
+
1690
1840
  const school = schools.value.find((s) => s.id === val);
1691
1841
 
1692
1842
  if (school?.name) {
@@ -1696,16 +1846,11 @@ watch(selectedSchool, (val) => {
1696
1846
 
1697
1847
  enrollment.value.cityMunicipality = school?.cityMunicipalityPSGC ?? "";
1698
1848
 
1699
- if (school?.province) {
1700
- enrollment.value.province = school?.province;
1701
- }
1702
-
1703
- const regionPSGC = school?.cityMunicipalityPSGC
1704
- ? school?.cityMunicipalityPSGC.slice(0, 2) + "00000000"
1705
- : "";
1706
-
1707
- if (school?.region && regionPSGC) {
1708
- enrollment.value.region = regionPSGC;
1849
+ if (school && school.cityMunicipalityPSGC) {
1850
+ enrollment.value.province =
1851
+ school.cityMunicipalityPSGC.slice(0, 5) + "00000";
1852
+ enrollment.value.region =
1853
+ school.cityMunicipalityPSGC.slice(0, 2) + "00000000";
1709
1854
  }
1710
1855
 
1711
1856
  if (school?.regionName) {
@@ -1898,8 +2043,6 @@ const indigenousCommunitiesPhilippines = [
1898
2043
  ];
1899
2044
 
1900
2045
  const sameAsCurrentAddress = ref(false);
1901
- const fatherLegalGuardianSame = ref(false);
1902
- const motherLegalGuardianSame = ref(false);
1903
2046
 
1904
2047
  const alternativeLearning = [
1905
2048
  "Modular (Print)",
@@ -1990,44 +2133,6 @@ watchEffect(() => {
1990
2133
  }
1991
2134
  });
1992
2135
 
1993
- watchEffect(() => {
1994
- if (fatherLegalGuardianSame.value) {
1995
- enrollment.value.parentGuardianInfo.legalGuardian.firstName =
1996
- enrollment.value.parentGuardianInfo.father.firstName;
1997
- enrollment.value.parentGuardianInfo.legalGuardian.lastName =
1998
- enrollment.value.parentGuardianInfo.father.lastName;
1999
- enrollment.value.parentGuardianInfo.legalGuardian.middleName =
2000
- enrollment.value.parentGuardianInfo.father.middleName;
2001
- enrollment.value.parentGuardianInfo.legalGuardian.contactNumber =
2002
- enrollment.value.parentGuardianInfo.father.contactNumber;
2003
- motherLegalGuardianSame.value = false;
2004
- } else {
2005
- enrollment.value.parentGuardianInfo.legalGuardian.firstName = "";
2006
- enrollment.value.parentGuardianInfo.legalGuardian.lastName = "";
2007
- enrollment.value.parentGuardianInfo.legalGuardian.middleName = "";
2008
- enrollment.value.parentGuardianInfo.legalGuardian.contactNumber = "";
2009
- }
2010
- });
2011
-
2012
- watchEffect(() => {
2013
- if (motherLegalGuardianSame.value) {
2014
- enrollment.value.parentGuardianInfo.legalGuardian.firstName =
2015
- enrollment.value.parentGuardianInfo.mother.firstName;
2016
- enrollment.value.parentGuardianInfo.legalGuardian.lastName =
2017
- enrollment.value.parentGuardianInfo.mother.lastName;
2018
- enrollment.value.parentGuardianInfo.legalGuardian.middleName =
2019
- enrollment.value.parentGuardianInfo.mother.middleName;
2020
- enrollment.value.parentGuardianInfo.legalGuardian.contactNumber =
2021
- enrollment.value.parentGuardianInfo.mother.contactNumber;
2022
- fatherLegalGuardianSame.value = false;
2023
- } else {
2024
- enrollment.value.parentGuardianInfo.legalGuardian.firstName = "";
2025
- enrollment.value.parentGuardianInfo.legalGuardian.lastName = "";
2026
- enrollment.value.parentGuardianInfo.legalGuardian.middleName = "";
2027
- enrollment.value.parentGuardianInfo.legalGuardian.contactNumber = "";
2028
- }
2029
- });
2030
-
2031
2136
  import { useMask } from "vuetify";
2032
2137
 
2033
2138
  watchEffect(() => {
@@ -91,7 +91,7 @@ export default function useEnrollment() {
91
91
  },
92
92
  remarks: "",
93
93
  alternativeLearningOptions: [],
94
- isCertifiedAndConsented: true,
94
+ isCertifiedAndConsented: false,
95
95
  });
96
96
 
97
97
  function add(value: TTLearner) {
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.28",
5
+ "version": "1.7.29",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"