Skip to content

Commit d8f1543

Browse files
committed
departments go to model
1 parent df2872b commit d8f1543

4 files changed

Lines changed: 98 additions & 48 deletions

File tree

my-app/src/model.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export const model = {
2525
creditMin: 0,
2626
creditMax: 45,
2727
applyDepartmentFilter: true,
28-
department: []
28+
department: ["EECS/Computational Science and Technology", "EECS/Theoretical Computer Science", "EECS/Electric Power and Energy Systems", "EECS/Network and Systems Engineering",
29+
"ITM/Learning in Engineering Sciences", "ITM/Industrial Economics and Management", "ITM/Energy Systems", "ITM/Integrated Product Development and Design", "ITM/SKD GRU",
30+
"SCI/Mathematics", "SCI/Applied Physics", "SCI/Mechanics", "SCI/Aeronautical and Vehicle Engineering",
31+
"ABE/Sustainability and Environmental Engineering", "ABE/Concrete Structures", "ABE/Structural Design & Bridges", "ABE/History of Science, Technology and Environment", ]
2932
},
3033

3134
setUser(user) {
@@ -132,14 +135,17 @@ export const model = {
132135
this.filterOptions.eligibility = eligibility;
133136
},
134137

138+
updateDepartmentFilter(department) {
139+
console.log(department);
140+
this.filterOptions.department = department;
141+
},
142+
135143
//setters for the filter options
136144
setApplyTranscriptFilter(transcriptFilterState) {
137145
this.filterOptions.applyTranscriptFilter = transcriptFilterState;
138146
},
139147
setApplyLevelFilter(levelFilterState) {
140148
this.filterOptions.applyLevelFilter = levelFilterState;
141-
142-
console.log("model -",this.filterOptions.level);
143149
},
144150
setApplyLanguageFilter(languageFilterState) {
145151
this.filterOptions.applyLanguageFilter = languageFilterState;
@@ -150,9 +156,9 @@ export const model = {
150156
setApplyCreditsFilter(creditsFilterState) {
151157
this.filterOptions.applyCreditsFilter = creditsFilterState;
152158
},
153-
// setApplyDepartmentFilter(departmentFilterState) {
154-
// this.filterOptions.applyDepartmentFilter = departmentFilterState;
155-
// },
159+
setApplyDepartmentFilter(departmentFilterState) {
160+
this.filterOptions.applyDepartmentFilter = departmentFilterState;
161+
},
156162

157163

158164

my-app/src/presenters/SidebarPresenter.jsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const SidebarPresenter = observer(({ model }) => {
1111

1212
let currentLanguageSet = 'none';
1313
let currentLevelSet = ["PREPARATORY", "BASIC", "ADVANCED", "RESEARCH"];
14+
let currentDepartmentSet = [
15+
"EECS/Computational Science and Technology", "EECS/Theoretical Computer Science", "EECS/Electric Power and Energy Systems", "EECS/Network and Systems Engineering",
16+
"ITM/Learning in Engineering Sciences", "ITM/Industrial Economics and Management", "ITM/Energy Systems", "ITM/Integrated Product Development and Design", "ITM/SKD GRU",
17+
"SCI/Mathematics", "SCI/Applied Physics", "SCI/Mechanics", "SCI/Aeronautical and Vehicle Engineering",
18+
"ABE/Sustainability and Environmental Engineering", "ABE/Concrete Structures", "ABE/Structural Design & Bridges", "ABE/History of Science, Technology and Environment",
19+
]
1420
function handleLanguageFilterChange(param) {
1521
if (param === "English") {
1622
switch (currentLanguageSet) {
@@ -77,6 +83,19 @@ const SidebarPresenter = observer(({ model }) => {
7783
model.updateLevelFilter(currentLevelSet);
7884
}
7985

86+
function handleDepartmentFilterChange(param) {
87+
if (currentDepartmentSet.includes(param)) {
88+
const index = currentDepartmentSet.indexOf(param);
89+
if (index > -1) {
90+
currentDepartmentSet.splice(index, 1);
91+
}
92+
} else {
93+
currentDepartmentSet.push(param);
94+
}
95+
model.updateDepartmentFilter(currentDepartmentSet);
96+
model.setFiltersChange();
97+
}
98+
8099
/*HandleFilterChange param is structured as such
81100
[
82101
type of the field: (toggle, slider, dropdown, buttongroup)
@@ -101,6 +120,9 @@ const SidebarPresenter = observer(({ model }) => {
101120
case "eligibility":
102121
model.updateTranscriptElegibilityFilter(param[2].toLowerCase());
103122
break;
123+
case "department":
124+
handleDepartmentFilterChange(param[2]);
125+
break;
104126
default:
105127
console.log("Invalid filter type");
106128
}
@@ -121,8 +143,6 @@ const SidebarPresenter = observer(({ model }) => {
121143
break;
122144
case "level":
123145
console.log("level filter set to: " + param[1]);
124-
125-
console.log("model -",model.filterOptions.level);
126146
model.setApplyLevelFilter(param[1]);
127147
break;
128148
case "location":
@@ -137,6 +157,10 @@ const SidebarPresenter = observer(({ model }) => {
137157
console.log("transcript filter set to: " + param[1]);
138158
model.setApplyTranscriptFilter(param[1]);
139159
break;
160+
case "department":
161+
console.log("department filter set to: " + param[1]);
162+
model.setApplyDepartmentFilter(param[1]);
163+
break;
140164
default:
141165
console.log("Invalid filter type");
142166
}
@@ -146,12 +170,12 @@ const SidebarPresenter = observer(({ model }) => {
146170
model.setFiltersChange();
147171
}
148172

149-
173+
150174

151175
return (
152176
<SidebarView HandleFilterChange={HandleFilterChange}
153177
HandleFilterEnable={HandleFilterEnable}
154-
reApplyFilter = {reApplyFilter}
178+
reApplyFilter={reApplyFilter}
155179
/>
156180
);
157181
});

my-app/src/views/Components/SideBarComponents/CollapsibleCheckboxes.jsx

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const CollapsibleCheckboxes = (props) => {
99

1010
const strokeWidth = 5;
1111

12+
let paramFieldType = "checkboxhierarchy";
13+
14+
const rows = props.fields;
15+
1216
const toggleExpand = (id, subItems) => {
1317
setExpanded((prev) => ({
1418
...prev,
@@ -33,38 +37,9 @@ const CollapsibleCheckboxes = (props) => {
3337
...prev,
3438
[key]: !prev[key],
3539
}));
40+
props.HandleFilterChange([paramFieldType, props.filterName, rows.find(item => item.id === mainId).label+"/"+rows.find(item => item.id === mainId).subItems[index]]);
3641
};
3742

38-
const rows = [
39-
{
40-
id: 1,
41-
label: "Category 1",
42-
subItems: ["Sub-item 1.1", "Sub-item 1.2", "Sub-item 1.3"],
43-
},
44-
{
45-
id: 2,
46-
label: "Category 2",
47-
subItems: ["Sub-item 2.1", "Sub-item 2.2"],
48-
},
49-
{
50-
id: 3,
51-
label: "Category 2",
52-
subItems: ["Sub-item 2.1", "Sub-item 2.2"],
53-
},
54-
{
55-
id: 4,
56-
label: "Category 3",
57-
subItems: [
58-
"Sub-item 3.1",
59-
"Sub-item 3.2",
60-
"Sub-item 3.3",
61-
"Sub-item 3.4",
62-
"Sub-item 3.5",
63-
"Sub-item 3.6",
64-
],
65-
},
66-
];
67-
6843

6944
return (
7045
<div className="m-2">
@@ -190,7 +165,7 @@ const CollapsibleCheckboxes = (props) => {
190165
onChange={() => toggleSubCheckbox(row.id, index)}
191166
/>
192167
<label htmlFor={checkboxId} className="cursor-pointer ml-2">
193-
{subItem}
168+
{subItem.substring(0, 25) + ((subItem.substring(0, 25).length>=25)? "...": "") }
194169
</label>
195170
</div>
196171
);

my-app/src/views/SidebarView.jsx

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@ function SidebarView(props) {
1818
}}
1919
>
2020
<h6 className="m-2 text-lg font-medium text-white text-center">
21-
Filters
22-
</h6>
21+
Filters
22+
</h6>
2323
<UploadTranscriptPresenter
2424
HandleFilterChange={props.HandleFilterChange}
25-
filterName = "transcript"
25+
filterName="transcript"
2626
HandleFilterEnable={props.HandleFilterEnable}
27-
reApplyFilter = {props.reApplyFilter}
27+
reApplyFilter={props.reApplyFilter}
2828
/>
2929
<div className='flex-auto justify-center h-100 max-h-100 '>
3030
<div className="z-10 w-100% rounded-lg justify-center pb-10" >
31-
31+
3232
<DropDownField
3333
options={["Preparatory", "Basic", "Advanced", "Research"]}
3434
HandleFilterChange={props.HandleFilterChange}
35-
filterName = "level"
35+
filterName="level"
3636
HandleFilterEnable={props.HandleFilterEnable}
3737
/>
3838
<ToggleField
3939
fields={["English", "Swedish"]}
4040
HandleFilterChange={props.HandleFilterChange}
41-
filterName = "language"
41+
filterName="language"
4242
HandleFilterEnable={props.HandleFilterEnable}
4343
/>
4444

@@ -59,6 +59,51 @@ function SidebarView(props) {
5959
HandleFilterChange={props.HandleFilterChange}
6060
filterName="department"
6161
HandleFilterEnable={props.HandleFilterEnable}
62+
fields={
63+
[
64+
{
65+
id: 1,
66+
label: "EECS",
67+
subItems: [
68+
"Computational Science and Technology",
69+
"Theoretical Computer Science",
70+
"Electric Power and Energy Systems",
71+
"Network and Systems Engineering",
72+
],
73+
},
74+
{
75+
id: 2,
76+
label: "ITM",
77+
subItems: [
78+
"Learning in Engineering Sciences",
79+
"Industrial Economics and Management",
80+
"Energy Systems",
81+
"Integrated Product Development and Design",
82+
"SKD GRU",
83+
],
84+
},
85+
{
86+
id: 3,
87+
label: "SCI",
88+
subItems: [
89+
"Mathematics",
90+
"Applied Physics",
91+
"Mechanics",
92+
"Aeronautical and Vehicle Engineering",
93+
],
94+
},
95+
{
96+
id: 4,
97+
label: "ABE",
98+
subItems: [
99+
"Sustainability and Environmental Engineering",
100+
"Concrete Structures",
101+
"Structural Design & Bridges",
102+
"History of Science, Technology and Environment",
103+
],
104+
},
105+
]
106+
}
62107
/>
63108
</div>
64109

0 commit comments

Comments
 (0)