64961: Return to last page on cancel, description 10 rows, renaming Other Format and Submit

This commit is contained in:
Kristof De Langhe
2019-09-19 17:00:12 +02:00
parent e76579ee00
commit 0798701019
5 changed files with 37 additions and 21 deletions

View File

@@ -94,10 +94,10 @@
"bitstream.edit.form.embargo.label": "Embargo until specific date", "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.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.fileName.label": "Filename",
"bitstream.edit.form.otherFormat.label": "Other Format", "bitstream.edit.form.newFormat.label": "Describe new 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.newFormat.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.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.hint": "If the format is not in the above list, <b>select \"format not in list\" above</b> and describe it under \"Describe new format\".",
"bitstream.edit.form.selectedFormat.label": "Selected Format", "bitstream.edit.form.selectedFormat.label": "Selected Format",
"bitstream.edit.form.selectedFormat.unknown": "Format not in list", "bitstream.edit.form.selectedFormat.unknown": "Format not in list",
"bitstream.edit.notifications.error.format.title": "An error occurred saving the bitstream's format", "bitstream.edit.notifications.error.format.title": "An error occurred saving the bitstream's format",

View File

@@ -16,7 +16,9 @@
[formGroup]="formGroup" [formGroup]="formGroup"
[formModel]="formModel" [formModel]="formModel"
[formLayout]="formLayout" [formLayout]="formLayout"
[submitLabel]="'form.save'"
(submitForm)="onSubmit()" (submitForm)="onSubmit()"
(cancel)="onCancel()"
(dfChange)="onChange($event)"></ds-form> (dfChange)="onChange($event)"></ds-form>
</div> </div>
</div> </div>

View File

@@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { Bitstream } from '../../core/shared/bitstream.model'; import { Bitstream } from '../../core/shared/bitstream.model';
import { ActivatedRoute } from '@angular/router'; 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 { combineLatest as observableCombineLatest } from 'rxjs';
import { Subscription } from 'rxjs/internal/Subscription'; import { Subscription } from 'rxjs/internal/Subscription';
import { import {
@@ -24,8 +24,10 @@ import { BitstreamFormatDataService } from '../../core/data/bitstream-format-dat
import { BitstreamFormat } from '../../core/shared/bitstream-format.model'; import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
import { BitstreamFormatSupportLevel } from '../../core/shared/bitstream-format-support-level'; import { BitstreamFormatSupportLevel } from '../../core/shared/bitstream-format-support-level';
import { RestResponse } from '../../core/cache/response.models'; 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 { Metadata } from '../../core/shared/metadata.utils';
import { Location } from '@angular/common';
import { Operation } from 'fast-json-patch';
@Component({ @Component({
selector: 'ds-edit-bitstream-page', selector: 'ds-edit-bitstream-page',
@@ -106,7 +108,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
*/ */
descriptionModel = new DynamicTextAreaModel({ descriptionModel = new DynamicTextAreaModel({
id: 'description', 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 * The Dynamic Input Model for supplying more format information
*/ */
otherFormatModel = new DynamicInputModel({ newFormatModel = new DynamicInputModel({
id: 'otherFormat', id: 'newFormat',
name: 'otherFormat' name: 'newFormat'
}); });
/** /**
* All input models in a simple array for easier iterations * 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 * The dynamic form fields used for editing the information of a bitstream
@@ -167,7 +170,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
id: 'formatContainer', id: 'formatContainer',
group: [ group: [
this.selectedFormatModel, this.selectedFormatModel,
this.otherFormatModel this.newFormatModel
] ]
}) })
]; ];
@@ -175,7 +178,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
/** /**
* The base layout of the "Other Format" input * 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 * 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' host: 'col col-sm-6 d-inline-block'
} }
}, },
otherFormat: { newFormat: {
grid: { grid: {
host: this.otherFormatBaseLayout + ' invisible' host: this.newFormatBaseLayout + ' invisible'
} }
}, },
fileNamePrimaryContainer: { fileNamePrimaryContainer: {
@@ -244,6 +247,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
sub: Subscription; sub: Subscription;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private location: Location,
private formService: DynamicFormService, private formService: DynamicFormService,
private translate: TranslateService, private translate: TranslateService,
private bitstreamService: BitstreamDataService, private bitstreamService: BitstreamDataService,
@@ -304,7 +308,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
description: bitstream.description description: bitstream.description
}, },
formatContainer: { 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( this.bitstream.format.pipe(
@@ -339,9 +343,9 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
*/ */
updateOtherFormatLayout(selectedId: string) { updateOtherFormatLayout(selectedId: string) {
if (this.isUnknownFormat(selectedId)) { if (this.isUnknownFormat(selectedId)) {
this.formLayout.otherFormat.grid.host = this.otherFormatBaseLayout; this.formLayout.newFormat.grid.host = this.newFormatBaseLayout;
} else { } 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; const primary = rawForm.fileNamePrimaryContainer.primaryBitstream;
Metadata.setFirstValue(newMetadata, 'dc.title', rawForm.fileNamePrimaryContainer.fileName); Metadata.setFirstValue(newMetadata, 'dc.title', rawForm.fileNamePrimaryContainer.fileName);
Metadata.setFirstValue(newMetadata, 'dc.description', rawForm.descriptionContainer.description); Metadata.setFirstValue(newMetadata, 'dc.description', rawForm.descriptionContainer.description);
if (isNotEmpty(rawForm.formatContainer.otherFormat)) { if (isNotEmpty(rawForm.formatContainer.newFormat)) {
Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.otherFormat); Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.newFormat);
} }
this.bitstream.metadata = newMetadata; this.bitstream.metadata = newMetadata;
} }

View File

@@ -50,9 +50,9 @@
<div class="form-group row"> <div class="form-group row">
<div class="col text-right"> <div class="col text-right">
<button type="reset" class="btn btn-default" (click)="reset()">{{'form.cancel' | translate}}</button> <button type="reset" class="btn btn-default" (click)="reset()">{{cancelLabel | translate}}</button>
<button type="submit" class="btn btn-primary" (click)="onSubmit()" <button type="submit" class="btn btn-primary" (click)="onSubmit()"
[disabled]="!(isValid() | async)">{{'form.submit' | translate}} [disabled]="!(isValid() | async)">{{submitLabel | translate}}
</button> </button>
</div> </div>
</div> </div>

View File

@@ -53,6 +53,16 @@ export class FormComponent implements OnDestroy, OnInit {
*/ */
@Input() formId: string; @Input() formId: string;
/**
* i18n key for the submit button
*/
@Input() submitLabel = 'form.submit';
/**
* i18n key for the cancel button
*/
@Input() cancelLabel = 'form.cancel';
/** /**
* An array of DynamicFormControlModel type * An array of DynamicFormControlModel type
*/ */