diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index 62b0c4841c..6b093e5d98 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -94,10 +94,10 @@ "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, \"ACMESoft SuperApp version 1.5\").", + "bitstream.edit.form.newFormat.label": "Describe new format", + "bitstream.edit.form.newFormat.hint": "The application you used to create the file, and the version number (for example, \"ACMESoft SuperApp version 1.5\").", "bitstream.edit.form.primaryBitstream.label": "Primary bitstream", - "bitstream.edit.form.selectedFormat.hint": "If the format is not in the above list, select \"format not in list\" above and describe it under \"Other Format\".", + "bitstream.edit.form.selectedFormat.hint": "If the format is not in the above list, select \"format not in list\" above and describe it under \"Describe new format\".", "bitstream.edit.form.selectedFormat.label": "Selected Format", "bitstream.edit.form.selectedFormat.unknown": "Format not in list", "bitstream.edit.notifications.error.format.title": "An error occurred saving the bitstream's format", diff --git a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html index bf37f2bc1c..f3f8d72724 100644 --- a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html +++ b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html @@ -16,7 +16,9 @@ [formGroup]="formGroup" [formModel]="formModel" [formLayout]="formLayout" + [submitLabel]="'form.save'" (submitForm)="onSubmit()" + (cancel)="onCancel()" (dfChange)="onChange($event)"> diff --git a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts index 264747b339..cdff729385 100644 --- a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts +++ b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts @@ -1,7 +1,7 @@ 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'; +import { map, switchMap, take, tap } from 'rxjs/operators'; import { combineLatest as observableCombineLatest } from 'rxjs'; import { Subscription } from 'rxjs/internal/Subscription'; import { @@ -24,8 +24,10 @@ import { BitstreamFormatDataService } from '../../core/data/bitstream-format-dat import { BitstreamFormat } from '../../core/shared/bitstream-format.model'; import { BitstreamFormatSupportLevel } from '../../core/shared/bitstream-format-support-level'; import { RestResponse } from '../../core/cache/response.models'; -import { hasValue, isNotEmpty } from '../../shared/empty.util'; +import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util'; import { Metadata } from '../../core/shared/metadata.utils'; +import { Location } from '@angular/common'; +import { Operation } from 'fast-json-patch'; @Component({ selector: 'ds-edit-bitstream-page', @@ -106,7 +108,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { */ descriptionModel = new DynamicTextAreaModel({ id: 'description', - name: 'description' + name: 'description', + rows: 10 }); /** @@ -129,15 +132,15 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { /** * The Dynamic Input Model for supplying more format information */ - otherFormatModel = new DynamicInputModel({ - id: 'otherFormat', - name: 'otherFormat' + newFormatModel = new DynamicInputModel({ + id: 'newFormat', + name: 'newFormat' }); /** * All input models in a simple array for easier iterations */ - inputModels = [this.fileNameModel, this.primaryBitstreamModel, this.descriptionModel, this.embargoModel, this.selectedFormatModel, this.otherFormatModel]; + inputModels = [this.fileNameModel, this.primaryBitstreamModel, this.descriptionModel, this.embargoModel, this.selectedFormatModel, this.newFormatModel]; /** * The dynamic form fields used for editing the information of a bitstream @@ -167,7 +170,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { id: 'formatContainer', group: [ this.selectedFormatModel, - this.otherFormatModel + this.newFormatModel ] }) ]; @@ -175,7 +178,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { /** * The base layout of the "Other Format" input */ - otherFormatBaseLayout = 'col col-sm-6 d-inline-block'; + newFormatBaseLayout = 'col col-sm-6 d-inline-block'; /** * Layout used for structuring the form inputs @@ -206,9 +209,9 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { host: 'col col-sm-6 d-inline-block' } }, - otherFormat: { + newFormat: { grid: { - host: this.otherFormatBaseLayout + ' invisible' + host: this.newFormatBaseLayout + ' invisible' } }, fileNamePrimaryContainer: { @@ -244,6 +247,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { sub: Subscription; constructor(private route: ActivatedRoute, + private location: Location, private formService: DynamicFormService, private translate: TranslateService, private bitstreamService: BitstreamDataService, @@ -304,7 +308,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { description: bitstream.description }, formatContainer: { - otherFormat: hasValue(bitstream.firstMetadata('dc.format')) ? bitstream.firstMetadata('dc.format').value : undefined + newFormat: hasValue(bitstream.firstMetadata('dc.format')) ? bitstream.firstMetadata('dc.format').value : undefined } }); this.bitstream.format.pipe( @@ -339,9 +343,9 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { */ updateOtherFormatLayout(selectedId: string) { if (this.isUnknownFormat(selectedId)) { - this.formLayout.otherFormat.grid.host = this.otherFormatBaseLayout; + this.formLayout.newFormat.grid.host = this.newFormatBaseLayout; } else { - this.formLayout.otherFormat.grid.host = this.otherFormatBaseLayout + ' invisible'; + this.formLayout.newFormat.grid.host = this.newFormatBaseLayout + ' invisible'; } } @@ -450,8 +454,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { const primary = rawForm.fileNamePrimaryContainer.primaryBitstream; Metadata.setFirstValue(newMetadata, 'dc.title', rawForm.fileNamePrimaryContainer.fileName); Metadata.setFirstValue(newMetadata, 'dc.description', rawForm.descriptionContainer.description); - if (isNotEmpty(rawForm.formatContainer.otherFormat)) { - Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.otherFormat); + if (isNotEmpty(rawForm.formatContainer.newFormat)) { + Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.newFormat); } this.bitstream.metadata = newMetadata; } diff --git a/src/app/shared/form/form.component.html b/src/app/shared/form/form.component.html index 21d4a81659..11bcdd0c4b 100644 --- a/src/app/shared/form/form.component.html +++ b/src/app/shared/form/form.component.html @@ -50,9 +50,9 @@