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

DOM manipulation removal #170

Merged
merged 21 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2,491 changes: 1,437 additions & 1,054 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/components/Course.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,10 @@ export default {
};
},
computed: {
rqString() {
return 'RQ';
},

// TODO: bold requirements
requirementString() {
return this.alerts.requirement;
},

// TODO: too much DOM manipulation that vue should fix - talk to Sam
cautionString() {
return this.alerts.caution;
},
Expand All @@ -137,7 +131,6 @@ export default {
return `https://www.cureviews.org/course/${this.subject}/${this.number}`;
},

// TODO: change semester from FA18
roster() {
return `https://classes.cornell.edu/browse/roster/FA18/class/${this.subject}/${this.number}`;
},
Expand Down
5 changes: 1 addition & 4 deletions src/components/Modals/DeleteSemester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
<script>
import Vue from 'vue';
import NewCourse from '@/components/Modals/NewCourse';
import NewCustomCourse from '@/components/Modals/NewCustomCourse';
import NewSemester from '@/components/Modals/NewSemester';

Vue.component('newCourse', NewCourse);
Vue.component('newCustomCourse', NewCustomCourse);
Vue.component('newSemester', NewSemester);


Expand All @@ -52,8 +50,7 @@ export default {
},
methods: {
closeCurrentModal() {
const modal = document.getElementById(`deleteSemesterModal-${this.deleteSemID}`);
modal.style.display = 'none';
this.$emit('close-delete-modal');
},
deleteSemester() {
this.$emit('delete-semester', this.deleteSemType, this.deleteSemYear);
Expand Down
16 changes: 10 additions & 6 deletions src/components/Modals/EditSemester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:year="deleteSemYear"
:type="deleteSemType"
@duplicateSemester="disableButton"
@updateSemProps="updateSemProps"
ref="modalBodyComponent">
</newSemester>
</div>
Expand All @@ -32,11 +33,9 @@
<script>
import Vue from 'vue';
import NewCourse from '@/components/Modals/NewCourse';
import NewCustomCourse from '@/components/Modals/NewCustomCourse';
import NewSemester from '@/components/Modals/NewSemester';

Vue.component('newCourse', NewCourse);
Vue.component('newCustomCourse', NewCustomCourse);
Vue.component('newSemester', NewSemester);

export default {
Expand All @@ -48,7 +47,9 @@ export default {
},
data() {
return {
isDisabled: false
isDisabled: false,
season: '',
year: ''
};
},
computed: {
Expand All @@ -64,17 +65,20 @@ export default {
},
methods: {
closeCurrentModal() {
const modal = document.getElementById(`editSemesterModal-${this.deleteSemID}`);
modal.style.display = 'none';
this.$emit('close-edit-modal');
},
editSemester() {
if (!this.isDisabled) {
this.$parent.editSemester(this.deleteSemID);
this.$emit('edit-semester', this.season, this.year);
this.closeCurrentModal();
}
},
disableButton(bool) {
this.isDisabled = bool;
},
updateSemProps(season, year) {
this.season = season;
this.year = year;
}
}
};
Expand Down
36 changes: 16 additions & 20 deletions src/components/Modals/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
:currentSemesters="currentSemesters"
placeholderText = 'CS 1110", "Multivariable Calculus", etc.'
@duplicateSemester="disableButton"
@close-current-model="closeCourseModal"
@updateSemProps="updateSemProps"
ref="modalBodyComponent"
></component>
<div class="modal-buttonWrapper">
Expand All @@ -26,12 +28,10 @@
<script>
import Vue from 'vue';
import NewCourse from '@/components/Modals/NewCourse';
import NewCustomCourse from '@/components/Modals/NewCustomCourse';
import NewSemester from '@/components/Modals/NewSemester';
import EditSemester from '@/components/Modals/EditSemester';

Vue.component('newCourse', NewCourse);
Vue.component('newCustomCourse', NewCustomCourse);
Vue.component('newSemester', NewSemester);
Vue.component('editSemester', EditSemester);

Expand All @@ -40,7 +40,9 @@ export default {
return {
isOnboard: false,
courseIsAddable: true,
isDisabled: false
isDisabled: false,
season: '',
year: ''
};
},
props: {
Expand Down Expand Up @@ -75,24 +77,24 @@ export default {
if (this.type === 'course') {
return 'newCourse';
}
return 'newCustomCourse';
return '';
}
},
methods: {
disableButton(bool) {
this.isDisabled = bool;
},
closeCourseModal() {
this.$emit('close-course-modal');
},
closeCurrentModal() {
let modal;
if (this.type === 'course') {
modal = document.getElementById(`${this.type}Modal-${this.semesterID}`);
} else {
modal = document.getElementById(`${this.type}Modal`);
this.$emit('close-course-modal');
return;
}
if (this.type === 'semester') {
this.$refs.modalBodyComponent.resetDropdowns();
}
modal.style.display = 'none';
},
// Note: Currently not used
checkCourseDuplicate(key) {
Expand All @@ -103,13 +105,10 @@ export default {
const dropdown = document.getElementById(`dropdown-${this.semesterID}`);
const title = dropdown.value;

// TODO: can I make the valid assumption that the course code is up to the colon in the title?
const key = title.substring(0, title.indexOf(':'));
this.addCourse();
} else if (this.type === 'semester') {
this.addSemester();
} else {
// TODO: add custom course
}
},
addCourse() {
Expand All @@ -118,7 +117,6 @@ export default {
// name used to transmit roster information
const roster = dropdown.name;

// TODO: can I make the valid assumption that the course code is up to the colon in the title?
const courseCode = title.substring(0, title.indexOf(':'));
const subject = courseCode.split(' ')[0];
const number = courseCode.split(' ')[1];
Expand Down Expand Up @@ -160,22 +158,20 @@ export default {
},
addSemester() {
if (!this.isDisabled) {
const seasonInput = document.getElementById(`season-placeholder`);
const yearInput = document.getElementById(`year-placeholder`);
this.$parent.addSemester(
seasonInput.innerHTML.trim(' ').split(' ')[0],
parseInt(yearInput.innerHTML, 10)
);
this.$emit('add-semester', this.season, this.year);

this.closeCurrentModal();
}
},
updateSemProps(season, year) {
this.season = season;
this.year = year;
}
}
};
</script>

<style lang="scss">
// TODO: font family
.modal {
padding: 1rem;

Expand Down
8 changes: 6 additions & 2 deletions src/components/Modals/NewCourse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ export default {
}
},
mounted() {
// Activate focus and set input to empty
const input = document.getElementById(`dropdown-${this.semesterID}`);
input.value = '';
input.focus();

this.autocomplete(
document.getElementById(`dropdown-${this.semesterID}`),
coursesJSON
);
},
methods: {
closeCourseModal() {
const modal = document.getElementById(`courseModal-${this.semesterID}`);
modal.style.display = 'none';
this.$emit('close-course-modal');
},
autocomplete(inp, courses) {
/* the autocomplete function takes two arguments,
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions src/components/Modals/NewSemester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export default {
directives: {
'click-outside': clickOutside
},
mounted() {
this.$emit('updateSemProps', this.seasonPlaceholder, this.yearPlaceholder);
},
methods: {
seasonValue(season) {
return SeasonsEnum[season[1].toLowerCase()];
Expand Down Expand Up @@ -259,6 +262,7 @@ export default {
displayOptions.boxBorder = '#C4C4C4';
displayOptions.arrowColor = '#C4C4C4';
displayOptions.placeholderColor = '#757575';
this.$emit('updateSemProps', this.seasonText || this.seasonPlaceholder, this.yearText || this.yearPlaceholder);
},
selectSeason(text) {
this.selectOption('season', text);
Expand Down
Loading