mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
64503: Feedback 2019-10-24 ; loading, message fix, notification clearing
This commit is contained in:
@@ -159,7 +159,7 @@
|
||||
"collection.edit.tabs.roles.head": "Assign Roles",
|
||||
"collection.edit.tabs.roles.title": "Collection Edit - Roles",
|
||||
"collection.edit.tabs.source.external": "This collection harvests its content from an external source",
|
||||
"collection.edit.tabs.source.form.errors.provider.required": "You must provide a set id of the target collection.",
|
||||
"collection.edit.tabs.source.form.errors.oaiSource.required": "You must provide a set id of the target collection.",
|
||||
"collection.edit.tabs.source.form.harvestType": "Content being harvested",
|
||||
"collection.edit.tabs.source.form.head": "Configure an external source",
|
||||
"collection.edit.tabs.source.form.metadataConfigId": "Metadata Format",
|
||||
@@ -478,6 +478,7 @@
|
||||
"loading.browse-by-page": "Loading page...",
|
||||
"loading.collection": "Loading collection...",
|
||||
"loading.collections": "Loading collections...",
|
||||
"loading.content-source": "Loading content source...",
|
||||
"loading.community": "Loading community...",
|
||||
"loading.default": "Loading...",
|
||||
"loading.item": "Loading item...",
|
||||
|
@@ -18,11 +18,12 @@
|
||||
</button>
|
||||
</div>
|
||||
<h4>{{ 'collection.edit.tabs.source.head' | translate }}</h4>
|
||||
<div class="form-check mb-4">
|
||||
<div *ngIf="contentSource" class="form-check mb-4">
|
||||
<input type="checkbox" class="form-check-input" id="externalSourceCheck" [checked]="(contentSource?.harvestType !== harvestTypeNone)" (change)="changeExternalSource()">
|
||||
<label class="form-check-label" for="externalSourceCheck">{{ 'collection.edit.tabs.source.external' | translate }}</label>
|
||||
</div>
|
||||
<h4 *ngIf="(contentSource?.harvestType !== harvestTypeNone)">{{ 'collection.edit.tabs.source.form.head' | translate }}</h4>
|
||||
<ds-loading *ngIf="!contentSource" [message]="'loading.content-source' | translate"></ds-loading>
|
||||
<h4 *ngIf="contentSource && (contentSource?.harvestType !== harvestTypeNone)">{{ 'collection.edit.tabs.source.form.head' | translate }}</h4>
|
||||
</div>
|
||||
<ds-form *ngIf="formGroup && contentSource && (contentSource?.harvestType !== harvestTypeNone)"
|
||||
[formId]="'collection-source-form-id'"
|
||||
|
@@ -30,6 +30,7 @@ import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
|
||||
import { CollectionDataService } from '../../../core/data/collection-data.service';
|
||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { MetadataConfig } from '../../../core/shared/metadata-config.model';
|
||||
import { INotification } from '../../../shared/notifications/models/notification.model';
|
||||
|
||||
/**
|
||||
* Component for managing the content source of the collection
|
||||
@@ -214,6 +215,13 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
||||
*/
|
||||
previouslySelectedHarvestType = ContentSourceHarvestType.Metadata;
|
||||
|
||||
/**
|
||||
* Notifications displayed after clicking submit
|
||||
* These are cleaned up every time a user submits the form to prevent error or other notifications from staying active
|
||||
* while they shouldn't be.
|
||||
*/
|
||||
displayedNotifications: INotification[] = [];
|
||||
|
||||
public constructor(public objectUpdatesService: ObjectUpdatesService,
|
||||
public notificationsService: NotificationsService,
|
||||
protected location: Location,
|
||||
@@ -269,7 +277,10 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
||||
this.updateSub = this.update$.subscribe((update: FieldUpdate) => {
|
||||
if (update) {
|
||||
const field = update.field as ContentSource;
|
||||
const defaultConfigId = this.contentSource.metadataConfigs[0].id;
|
||||
let defaultConfigId;
|
||||
if (hasValue(this.contentSource) && isNotEmpty(this.contentSource.metadataConfigs)) {
|
||||
defaultConfigId = this.contentSource.metadataConfigs[0].id;
|
||||
}
|
||||
this.formGroup.patchValue({
|
||||
oaiSourceContainer: {
|
||||
oaiSource: field.oaiSource
|
||||
@@ -355,9 +366,14 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
||||
map((col) => col.payload.uuid),
|
||||
switchMap((uuid) => this.collectionService.updateContentSource(uuid, this.contentSource)),
|
||||
take(1)
|
||||
).subscribe((contentSource: ContentSource) => {
|
||||
this.initializeOriginalContentSource(contentSource);
|
||||
this.notificationsService.success(this.getNotificationTitle('saved'), this.getNotificationContent('saved'));
|
||||
).subscribe((result: ContentSource | INotification) => {
|
||||
if (hasValue((result as any).harvestType)) {
|
||||
this.clearNotifications();
|
||||
this.initializeOriginalContentSource(result as ContentSource);
|
||||
this.displayedNotifications.push(this.notificationsService.success(this.getNotificationTitle('saved'), this.getNotificationContent('saved')));
|
||||
} else {
|
||||
this.displayedNotifications.push(result as INotification);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -419,6 +435,16 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
||||
this.objectUpdatesService.saveAddFieldUpdate(this.url, cloneDeep(this.contentSource));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear possible active notifications
|
||||
*/
|
||||
clearNotifications() {
|
||||
this.displayedNotifications.forEach((notification: INotification) => {
|
||||
this.notificationsService.remove(notification);
|
||||
});
|
||||
this.displayedNotifications = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure open subscriptions are closed
|
||||
*/
|
||||
|
@@ -38,6 +38,7 @@ import { ResponseParsingService } from './parsing.service';
|
||||
import { GenericConstructor } from '../shared/generic-constructor';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { PaginatedSearchOptions } from '../../+search-page/paginated-search-options.model';
|
||||
import { INotification } from '../../shared/notifications/models/notification.model';
|
||||
|
||||
@Injectable()
|
||||
export class CollectionDataService extends ComColDataService<Collection> {
|
||||
@@ -140,7 +141,7 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
* @param collectionId
|
||||
* @param contentSource
|
||||
*/
|
||||
updateContentSource(collectionId: string, contentSource: ContentSource): Observable<ContentSource> {
|
||||
updateContentSource(collectionId: string, contentSource: ContentSource): Observable<ContentSource | INotification> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
const serializedContentSource = new DSpaceRESTv2Serializer(ContentSource).serialize(contentSource);
|
||||
const request$ = this.getHarvesterEndpoint(collectionId).pipe(
|
||||
@@ -166,9 +167,9 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
if (!response.isSuccessful) {
|
||||
if (hasValue((response as any).errorMessage)) {
|
||||
if (response.statusCode === 422) {
|
||||
this.notificationsService.error(this.translate.instant(this.errorTitle), this.translate.instant(this.contentSourceError), new NotificationOptions(-1));
|
||||
return this.notificationsService.error(this.translate.instant(this.errorTitle), this.translate.instant(this.contentSourceError), new NotificationOptions(-1));
|
||||
} else {
|
||||
this.notificationsService.error(this.translate.instant(this.errorTitle), (response as any).errorMessage, new NotificationOptions(-1));
|
||||
return this.notificationsService.error(this.translate.instant(this.errorTitle), (response as any).errorMessage, new NotificationOptions(-1));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -176,10 +177,11 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
}
|
||||
}),
|
||||
isNotEmptyOperator(),
|
||||
map((response: ContentSourceSuccessResponse) => {
|
||||
if (isNotEmpty(response.contentsource)) {
|
||||
return response.contentsource;
|
||||
map((response: ContentSourceSuccessResponse | INotification) => {
|
||||
if (isNotEmpty((response as any).contentsource)) {
|
||||
return (response as ContentSourceSuccessResponse).contentsource;
|
||||
}
|
||||
return response as INotification;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@@ -20,8 +20,8 @@ export class ContentSourceResponseParsingService implements ResponseParsingServi
|
||||
const deserialized = new DSpaceRESTv2Serializer(ContentSource).deserialize(payload);
|
||||
|
||||
let metadataConfigs = [];
|
||||
if (payload._embedded && payload._embedded.metadata_configs && payload._embedded.metadata_configs.configs) {
|
||||
metadataConfigs = new DSpaceRESTv2Serializer(MetadataConfig).serializeArray(payload._embedded.metadata_configs.configs);
|
||||
if (payload._embedded && payload._embedded.harvestermetadata && payload._embedded.harvestermetadata.configs) {
|
||||
metadataConfigs = new DSpaceRESTv2Serializer(MetadataConfig).serializeArray(payload._embedded.harvestermetadata.configs);
|
||||
}
|
||||
deserialized.metadataConfigs = metadataConfigs;
|
||||
|
||||
|
Reference in New Issue
Block a user