Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
8e3e826a
Commit
8e3e826a
authored
6 years ago
by
Kristof De Langhe
Browse files
Options
Downloads
Patches
Plain Diff
55647: FixedFilter fixed
parent
d8ce01b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/+search-page/search-service/search-configuration.service.ts
+23
-2
23 additions, 2 deletions
...earch-page/search-service/search-configuration.service.ts
src/app/shared/services/route.service.ts
+14
-14
14 additions, 14 deletions
src/app/shared/services/route.service.ts
with
37 additions
and
16 deletions
src/app/+search-page/search-service/search-configuration.service.ts
+
23
−
2
View file @
8e3e826a
...
...
@@ -13,6 +13,7 @@ import { Subscription } from 'rxjs/Subscription';
import
{
getSucceededRemoteData
}
from
'
../../core/shared/operators
'
;
import
{
SearchFilter
}
from
'
../search-filter.model
'
;
import
{
DSpaceObjectType
}
from
'
../../core/shared/dspace-object-type.model
'
;
import
{
SearchFixedFilterService
}
from
'
../search-filters/search-filter/search-fixed-filter.service
'
;
/**
* Service that performs all actions that have to do with the current search configuration
...
...
@@ -69,6 +70,7 @@ export class SearchConfigurationService implements OnDestroy {
* @param {ActivatedRoute} route
*/
constructor
(
private
routeService
:
RouteService
,
private
fixedFilterService
:
SearchFixedFilterService
,
private
route
:
ActivatedRoute
)
{
this
.
defaults
.
pipe
(
getSucceededRemoteData
())
...
...
@@ -166,6 +168,14 @@ export class SearchConfigurationService implements OnDestroy {
});
}
/**
* @returns {Observable<string>} Emits the current fixed filter as a string
*/
getCurrentFixedFilter
():
Observable
<
string
>
{
const
fixedFilter
:
Observable
<
string
>
=
this
.
routeService
.
getRouteParameterValue
(
'
filter
'
);
return
fixedFilter
.
flatMap
((
f
)
=>
this
.
fixedFilterService
.
getQueryByFilterName
(
f
));
}
/**
* @returns {Observable<Params>} Emits the current active filters with their values as they are displayed in the frontend URL
*/
...
...
@@ -183,7 +193,8 @@ export class SearchConfigurationService implements OnDestroy {
this
.
getScopePart
(
defaults
.
scope
),
this
.
getQueryPart
(
defaults
.
query
),
this
.
getDSOTypePart
(),
this
.
getFiltersPart
()
this
.
getFiltersPart
(),
this
.
getFixedFilterPart
()
).
subscribe
((
update
)
=>
{
const
currentValue
:
SearchOptions
=
this
.
searchOptions
.
getValue
();
const
updatedValue
:
SearchOptions
=
Object
.
assign
(
currentValue
,
update
);
...
...
@@ -203,7 +214,8 @@ export class SearchConfigurationService implements OnDestroy {
this
.
getScopePart
(
defaults
.
scope
),
this
.
getQueryPart
(
defaults
.
query
),
this
.
getDSOTypePart
(),
this
.
getFiltersPart
()
this
.
getFiltersPart
(),
this
.
getFixedFilterPart
()
).
subscribe
((
update
)
=>
{
const
currentValue
:
PaginatedSearchOptions
=
this
.
paginatedSearchOptions
.
getValue
();
const
updatedValue
:
PaginatedSearchOptions
=
Object
.
assign
(
currentValue
,
update
);
...
...
@@ -289,4 +301,13 @@ export class SearchConfigurationService implements OnDestroy {
return
{
filters
}
});
}
/**
* @returns {Observable<string>} Emits the current fixed filter as a partial SearchOptions object
*/
private
getFixedFilterPart
():
Observable
<
any
>
{
return
this
.
getCurrentFixedFilter
().
map
((
fixedFilter
)
=>
{
return
{
fixedFilter
}
});
}
}
This diff is collapsed.
Click to expand it.
src/app/shared/services/route.service.ts
+
14
−
14
View file @
8e3e826a
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs/Observable
'
;
import
{
ActivatedRoute
,
NavigationEnd
,
Params
,
Router
,
}
from
'
@angular/router
'
;
import
{
filter
}
from
'
rxjs/operators
'
;
import
{
ActivatedRoute
,
ActivationEnd
,
NavigationEnd
,
Params
,
Router
,
}
from
'
@angular/router
'
;
import
{
filter
,
flatMap
,
map
}
from
'
rxjs/operators
'
;
@
Injectable
()
export
class
RouteService
{
...
...
@@ -13,19 +13,19 @@ export class RouteService {
}
getQueryParameterValues
(
paramName
:
string
):
Observable
<
string
[]
>
{
return
this
.
route
.
queryParamMap
.
map
((
m
ap
)
=>
[...
m
ap
.
getAll
(
paramName
)]).
distinctUntilChanged
();
return
this
.
route
.
queryParamMap
.
map
((
paramM
ap
)
=>
[...
paramM
ap
.
getAll
(
paramName
)]).
distinctUntilChanged
();
}
getQueryParameterValue
(
paramName
:
string
):
Observable
<
string
>
{
return
this
.
route
.
queryParamMap
.
map
((
m
ap
)
=>
m
ap
.
get
(
paramName
)).
distinctUntilChanged
();
return
this
.
route
.
queryParamMap
.
map
((
paramM
ap
)
=>
paramM
ap
.
get
(
paramName
)).
distinctUntilChanged
();
}
hasQueryParam
(
paramName
:
string
):
Observable
<
boolean
>
{
return
this
.
route
.
queryParamMap
.
map
((
m
ap
)
=>
m
ap
.
has
(
paramName
)).
distinctUntilChanged
();
return
this
.
route
.
queryParamMap
.
map
((
paramM
ap
)
=>
paramM
ap
.
has
(
paramName
)).
distinctUntilChanged
();
}
hasQueryParamWithValue
(
paramName
:
string
,
paramValue
:
string
):
Observable
<
boolean
>
{
return
this
.
route
.
queryParamMap
.
map
((
m
ap
)
=>
m
ap
.
getAll
(
paramName
).
indexOf
(
paramValue
)
>
-
1
).
distinctUntilChanged
();
return
this
.
route
.
queryParamMap
.
map
((
paramM
ap
)
=>
paramM
ap
.
getAll
(
paramName
).
indexOf
(
paramValue
)
>
-
1
).
distinctUntilChanged
();
}
getRouteParameterValue
(
paramName
:
string
):
Observable
<
string
>
{
...
...
@@ -38,26 +38,26 @@ export class RouteService {
getQueryParamsWithPrefix
(
prefix
:
string
):
Observable
<
Params
>
{
return
this
.
route
.
queryParamMap
.
map
((
m
ap
)
=>
{
.
map
((
paramM
ap
)
=>
{
const
params
=
{};
m
ap
.
keys
paramM
ap
.
keys
.
filter
((
key
)
=>
key
.
startsWith
(
prefix
))
.
forEach
((
key
)
=>
{
params
[
key
]
=
[...
m
ap
.
getAll
(
key
)];
params
[
key
]
=
[...
paramM
ap
.
getAll
(
key
)];
});
return
params
;
}).
distinctUntilChanged
();
}
subscribeToRouterParams
()
{
this
.
router
.
events
.
pipe
(
filter
((
event
)
=>
event
instanceof
NavigationEnd
))
.
subscribe
(()
=>
{
this
.
params
=
this
.
router
.
events
.
pipe
(
flatMap
((
event
)
=>
{
let
active
=
this
.
route
;
while
(
active
.
firstChild
)
{
active
=
active
.
firstChild
;
}
this
.
params
=
active
.
params
;
});
return
active
.
params
;
})
);
}
}
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