mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
80195: Select original owningCollection on load
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<div class="card-header">{{'dso-selector.placeholder' | translate: { type: 'collection' } }}</div>
|
<div class="card-header">{{'dso-selector.placeholder' | translate: { type: 'collection' } }}</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<ds-authorized-collection-selector [types]="COLLECTIONS"
|
<ds-authorized-collection-selector [types]="COLLECTIONS"
|
||||||
[currentDSOId]="selectedCollection?.id"
|
[currentDSOId]="selectedCollection ? selectedCollection.id : originalCollection.id"
|
||||||
(onSelect)="selectDso($event)">
|
(onSelect)="selectDso($event)">
|
||||||
</ds-authorized-collection-selector>
|
</ds-authorized-collection-selector>
|
||||||
</div>
|
</div>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button (click)="moveCollection()" class="btn btn-primary" [disabled]=!canSubmit>
|
<button (click)="moveCollection()" class="btn btn-primary" [disabled]=!canMove>
|
||||||
<span *ngIf="!processing"> {{'item.edit.move.move' | translate}}</span>
|
<span *ngIf="!processing"> {{'item.edit.move.move' | translate}}</span>
|
||||||
<span *ngIf="processing"><i class='fas fa-circle-notch fa-spin'></i>
|
<span *ngIf="processing"><i class='fas fa-circle-notch fa-spin'></i>
|
||||||
{{'item.edit.move.processing' | translate}}
|
{{'item.edit.move.processing' | translate}}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, switchMap } from 'rxjs/operators';
|
||||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
@@ -7,7 +7,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import {
|
import {
|
||||||
getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData, getFirstSucceededRemoteData,
|
getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData, getFirstSucceededRemoteData, getRemoteDataPayload,
|
||||||
} from '../../../core/shared/operators';
|
} from '../../../core/shared/operators';
|
||||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
@@ -33,7 +33,8 @@ export class ItemMoveComponent implements OnInit {
|
|||||||
|
|
||||||
inheritPolicies = false;
|
inheritPolicies = false;
|
||||||
itemRD$: Observable<RemoteData<Item>>;
|
itemRD$: Observable<RemoteData<Item>>;
|
||||||
collectionSearchResults: Observable<any[]> = observableOf([]);
|
originalCollection: Collection;
|
||||||
|
|
||||||
selectedCollectionName: string;
|
selectedCollectionName: string;
|
||||||
selectedCollection: Collection;
|
selectedCollection: Collection;
|
||||||
canSubmit = false;
|
canSubmit = false;
|
||||||
@@ -57,7 +58,9 @@ export class ItemMoveComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.itemRD$ = this.route.data.pipe(map((data) => data.dso), getFirstSucceededRemoteData()) as Observable<RemoteData<Item>>;
|
this.itemRD$ = this.route.data.pipe(
|
||||||
|
map((data) => data.dso), getFirstSucceededRemoteData()
|
||||||
|
) as Observable<RemoteData<Item>>;
|
||||||
this.itemPageRoute$ = this.itemRD$.pipe(
|
this.itemPageRoute$ = this.itemRD$.pipe(
|
||||||
getAllSucceededRemoteDataPayload(),
|
getAllSucceededRemoteDataPayload(),
|
||||||
map((item) => getItemPageRoute(item))
|
map((item) => getItemPageRoute(item))
|
||||||
@@ -66,6 +69,15 @@ export class ItemMoveComponent implements OnInit {
|
|||||||
this.item = rd.payload;
|
this.item = rd.payload;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
this.itemRD$.pipe(
|
||||||
|
getFirstSucceededRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
switchMap((item) => item.owningCollection),
|
||||||
|
getFirstSucceededRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
).subscribe((collection) => {
|
||||||
|
this.originalCollection = collection;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,4 +120,8 @@ export class ItemMoveComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get canMove(): boolean {
|
||||||
|
return this.canSubmit && this.selectedCollection?.id !== this.originalCollection.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user