mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Added iiif form fields to the bitstream edit component.
This commit is contained in:
@@ -147,10 +147,34 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
name: 'newFormat'
|
||||
});
|
||||
|
||||
/**
|
||||
* The Dynamic TextArea Model for the file's description
|
||||
*/
|
||||
iiifLabelModel = new DynamicInputModel({
|
||||
id: 'iiifLabel',
|
||||
name: 'iiifLabel'
|
||||
});
|
||||
|
||||
iiifTocModel = new DynamicInputModel({
|
||||
id: 'iiifToc',
|
||||
name: 'iiifToc'
|
||||
});
|
||||
|
||||
iiifWidthModel = new DynamicInputModel({
|
||||
id: 'iiifWidth',
|
||||
name: 'iiifWidth'
|
||||
});
|
||||
|
||||
iiifHeightModel = new DynamicInputModel({
|
||||
id: 'iiifHeight',
|
||||
name: 'iiifHeight'
|
||||
});
|
||||
|
||||
/**
|
||||
* All input models in a simple array for easier iterations
|
||||
*/
|
||||
inputModels = [this.fileNameModel, this.primaryBitstreamModel, this.descriptionModel, this.selectedFormatModel, this.newFormatModel];
|
||||
inputModels = [this.fileNameModel, this.primaryBitstreamModel, this.descriptionModel, this.selectedFormatModel,
|
||||
this.newFormatModel, this.iiifLabelModel, this.iiifTocModel, this.iiifWidthModel, this.iiifHeightModel];
|
||||
|
||||
/**
|
||||
* The dynamic form fields used for editing the information of a bitstream
|
||||
@@ -176,6 +200,30 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
this.selectedFormatModel,
|
||||
this.newFormatModel
|
||||
]
|
||||
}),
|
||||
new DynamicFormGroupModel({
|
||||
id: 'iiifLabelContainer',
|
||||
group: [
|
||||
this.iiifLabelModel
|
||||
]
|
||||
}),
|
||||
new DynamicFormGroupModel({
|
||||
id: 'iiifTocContainer',
|
||||
group: [
|
||||
this.iiifTocModel
|
||||
]
|
||||
}),
|
||||
new DynamicFormGroupModel({
|
||||
id: 'iiifWidthContainer',
|
||||
group: [
|
||||
this.iiifWidthModel
|
||||
]
|
||||
}),
|
||||
new DynamicFormGroupModel({
|
||||
id: 'iiifHeightContainer',
|
||||
group: [
|
||||
this.iiifHeightModel
|
||||
]
|
||||
})
|
||||
];
|
||||
|
||||
@@ -218,6 +266,26 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
host: this.newFormatBaseLayout + ' invisible'
|
||||
}
|
||||
},
|
||||
iiifLabel: {
|
||||
grid: {
|
||||
host: 'd-none'
|
||||
}
|
||||
},
|
||||
iiifToc: {
|
||||
grid: {
|
||||
host: 'd-none'
|
||||
}
|
||||
},
|
||||
iiifWidth: {
|
||||
grid: {
|
||||
host: 'd-none'
|
||||
}
|
||||
},
|
||||
iiifHeight: {
|
||||
grid: {
|
||||
host: 'd-none'
|
||||
}
|
||||
},
|
||||
fileNamePrimaryContainer: {
|
||||
grid: {
|
||||
host: 'row position-relative'
|
||||
@@ -232,7 +300,27 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
grid: {
|
||||
host: 'row'
|
||||
}
|
||||
}
|
||||
},
|
||||
iiifLabelContainer: {
|
||||
grid: {
|
||||
host: 'row'
|
||||
}
|
||||
},
|
||||
iiifTocContainer: {
|
||||
grid: {
|
||||
host: 'row'
|
||||
}
|
||||
},
|
||||
iiifWidthContainer: {
|
||||
grid: {
|
||||
host: 'row'
|
||||
}
|
||||
},
|
||||
iiifHeightContainer: {
|
||||
grid: {
|
||||
host: 'row'
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -254,6 +342,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
entityType: string;
|
||||
|
||||
isIIIF: boolean;
|
||||
|
||||
/**
|
||||
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||
* @type {Array}
|
||||
@@ -303,6 +393,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
this.formats = allFormats.page;
|
||||
this.updateFormatModel();
|
||||
this.updateForm(this.bitstream);
|
||||
this.setIiifStatus(this.bitstream);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -467,6 +558,12 @@ 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 (this.isIIIF) {
|
||||
Metadata.setFirstValue(newMetadata, 'iiif.label', rawForm.iiifLabelContainer.iiifLabel);
|
||||
Metadata.setFirstValue(newMetadata, 'iiif.toc', rawForm.iiifTocContainer.iiifToc);
|
||||
Metadata.setFirstValue(newMetadata, 'iiif.image.width', rawForm.iiifWidthContainer.iiifWidth);
|
||||
Metadata.setFirstValue(newMetadata, 'iiif.image.height', rawForm.iiifHeightContainer.iiifHeight);
|
||||
}
|
||||
if (isNotEmpty(rawForm.formatContainer.newFormat)) {
|
||||
Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.newFormat);
|
||||
}
|
||||
@@ -497,6 +594,39 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the parent item is iiif-enabled, the update boolean isIIIF property and show
|
||||
* iiif fields in the form.
|
||||
* @param bitstream
|
||||
*/
|
||||
setIiifStatus(bitstream: Bitstream) {
|
||||
this.bitstream.bundle.pipe(getFirstSucceededRemoteDataPayload(),
|
||||
mergeMap((bundle: Bundle) => bundle.item.pipe(getFirstSucceededRemoteDataPayload())))
|
||||
.subscribe((item) => {
|
||||
if (item.firstMetadataValue('dspace.iiif.enabled').match('true') !== null) {
|
||||
this.isIIIF = true;
|
||||
this.formLayout.iiifLabel.grid.host = this.newFormatBaseLayout;
|
||||
this.formLayout.iiifToc.grid.host = this.newFormatBaseLayout;
|
||||
this.formLayout.iiifWidth.grid.host = this.newFormatBaseLayout;
|
||||
this.formLayout.iiifHeight.grid.host = this.newFormatBaseLayout;
|
||||
this.formGroup.patchValue({
|
||||
iiifLabelContainer: {
|
||||
iiifLabel: bitstream.firstMetadataValue('iiif.label')
|
||||
},
|
||||
iiifTocContainer: {
|
||||
iiifToc: bitstream.firstMetadataValue('iiif.toc')
|
||||
},
|
||||
iiifWidthContainer: {
|
||||
iiifWidth: bitstream.firstMetadataValue('iiif.image.width')
|
||||
},
|
||||
iiifHeightContainer: {
|
||||
iiifHeight: bitstream.firstMetadataValue('iiif.image.height')
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from open subscriptions
|
||||
*/
|
||||
|
@@ -582,6 +582,23 @@
|
||||
|
||||
"bitstream.edit.notifications.error.format.title": "An error occurred saving the bitstream's format",
|
||||
|
||||
"bitstream.edit.form.iiifLabel.label": "IIIF Label",
|
||||
|
||||
"bitstream.edit.form.iiifLabel.hint": "Canvas label for this image",
|
||||
|
||||
"bitstream.edit.form.iiifToc.label": "IIIF Table of Contents",
|
||||
|
||||
"bitstream.edit.form.iiifToc.hint": "Add label to make this image the start of a new range.",
|
||||
|
||||
"bitstream.edit.form.iiifWidth.label": "IIIF canvas width",
|
||||
|
||||
"bitstream.edit.form.iiifWidth.hint": "The canvas width should match the image width.",
|
||||
|
||||
"bitstream.edit.form.iiifHeight.label": "IIIF canvas height",
|
||||
|
||||
"bitstream.edit.form.iiifHeight.hint": "The canvas height should match the image height.",
|
||||
|
||||
|
||||
"bitstream.edit.notifications.saved.content": "Your changes to this bitstream were saved.",
|
||||
|
||||
"bitstream.edit.notifications.saved.title": "Bitstream saved",
|
||||
|
Reference in New Issue
Block a user