80195: Replace input suggestions with collection selector

This commit is contained in:
Yura Bondarenko
2021-06-23 11:05:14 +02:00
parent ddb7d5181f
commit b2c002057e
2 changed files with 13 additions and 30 deletions

View File

@@ -5,19 +5,16 @@
<p>{{'item.edit.move.description' | translate}}</p> <p>{{'item.edit.move.description' | translate}}</p>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<ds-dso-input-suggestions #f id="search-form" <div class="card mb-3">
[suggestions]="(collectionSearchResults | async)" <div class="card-header">{{'dso-selector.placeholder' | translate: { type: 'collection' } }}</div>
[placeholder]="'item.edit.move.search.placeholder'| translate" <div class="card-body">
[action]="getCurrentUrl()" <ds-authorized-collection-selector [types]="COLLECTIONS"
[name]="'item-move'" [currentDSOId]="selectedCollection?.id"
[(ngModel)]="selectedCollectionName" (onSelect)="selectDso($event)">
(clickSuggestion)="onClick($event)" </ds-authorized-collection-selector>
(typeSuggestion)="resetCollection($event)" </div>
(findSuggestions)="findSuggestions($event)" <div></div>
(click)="f.open()" </div>
ngDefaultControl>
</ds-dso-input-suggestions>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@@ -53,6 +53,8 @@ export class ItemMoveComponent implements OnInit {
*/ */
itemPageRoute$: Observable<string>; itemPageRoute$: Observable<string>;
COLLECTIONS = [DSpaceObjectType.COLLECTION];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
@@ -75,14 +77,6 @@ export class ItemMoveComponent implements OnInit {
this.loadSuggestions(''); this.loadSuggestions('');
} }
/**
* Find suggestions based on entered query
* @param query - Search query
*/
findSuggestions(query): void {
this.loadSuggestions(query);
}
/** /**
* Load all available collections to move the item to. * Load all available collections to move the item to.
* TODO: When the API support it, only fetch collections where user has ADD rights to. * TODO: When the API support it, only fetch collections where user has ADD rights to.
@@ -107,7 +101,7 @@ export class ItemMoveComponent implements OnInit {
* Set the collection name and id based on the selected value * Set the collection name and id based on the selected value
* @param data - obtained from the ds-input-suggestions component * @param data - obtained from the ds-input-suggestions component
*/ */
onClick(data: any): void { selectDso(data: any): void {
this.selectedCollection = data; this.selectedCollection = data;
this.selectedCollectionName = data.name; this.selectedCollectionName = data.name;
this.canSubmit = true; this.canSubmit = true;
@@ -137,12 +131,4 @@ export class ItemMoveComponent implements OnInit {
} }
); );
} }
/**
* Resets the can submit when the user changes the content of the input field
* @param data
*/
resetCollection(data: any) {
this.canSubmit = false;
}
} }