Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
Resin
Client
Commits
53a5cde6
Commit
53a5cde6
authored
2 years ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
fix(annuaire): filters
parent
e3dc13d4
No related branches found
No related tags found
2 merge requests
!525
V2.3.0
,
!500
fix(annuaire): filters
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/annuaire/filter-modal/filter-modal.component.ts
+20
-25
20 additions, 25 deletions
src/app/annuaire/filter-modal/filter-modal.component.ts
src/app/annuaire/search-bar/search-bar.component.html
+3
-1
3 additions, 1 deletion
src/app/annuaire/search-bar/search-bar.component.html
with
23 additions
and
26 deletions
src/app/annuaire/filter-modal/filter-modal.component.ts
+
20
−
25
View file @
53a5cde6
...
...
@@ -11,48 +11,37 @@ export class FilterModalComponent implements OnInit, OnChanges {
@
Input
()
public
modalType
:
TypeModal
;
@
Input
()
public
filtersTypes
:
string
[];
@
Input
()
public
checkedFilters
:
string
[];
@
Output
()
searchEvent
=
new
EventEmitter
();
@
Output
()
closeEvent
=
new
EventEmitter
();
@
Input
()
public
jobFilterChecked
:
string
[];
@
Input
()
public
employerFilterChecked
:
string
[];
@
Output
()
fetchResults
=
new
EventEmitter
<
string
[]
>
();
public
buttonTypeEnum
=
ButtonType
;
public
toggledCategories
:
string
[]
=
[];
public
currentCheckedFilters
:
string
[]
=
[];
ngOnInit
():
void
{
this
.
currentCheckedFilters
=
[...
this
.
checkedFilters
]
;
this
.
currentCheckedFilters
=
this
.
checkedFilters
.
slice
()
;
}
ngOnChanges
(
changes
:
SimpleChanges
):
void
{
if
(
changes
.
modalType
)
this
.
currentCheckedFilters
=
[]
;
if
(
changes
.
modalType
)
this
.
currentCheckedFilters
=
this
.
checkedFilters
.
slice
()
;
}
public
isFilterChecked
(
filter
:
string
):
boolean
{
return
this
.
currentCheckedFilters
.
f
in
dIndex
((
_filter
)
=>
_filter
===
filter
)
>
-
1
;
return
this
.
currentCheckedFilters
.
in
cludes
(
filter
)
;
}
public
toggleCheckbox
(
filter
:
string
):
void
{
const
filterExists
=
this
.
currentCheckedFilters
.
f
in
dIndex
((
_filterChecked
)
=>
_filterChecked
===
filter
)
!==
-
1
;
const
filterExists
=
this
.
currentCheckedFilters
.
in
cludes
(
filter
)
;
if
(
!
filterExists
)
{
const
index
=
this
.
filtersTypes
.
findIndex
((
_filter
)
=>
_filter
===
filter
);
const
index
=
this
.
filtersTypes
.
indexOf
(
filter
);
this
.
currentCheckedFilters
.
push
(
this
.
filtersTypes
[
index
]);
}
else
{
const
filterToRemove
=
this
.
currentCheckedFilters
.
f
ind
Index
((
_filterChecked
)
=>
_filterChecked
===
filter
);
this
.
currentCheckedFilters
.
splice
(
filterToRemove
);
const
filterToRemove
=
this
.
currentCheckedFilters
.
ind
exOf
(
filter
);
this
.
currentCheckedFilters
.
splice
(
filterToRemove
,
1
);
}
}
// Clear only filters in the current modal
public
clearFilters
():
void
{
this
.
checkedFilters
=
[];
this
.
currentCheckedFilters
=
[];
this
.
emitModules
(
this
.
checkedFilters
);
}
// Sends an array containing all modules
public
emitModules
(
filters
:
string
[]):
void
{
this
.
searchEvent
.
emit
(
filters
);
}
public
getModalType
():
string
{
switch
(
this
.
modalType
)
{
case
TypeModal
.
employers
:
...
...
@@ -64,12 +53,18 @@ export class FilterModalComponent implements OnInit, OnChanges {
}
}
public
closeModal
():
void
{
this
.
closeEvent
.
emit
();
/** Clear only filters in the current modal */
public
clearFilters
():
void
{
if
(
this
.
modalType
===
TypeModal
.
jobs
)
{
this
.
currentCheckedFilters
=
this
.
employerFilterChecked
;
}
else
if
(
this
.
modalType
===
TypeModal
.
employers
)
{
this
.
currentCheckedFilters
=
this
.
jobFilterChecked
;
}
this
.
fetchResults
.
emit
(
this
.
currentCheckedFilters
);
}
public
onSubmitFilters
():
void
{
this
.
checkedFilters
=
this
.
currentCheckedFilters
;
this
.
emitModules
(
this
.
currentCheckedFilters
);
this
.
fetchResults
.
emit
(
this
.
currentCheckedFilters
);
}
}
This diff is collapsed.
Click to expand it.
src/app/annuaire/search-bar/search-bar.component.html
+
3
−
1
View file @
53a5cde6
...
...
@@ -57,8 +57,10 @@
<app-filter-modal
[modalType]=
"modalTypeOpened"
[checkedFilters]=
"searchService.checkedFilterList"
[employerFilterChecked]=
"employerFilterChecked"
[jobFilterChecked]=
"jobFilterChecked"
[filtersTypes]=
"getModalCategory()"
(
searchEvent
)=
"fetchResults($event)"
(
fetchResults
)=
"fetchResults($event)"
(closeEvent)=
"closeModal()"
/>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment