Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDX-1670: fix for not being able to select a value for the new school… #1516

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions frontend/src/components/institute/NewSchoolPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@
id="newSchoolPostBtn"
text="Save"
width="7rem"
@click-action="addNewSchool"
:disabled="!isFormValid"
:loading="processing"
@click-action="addNewSchool"
/>
</v-card-actions>
</v-card>
Expand Down Expand Up @@ -515,6 +515,7 @@ export default {
required: true
},
},
emits: ['newSchool:closeNewSchoolPage'],
data() {
return {
isFormValid: false,
Expand Down Expand Up @@ -570,13 +571,6 @@ export default {
}
};
},
mounted() {
this.validateForm();
this.addressButton = {
icon: 'mdi-plus-thick',
label: 'Add Address'
};
},
computed: {
...mapState(authStore, ['isAuthenticated', 'userInfo', 'SCHOOL_INDEPENDENT_ADMIN_ROLE']),
...mapState(instituteStore, ['activeFacilityTypeCodes', 'activeSchoolCategoryTypeCodes', 'activeSchoolOrganizationTypeCodes', 'schoolReportingRequirementTypeCodes', 'activeSchoolNeighborhoodLearningCodes', 'activeGradeCodes', 'activeProvinceCodes', 'activeCountryCodes', 'schoolCategoryFacilityTypesMap', 'schoolReportingRequirementTypeCodes']),
Expand All @@ -585,9 +579,7 @@ export default {
if (!this.activeFacilityTypeCodes || !this.newSchool?.schoolCategoryCode) {
return [];
}

let facilityTypes = this.schoolCategoryFacilityTypesMap[this.newSchool?.schoolCategoryCode]?.map(schoolCatFacilityTypeCode => this.activeFacilityTypeCodes.find(facTypCode => facTypCode.facilityTypeCode === schoolCatFacilityTypeCode));
this.enableOrDisableFacilityType(facilityTypes);
return sortBy(facilityTypes, ['displayOrder']);
},
schoolCategoryTypeCodes() {
Expand Down Expand Up @@ -622,6 +614,13 @@ export default {
return this.schoolReportingRequirementTypeCodes ? this.schoolReportingRequirementTypeCodes : [];
}
},
mounted() {
this.validateForm();
this.addressButton = {
icon: 'mdi-plus-thick',
label: 'Add Address'
};
},
created() {
const instStore = instituteStore();
instStore.getAllActiveFacilityTypeCodes();
Expand All @@ -635,16 +634,6 @@ export default {
instStore.getSchoolReportingRequirementTypeCodes();
},
methods: {
enableOrDisableFacilityType(facilityTypes) {
this.isFacilityTypeDisabled = facilityTypes && facilityTypes.length === 1;
if (this.isFacilityTypeDisabled) {
this.newSchool.facilityTypeCode = facilityTypes[0].facilityTypeCode;
} else {
this.newSchool.facilityTypeCode = null;
}

this.validateForm();
},
openEffectiveDatePicker() {
this.$refs.newSchoolDatePicker.openMenu();
},
Expand Down Expand Up @@ -704,6 +693,13 @@ export default {
}
},
async schoolCategoryChanged() {
if (this.allowedFacilityTypeCodesForSchoolCategoryCode.length <= 1) {
this.isFacilityTypeDisabled = true;
this.newSchool.facilityTypeCode = this.allowedFacilityTypeCodesForSchoolCategoryCode[0]?.facilityTypeCode ?? null;
} else {
this.isFacilityTypeDisabled = false;
this.newSchool.facilityTypeCode = null;
}
if (this.newSchool.schoolCategoryCode && this.requiredAuthoritySchoolCategories.includes(this.newSchool.schoolCategoryCode)) {
this.authorityDisabled = false;
} else {
Expand Down
Loading