@@ -3,11 +3,32 @@ import { addCourse, addReviewForCourse, getReviewsForCourse } from "../firebase"
33
44export const model = {
55 user : undefined ,
6+ //add searchChange: false, //this is for reworking the searchbar presenter, so that it triggers as a model,
7+ //instead of passing searchcouses lambda function down into the searchbarview.
68 currentSearch : [ ] ,
79 currentSearchText : "" ,
810 scrollPosition : 0 ,
911 courses : [ ] ,
1012 favourites : [ ] ,
13+ isReady : false ,
14+ filtersChange : false ,
15+ filtersCalculated : false ,
16+ filteredCourses : [ ] ,
17+ filterOptions : {
18+ applyTranscriptFilter : true ,
19+ eligibility : "weak" , //the possible values for the string are: "weak"/"moderate"/"strong"
20+ applyLevelFilter : true ,
21+ level : [ ] , //the possible values for the array are: "PREPARATORY", "BASIC", "ADVANCED", "RESEARCH"
22+ applyLanguageFilter : true ,
23+ language : "none" , //the possible values for the string are: "none"/"english"/"swedish"/"both"
24+ applyLocationFilter :true ,
25+ location : [ ] , //the possible values for the array are: 'KTH Campus', 'KTH Kista', 'AlbaNova', 'KTH Flemingsberg', 'KTH Solna', 'KTH Södertälje', 'Handelshögskolan', 'KI Solna', 'Stockholms universitet', 'KONSTFACK'
26+ applyCreditsFilter :true ,
27+ creditMin : 0 ,
28+ creditMax : 45 ,
29+ applyDepartmentFilter :false ,
30+ department : [ ]
31+ } ,
1132
1233 setUser ( user ) {
1334 if ( ! this . user )
@@ -76,7 +97,6 @@ export const model = {
7697 this . addCourse ( course ) ;
7798 } ) ;
7899 } ,
79-
80100 //for reviews
81101 async addReview ( courseCode , review ) {
82102 try {
@@ -95,4 +115,53 @@ export const model = {
95115 return [ ] ;
96116 }
97117 } ,
118+ //for filters
119+
120+ setFiltersChange ( ) {
121+ this . filtersChange = true ;
122+ } ,
123+
124+ setFiltersCalculated ( ) {
125+ this . filtersCalculated = true ;
126+ } ,
127+
128+ updateLevelFilter ( level ) {
129+ this . filterOptions . level = level ;
130+ } ,
131+ updateLanguageFilter ( languages ) {
132+ this . filterOptions . language = languages ;
133+ } ,
134+ updateLocationFilter ( location ) {
135+ this . filterOptions . location = location ;
136+ } ,
137+ updateCreditsFilter ( creditLimits ) {
138+ this . filterOptions . creditMin = creditLimits [ 0 ] ;
139+ this . filterOptions . creditMax = creditLimits [ 1 ] ;
140+ } ,
141+ updateTranscriptElegibilityFilter ( eligibility ) {
142+ this . filterOptions . eligibility = eligibility ;
143+ } ,
144+
145+ //setters for the filter options
146+ setApplyTranscriptFilter ( transcriptFilterState ) {
147+ this . filterOptions . applyTranscriptFilter = transcriptFilterState ;
148+ } ,
149+ setApplyLevelFilter ( levelFilterState ) {
150+ this . filterOptions . applyLevelFilter = levelFilterState ;
151+ } ,
152+ setApplyLanguageFilter ( languageFilterState ) {
153+ this . filterOptions . applyLanguageFilter = languageFilterState ;
154+ } ,
155+ setApplyLocationFilter ( locationFilterState ) {
156+ this . filterOptions . applyLocationFilter = locationFilterState ;
157+ } ,
158+ setApplyCreditsFilter ( creditsFilterState ) {
159+ this . filterOptions . applyCreditsFilter = creditsFilterState ;
160+ } ,
161+ // setApplyDepartmentFilter(departmentFilterState) {
162+ // this.filterOptions.applyDepartmentFilter = departmentFilterState;
163+ // },
164+
165+
166+
98167} ;
0 commit comments