94961: Edit-bitstream loading message, error notifications and AoT fixes

This commit is contained in:
Kristof De Langhe
2019-09-17 15:31:54 +02:00
parent fa1b1ad886
commit a56d551ef1
8 changed files with 54 additions and 24 deletions

View File

@@ -82,22 +82,23 @@
"admin.registries.schema.title": "DSpace Angular :: Metadata Schema Registry",
"auth.errors.invalid-user": "Invalid email address or password.",
"auth.messages.expired": "Your session has expired. Please log in again.",
"bitstream.edit.title": "Edit bitstream",
"bitstream.edit.bitstream": "Bitstream: ",
"bitstream.edit.form.description.label": "Description",
"bitstream.edit.form.description.hint": "Optionally, provide a brief description of the file, for example \"<i>Main article</i>\" or \"<i>Experiment data readings</i>\".",
"bitstream.edit.form.embargo.label": "Embargo until specific date",
"bitstream.edit.form.description.label": "Description",
"bitstream.edit.form.embargo.hint": "The first day from which access is allowed. <b>This date cannot be modified on this form.</b> To set an embargo date for a bitstream, go to the <i>Item Status</i> tab, click <i>Authorizations...</i>, create or edit the bitstream's <i>READ</i> policy, and set the <i>Start Date</i> as desired.",
"bitstream.edit.form.fileName.label": "Filename",
"bitstream.edit.form.embargo.label": "Embargo until specific date",
"bitstream.edit.form.fileName.hint": "Change the filename for the bitstream. Note that this will change the display bitstream URL, but old links will still resolve as long as the sequence ID does not change.",
"bitstream.edit.form.fileName.label": "Filename",
"bitstream.edit.form.otherFormat.label": "Other Format",
"bitstream.edit.form.otherFormat.hint": "The application you used to create the file, and the version number (for example, \"<i>ACMESoft SuperApp version 1.5</i>\").",
"bitstream.edit.form.primaryBitstream.label": "Primary bitstream",
"bitstream.edit.form.selectedFormat.hint": "If the format is not in the above list, <b>select \"format not in list\" above</b> and describe it under \"Other Format\".",
"bitstream.edit.form.selectedFormat.label": "Selected Format",
"bitstream.edit.form.selectedFormat.unknown": "Format not in list",
"bitstream.edit.form.otherFormat.label": "Other Format",
"bitstream.edit.form.otherFormat.hint": "The application you used to create the file, and the version number (for example, \"<i>ACMESoft SuperApp version 1.5</i>\").",
"bitstream.edit.notifications.error.format.title": "An error occurred saving the bitstream's format",
"bitstream.edit.notifications.saved.content": "Your changes to this bitstream were saved.",
"bitstream.edit.notifications.saved.title": "Bitstream saved",
"bitstream.edit.title": "Edit bitstream",
"browse.comcol.by.author": "By Author",
"browse.comcol.by.dateissued": "By Issue Date",
"browse.comcol.by.subject": "By Subject",
@@ -391,6 +392,7 @@
"journalvolume.page.issuedate": "Issue Date",
"journalvolume.page.titleprefix": "Journal Volume: ",
"journalvolume.page.volume": "Volume",
"loading.bitstream": "Loading bitstream...",
"loading.browse-by": "Loading items...",
"loading.browse-by-page": "Loading page...",
"loading.collection": "Loading collection...",

View File

@@ -1,5 +1,5 @@
<div class="container">
<div class="row">
<div class="row" *ngIf="bitstream">
<div class="col-md-2">
<ds-thumbnail [thumbnail]="bitstream"></ds-thumbnail>
</div>
@@ -20,4 +20,5 @@
(dfChange)="onChange($event)"></ds-form>
</div>
</div>
<ds-loading *ngIf="!bitstream" message="{{'loading.bitstream' | translate}}"></ds-loading>
</div>

View File

@@ -8,7 +8,7 @@ import { ActivatedRoute } from '@angular/router';
import { DynamicFormControlModel, DynamicFormService } from '@ng-dynamic-forms/core';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core';
import { BitstreamFormatDataService } from '../../core/data/bitstream-format-data.service';
import { Bitstream } from '../../core/shared/bitstream.model';
import { NotificationType } from '../../shared/notifications/models/notification-type';
@@ -111,7 +111,8 @@ describe('EditBitstreamPageComponent', () => {
{ provide: DynamicFormService, useValue: formService },
{ provide: ActivatedRoute, useValue: { data: observableOf({ bitstream: new RemoteData(false, false, true, null, bitstream) }) } },
{ provide: BitstreamDataService, useValue: bitstreamService },
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService }
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
ChangeDetectorRef
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();

View File

@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { Bitstream } from '../../core/shared/bitstream.model';
import { ActivatedRoute } from '@angular/router';
import { map, take, tap } from 'rxjs/operators';
@@ -248,7 +248,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
private translate: TranslateService,
private bitstreamService: BitstreamDataService,
private notificationsService: NotificationsService,
private bitstreamFormatService: BitstreamFormatDataService) {
private bitstreamFormatService: BitstreamFormatDataService,
private changeDetectorRef: ChangeDetectorRef) {
}
/**
@@ -278,6 +279,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
this.formats = allFormats.page;
this.updateFormatModel();
this.updateForm(this.bitstream);
this.changeDetectorRef.detectChanges();
});
this.updateFieldTranslations();
@@ -285,6 +287,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
.subscribe(() => {
this.updateFieldTranslations();
});
this.changeDetectorRef.detectChanges();
}
/**
@@ -429,6 +432,12 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
this.translate.instant(this.NOTIFICATIONS_PREFIX + 'saved.title'),
this.translate.instant(this.NOTIFICATIONS_PREFIX + 'saved.content')
);
if (hasValue(formatResponse) && !formatResponse.isSuccessful) {
this.notificationsService.error(
this.translate.instant(this.NOTIFICATIONS_PREFIX + 'error.format.title'),
formatResponse.statusText
);
}
}
/**

View File

@@ -1,4 +1,4 @@
import { Inject, Injectable, OnInit } from '@angular/core';
import { Component, Inject, Injectable, OnInit } from '@angular/core';
import { FieldUpdate, FieldUpdates } from '../../../core/data/object-updates/object-updates.reducer';
import { Observable } from 'rxjs/internal/Observable';
import { Item } from '../../../core/shared/item.model';
@@ -12,11 +12,14 @@ import { first, map } from 'rxjs/operators';
import { RemoteData } from '../../../core/data/remote-data';
import { AbstractTrackableComponent } from '../../../shared/trackable/abstract-trackable.component';
@Injectable()
@Component({
selector: 'ds-abstract-item-update',
template: ''
})
/**
* Abstract component for managing object updates of an item
*/
export abstract class AbstractItemUpdateComponent extends AbstractTrackableComponent implements OnInit {
export class AbstractItemUpdateComponent extends AbstractTrackableComponent implements OnInit {
/**
* The item to display the edit page for
*/
@@ -70,18 +73,35 @@ export abstract class AbstractItemUpdateComponent extends AbstractTrackableCompo
/**
* Initialize the values and updates of the current item's fields
* Abstract method: Should be overwritten in the sub class
*/
abstract initializeUpdates(): void;
initializeUpdates(): void {
// Overwrite in subclasses
}
/**
* Initialize the prefix for notification messages
* Abstract method: Should be overwritten in the sub class
*/
abstract initializeNotificationsPrefix(): void;
initializeNotificationsPrefix(): void {
// Overwrite in subclasses
}
/**
* Sends all initial values of this item to the object updates service
* Abstract method: Should be overwritten in the sub class
*/
abstract initializeOriginalFields(): void;
initializeOriginalFields(): void {
// Overwrite in subclasses
}
/**
* Submit the current changes
* Abstract method: Should be overwritten in the sub class
*/
submit(): void {
// Overwrite in subclasses
}
/**
* Prevent unnecessary rerendering so fields don't lose focus
@@ -112,9 +132,4 @@ export abstract class AbstractItemUpdateComponent extends AbstractTrackableCompo
}
);
}
/**
* Submit the current changes
*/
abstract submit(): void;
}

View File

@@ -19,6 +19,7 @@ import { ItemEditBitstreamComponent } from './item-bitstreams/item-edit-bitstrea
import { ItemRelationshipsComponent } from './item-relationships/item-relationships.component';
import { EditRelationshipComponent } from './item-relationships/edit-relationship/edit-relationship.component';
import { EditRelationshipListComponent } from './item-relationships/edit-relationship-list/edit-relationship-list.component';
import { AbstractItemUpdateComponent } from './abstract-item-update/abstract-item-update.component';
/**
* Module that contains all components related to the Edit Item page administrator functionality
@@ -33,6 +34,7 @@ import { EditRelationshipListComponent } from './item-relationships/edit-relatio
EditItemPageComponent,
ItemOperationComponent,
AbstractSimpleItemActionComponent,
AbstractItemUpdateComponent,
ModifyItemOverviewComponent,
ItemWithdrawComponent,
ItemReinstateComponent,

View File

@@ -50,7 +50,7 @@ const url = 'thisUrl';
let item: Item;
let itemService: ItemDataService;
let objectUpdatesService: ObjectUpdatesService;
let router: Router;
let router: any;
let route: ActivatedRoute;
let notificationsService: NotificationsService;
let bitstreamService: BitstreamDataService;

View File

@@ -18,7 +18,7 @@ import { DSpaceObject } from '../shared/dspace-object.model';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { ApplyPatchObjectCacheAction } from './object-cache.actions';
fdescribe('ServerSyncBufferEffects', () => {
describe('ServerSyncBufferEffects', () => {
let ssbEffects: ServerSyncBufferEffects;
let actions: Observable<any>;
const testConfig = {