Skip to content

Commit

Permalink
UIIN-3100 View Instance detail record: When user hits Export instance…
Browse files Browse the repository at this point in the history
… (MARC) action display toast notification that informs the user where to go to get the MARC record
  • Loading branch information
vashjs committed Nov 17, 2024
1 parent 317969f commit 51528e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/ViewInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,28 @@ class ViewInstance extends React.Component {
this.setState({ instancesQuickExportInProgress: true });

try {
const generator = new IdReportGenerator('QuickInstanceExport');
const instanceIds = [match.params.id];

await this.props.mutator.quickExport.POST({
const result = await this.props.mutator.quickExport.POST({
uuids: instanceIds,
type: 'uuid',
recordType: INSTANCE_RECORD_TYPE
});
new IdReportGenerator('QuickInstanceExport').toCSV(instanceIds);

const csvFileName = generator.getCSVFileName();
const marcFileName = generator.getMARCFileName(result?.jobExecutionHrId);

generator.toCSV(instanceIds);

this.calloutRef.current.sendCallout({
timeout: 0,
type: 'success',
message: <FormattedMessage
id="ui-inventory.exportInstancesInMARC.complete"
values={{ csvFileName, marcFileName }}
/>,
});
} catch (error) {
this.calloutRef.current.sendCallout({
type: 'error',
Expand Down
10 changes: 9 additions & 1 deletion src/reports/IdReportGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ class IdReportGenerator {
return records.map(record => ({ id: recordFinder(record) }));
}

getCSVFileName() {
return `${this.fileNamePrefix}${moment().format()}`;
}

getMARCFileName(jobHRID) {
return `quick-export-${jobHRID}`;
}

toCSV(records, recordFinder) {
const parsedRecords = this.parse(records, recordFinder);
const fileTitle = {
header: false,
filename: `${this.fileNamePrefix}${moment().format()}`,
filename: this.getCSVFileName(),
};
const generateReport = !isTestEnv() ? exportCsv : noop;

Expand Down
1 change: 1 addition & 0 deletions translations/ui-inventory/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@
"saveHoldingsUIIDS.error": "Error occurred while saving holdings UUIDs. Please try again.",
"saveInstancesCQLQuery": "Save instances CQL query",
"exportInstancesInMARC": "Export instances (MARC)",
"exportInstancesInMARC.complete": "The export is complete. The downloaded {csvFileName}.csv contains selected record's UIID. To retrieve the {marcFileName}.mrc file, please go to the Data export app.",
"exportInstanceInMARC": "Export instance (MARC)",
"setRecordForDeletion": "Set record for deletion",
"setForDeletion.toast.successful": "<b>{instanceTitle}</b> has been set for deletion",
Expand Down

0 comments on commit 51528e2

Please sign in to comment.