Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
42
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
50024c8c
Commit
50024c8c
authored
5 years ago
by
Giuseppe Digilio
Browse files
Options
Downloads
Patches
Plain Diff
During submission retrieve collection list only at first load
parent
2ff1b88b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/submission/form/collection/submission-form-collection.component.ts
+40
-37
40 additions, 37 deletions
...n/form/collection/submission-form-collection.component.ts
with
40 additions
and
37 deletions
src/app/submission/form/collection/submission-form-collection.component.ts
+
40
−
37
View file @
50024c8c
...
...
@@ -209,43 +209,46 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
elementsPerPage
:
100
};
// @TODO replace with search/top browse endpoint
// @TODO implement community/subcommunity hierarchy
const
communities$
=
this
.
communityDataService
.
findAll
(
findOptions
).
pipe
(
find
((
communities
:
RemoteData
<
PaginatedList
<
Community
>>
)
=>
isNotEmpty
(
communities
.
payload
)),
mergeMap
((
communities
:
RemoteData
<
PaginatedList
<
Community
>>
)
=>
communities
.
payload
.
page
));
const
listCollection$
=
communities$
.
pipe
(
flatMap
((
communityData
:
Community
)
=>
{
return
this
.
collectionDataService
.
getAuthorizedCollectionByCommunity
(
communityData
.
uuid
).
pipe
(
find
((
collections
:
RemoteData
<
PaginatedList
<
Collection
>>
)
=>
!
collections
.
isResponsePending
&&
collections
.
hasSucceeded
),
mergeMap
((
collections
:
RemoteData
<
PaginatedList
<
Collection
>>
)
=>
collections
.
payload
.
page
),
filter
((
collectionData
:
Collection
)
=>
isNotEmpty
(
collectionData
)),
map
((
collectionData
:
Collection
)
=>
({
communities
:
[{
id
:
communityData
.
id
,
name
:
communityData
.
name
}],
collection
:
{
id
:
collectionData
.
id
,
name
:
collectionData
.
name
}
}))
);
}),
reduce
((
acc
:
any
,
value
:
any
)
=>
[...
acc
,
...
value
],
[]),
startWith
([])
);
const
searchTerm$
=
this
.
searchField
.
valueChanges
.
pipe
(
debounceTime
(
200
),
distinctUntilChanged
(),
startWith
(
''
)
);
this
.
searchListCollection$
=
combineLatest
(
searchTerm$
,
listCollection$
).
pipe
(
map
(([
searchTerm
,
listCollection
])
=>
{
this
.
disabled$
.
next
(
isEmpty
(
listCollection
));
if
(
isEmpty
(
searchTerm
))
{
return
listCollection
;
}
else
{
return
listCollection
.
filter
((
v
)
=>
v
.
collection
.
name
.
toLowerCase
().
indexOf
(
searchTerm
.
toLowerCase
())
>
-
1
).
slice
(
0
,
5
);
}
}));
// Retrieve collection list only when is the first change
if
(
changes
.
currentCollectionId
.
isFirstChange
())
{
// @TODO replace with search/top browse endpoint
// @TODO implement community/subcommunity hierarchy
const
communities$
=
this
.
communityDataService
.
findAll
(
findOptions
).
pipe
(
find
((
communities
:
RemoteData
<
PaginatedList
<
Community
>>
)
=>
isNotEmpty
(
communities
.
payload
)),
mergeMap
((
communities
:
RemoteData
<
PaginatedList
<
Community
>>
)
=>
communities
.
payload
.
page
));
const
listCollection$
=
communities$
.
pipe
(
flatMap
((
communityData
:
Community
)
=>
{
return
this
.
collectionDataService
.
getAuthorizedCollectionByCommunity
(
communityData
.
uuid
).
pipe
(
find
((
collections
:
RemoteData
<
PaginatedList
<
Collection
>>
)
=>
!
collections
.
isResponsePending
&&
collections
.
hasSucceeded
),
mergeMap
((
collections
:
RemoteData
<
PaginatedList
<
Collection
>>
)
=>
collections
.
payload
.
page
),
filter
((
collectionData
:
Collection
)
=>
isNotEmpty
(
collectionData
)),
map
((
collectionData
:
Collection
)
=>
({
communities
:
[{
id
:
communityData
.
id
,
name
:
communityData
.
name
}],
collection
:
{
id
:
collectionData
.
id
,
name
:
collectionData
.
name
}
}))
);
}),
reduce
((
acc
:
any
,
value
:
any
)
=>
[...
acc
,
...
value
],
[]),
startWith
([])
);
const
searchTerm$
=
this
.
searchField
.
valueChanges
.
pipe
(
debounceTime
(
200
),
distinctUntilChanged
(),
startWith
(
''
)
);
this
.
searchListCollection$
=
combineLatest
(
searchTerm$
,
listCollection$
).
pipe
(
map
(([
searchTerm
,
listCollection
])
=>
{
this
.
disabled$
.
next
(
isEmpty
(
listCollection
));
if
(
isEmpty
(
searchTerm
))
{
return
listCollection
;
}
else
{
return
listCollection
.
filter
((
v
)
=>
v
.
collection
.
name
.
toLowerCase
().
indexOf
(
searchTerm
.
toLowerCase
())
>
-
1
).
slice
(
0
,
5
);
}
}));
}
}
}
...
...
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