Skip to content

Commit c1b124a

Browse files
committed
Properly showing or not showing filters/criterias accroding to number of saved filters
1 parent 0745ef8 commit c1b124a

File tree

4 files changed

+34
-49
lines changed

4 files changed

+34
-49
lines changed

kiohub-client/src/app/advanced-search-form/advanced-search-form.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,39 +163,39 @@ export class AdvancedSearchFormComponent implements OnInit, IAdvancedSearchFormV
163163

164164
private restoreFromSession() {
165165
const supervisors = this.valueUtils.getDataFromSessionStorage(SEARCH_SUPERVISORS);
166-
if (supervisors) {
166+
if (supervisors && supervisors.length > 0) {
167167
supervisors.split(',').forEach(str => this.supervisorsList.add({ name: str }));
168168
}
169169
const titles = this.valueUtils.getDataFromSessionStorage(SEARCH_TITLES);
170-
if (titles) {
170+
if (titles && titles.length > 0) {
171171
titles.split(',').forEach(str => this.titlesList.add({ name: str }));
172172
}
173173
const descriptions = this.valueUtils.getDataFromSessionStorage(SEARCH_DESC);
174-
if (descriptions) {
174+
if (descriptions && descriptions.length > 0) {
175175
descriptions.split(',').forEach(str => this.descriptionsList.add({ name: str }));
176176
}
177177
const tags = this.valueUtils.getDataFromSessionStorage(SEARCH_TAGS);
178-
if (tags) {
178+
if (tags && tags.length > 0) {
179179
tags.split(',').forEach(str => this.tagsList.add({ name: str }));
180180
}
181181
const licences = this.valueUtils.getDataFromSessionStorage(SEARCH_LICENCES);
182-
if (licences) {
182+
if (licences && licences.length > 0) {
183183
licences.split(',').forEach(str => this.licencesList.add({ name: str }));
184184
}
185185
const types = this.valueUtils.getDataFromSessionStorage(SEARCH_TYPES);
186-
if (types) {
186+
if (types && types.length > 0) {
187187
types.split(',').forEach(str => this.typesList.add({ name: str }));
188188
}
189189
const semesters = this.valueUtils.getDataFromSessionStorage(SEARCH_SEMESTERS);
190-
if (semesters) {
190+
if (semesters && semesters.length > 0) {
191191
semesters.split(',').forEach(str => this.showAddedSemester(this.semesterFromString(str)));
192192
}
193193
const dateFrom = this.valueUtils.getDataFromSessionStorage(SEARCH_DATE_FROM);
194-
if (dateFrom) {
194+
if (dateFrom && dateFrom !== 'undefined') {
195195
this.dateFrom = new Date(dateFrom);
196196
}
197197
const dateTo = this.valueUtils.getDataFromSessionStorage(SEARCH_DATE_TO);
198-
if (dateTo) {
198+
if (dateTo && dateTo !== 'undefined') {
199199
this.dateTo = new Date(dateTo);
200200
}
201201
}

kiohub-client/src/app/advanced-search/advanced-search.component.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export class AdvancedSearchComponent implements OnInit {
5757
this.searchResults = results.map(r => new SearchResult(r, 0));
5858
this.dataSource = new MatTableDataSource<SearchResult>(this.searchResults);
5959
this.showFilters = this.checkIfFiltersAreInSession();
60-
console.log('checkIfFilters... ' + this.checkIfFiltersAreInSession());
6160
});
6261
}
6362

@@ -121,21 +120,14 @@ export class AdvancedSearchComponent implements OnInit {
121120
if (sessionStorage.length === 0 ) {
122121
return false;
123122
}
124-
return sessionStorage.getItem(SEARCH_DATE_FROM) !== 'undefined'
125-
|| sessionStorage.getItem(SEARCH_DATE_TO) !== 'undefined'
126-
|| sessionStorage.getItem(SEARCH_DESC) !== null
127-
&& sessionStorage.getItem(SEARCH_DESC).length > 0
128-
|| sessionStorage.getItem(SEARCH_LICENCES) != null
129-
&& sessionStorage.getItem(SEARCH_LICENCES).length > 0
130-
|| sessionStorage.getItem(SEARCH_SEMESTERS) !== null
131-
&& sessionStorage.getItem(SEARCH_SEMESTERS).length > 0
132-
|| sessionStorage.getItem(SEARCH_SUPERVISORS) !== null
133-
&& sessionStorage.getItem(SEARCH_SUPERVISORS).length > 0
134-
|| sessionStorage.getItem(SEARCH_TAGS) !== null
135-
&& sessionStorage.getItem(SEARCH_TAGS).length > 0
136-
|| sessionStorage.getItem(SEARCH_TITLES) !== null
137-
&& sessionStorage.getItem(SEARCH_TITLES).length > 0
138-
|| sessionStorage.getItem(SEARCH_TYPES) !== null
139-
&& sessionStorage.getItem(SEARCH_TYPES).length > 0;
123+
return (sessionStorage.getItem(SEARCH_DATE_FROM) !== null && sessionStorage.getItem(SEARCH_DATE_FROM) !== 'undefined')
124+
|| (sessionStorage.getItem(SEARCH_DATE_TO) !== null && sessionStorage.getItem(SEARCH_DATE_TO) !== 'undefined')
125+
|| (sessionStorage.getItem(SEARCH_DESC) !== null && sessionStorage.getItem(SEARCH_DESC).length > 0)
126+
|| (sessionStorage.getItem(SEARCH_LICENCES) !== null && sessionStorage.getItem(SEARCH_LICENCES).length > 0)
127+
|| (sessionStorage.getItem(SEARCH_SEMESTERS) !== null && sessionStorage.getItem(SEARCH_SEMESTERS).length > 0)
128+
|| (sessionStorage.getItem(SEARCH_SUPERVISORS) !== null && sessionStorage.getItem(SEARCH_SUPERVISORS).length > 0)
129+
|| (sessionStorage.getItem(SEARCH_TAGS) !== null && sessionStorage.getItem(SEARCH_TAGS).length > 0)
130+
|| (sessionStorage.getItem(SEARCH_TITLES) !== null && sessionStorage.getItem(SEARCH_TITLES).length > 0)
131+
|| (sessionStorage.getItem(SEARCH_TYPES) !== null && sessionStorage.getItem(SEARCH_TYPES).length > 0);
140132
}
141133
}

kiohub-client/src/app/my-projects-search-form/my-projects-search-form.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,35 +266,35 @@ export class MyProjectsSearchFormComponent implements OnInit, IAdvancedSearchFor
266266

267267
private restoreFromSession() {
268268
const titles = this.valueUtils.getDataFromSessionStorage(FILTER_TITLES);
269-
if (titles) {
269+
if (titles && titles.length > 0) {
270270
titles.split(',').forEach(str => this.titlesList.add({ name: str }));
271271
}
272272
const status = this.valueUtils.getDataFromSessionStorage(FILTER_STATUS);
273-
if (status) {
273+
if (status && status.length > 0) {
274274
status.split(',').forEach(str => this.statusesList.add({ name: str }));
275275
}
276276
const tags = this.valueUtils.getDataFromSessionStorage(FILTER_TAGS);
277-
if (tags) {
277+
if (tags && tags.length > 0) {
278278
tags.split(',').forEach(str => this.tagsList.add({ name: str }));
279279
}
280280
const licences = this.valueUtils.getDataFromSessionStorage(FILTER_LICENCES);
281-
if (licences) {
281+
if (licences && licences.length > 0) {
282282
licences.split(',').forEach(str => this.licencesList.add({ name: str }));
283283
}
284284
const types = this.valueUtils.getDataFromSessionStorage(FILTER_TYPES);
285-
if (types) {
285+
if (types && types.length > 0) {
286286
types.split(',').forEach(str => this.typesList.add({ name: str }));
287287
}
288288
const semesters = this.valueUtils.getDataFromSessionStorage(FILTER_SEMESTERS);
289-
if (semesters) {
289+
if (semesters && semesters.length > 0) {
290290
semesters.split(',').forEach(str => this.showAddedSemester(this.semesterFromString(str)));
291291
}
292292
const dateFrom = this.valueUtils.getDataFromSessionStorage(FILTER_DATE_FROM);
293-
if (dateFrom) {
293+
if (dateFrom && dateFrom !== 'undefined') {
294294
this.dateFrom = new Date(dateFrom);
295295
}
296296
const dateTo = this.valueUtils.getDataFromSessionStorage(FILTER_DATE_TO);
297-
if (dateTo) {
297+
if (dateTo && dateTo !== 'undefined') {
298298
this.dateTo = new Date(dateTo);
299299
}
300300
}

kiohub-client/src/app/my-projects/my-projects.component.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export class MyProjectsComponent implements OnInit {
9393
this.displayedProjects = this.projects;
9494
this.filteredProjects = this.projects;
9595
this.sortAndSetByPinned();
96-
console.log('checkIfFilters... ' + this.checkIfFiltersAreInSession());
9796
this.showFilters = this.checkIfFiltersAreInSession();
9897
});
9998
} else {
@@ -251,19 +250,13 @@ export class MyProjectsComponent implements OnInit {
251250
if (sessionStorage.length === 0 ) {
252251
return false;
253252
}
254-
return sessionStorage.getItem(FILTER_DATE_FROM) !== 'undefined'
255-
|| sessionStorage.getItem(FILTER_DATE_TO) !== 'undefined'
256-
|| sessionStorage.getItem(FILTER_LICENCES) !== null
257-
&& sessionStorage.getItem(FILTER_LICENCES).length > 0
258-
|| sessionStorage.getItem(FILTER_SEMESTERS) !== null
259-
&& sessionStorage.getItem(FILTER_SEMESTERS).length > 0
260-
|| sessionStorage.getItem(FILTER_STATUS) !== null
261-
&& sessionStorage.getItem(FILTER_STATUS).length > 0
262-
|| sessionStorage.getItem(FILTER_TAGS) != null
263-
&& sessionStorage.getItem(FILTER_TAGS).length > 0
264-
|| sessionStorage.getItem(FILTER_TYPES) !== null
265-
&& sessionStorage.getItem(FILTER_TYPES).length > 0
266-
|| sessionStorage.getItem(FILTER_TITLES) !== null
267-
&& sessionStorage.getItem(FILTER_TITLES).length > 0;
253+
return sessionStorage.getItem(FILTER_DATE_FROM) !== null && sessionStorage.getItem(FILTER_DATE_FROM) !== 'undefined'
254+
|| sessionStorage.getItem(FILTER_DATE_TO) !== null && sessionStorage.getItem(FILTER_DATE_TO) !== 'undefined'
255+
|| sessionStorage.getItem(FILTER_LICENCES) !== null && sessionStorage.getItem(FILTER_LICENCES).length > 0
256+
|| sessionStorage.getItem(FILTER_SEMESTERS) !== null && sessionStorage.getItem(FILTER_SEMESTERS).length > 0
257+
|| sessionStorage.getItem(FILTER_STATUS) !== null && sessionStorage.getItem(FILTER_STATUS).length > 0
258+
|| sessionStorage.getItem(FILTER_TAGS) != null && sessionStorage.getItem(FILTER_TAGS).length > 0
259+
|| sessionStorage.getItem(FILTER_TYPES) !== null && sessionStorage.getItem(FILTER_TYPES).length > 0
260+
|| sessionStorage.getItem(FILTER_TITLES) !== null && sessionStorage.getItem(FILTER_TITLES).length > 0;
268261
}
269262
}

0 commit comments

Comments
 (0)