Skip to content

Dc field replace - #368

Open
Jason-Benson wants to merge 4 commits into
FalveyLibraryTechnology:devfrom
Jason-Benson:dcFieldReplace
Open

Dc field replace#368
Jason-Benson wants to merge 4 commits into
FalveyLibraryTechnology:devfrom
Jason-Benson:dcFieldReplace

Conversation

@Jason-Benson

Copy link
Copy Markdown
Contributor

This is an update the the bulk editor that allows you to select any DC fields from the currently selected set of records and replace any given text within them.

@Jason-Benson

Copy link
Copy Markdown
Contributor Author

Looks like this broke some tests. I'll tackle those next.

@demiankatz demiankatz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work, @Jason-Benson, this looks great. I have one small suggestion to streamline the code (see below), but other than that, it looks pretty much exactly the way I would have done it myself. :-)

I might find more things to suggest after I test it hands-on, but I'll let you fix the tests and reply to my feedback first so that I'm testing the finished product.

Also, one other minor point: I like to update the changelog in the PRs where I add new features. Might as well do that here. Since this is the first change since the last release, I would recommend just copying and pasting the whole 2.6.2 section, changing the heading to "2.7.0 - TBD" (since we'll want a minor version number due to the new feature, and the release date is not yet determined), reset all the subsections to "Nothing" except put "Added Dublin Core search-and-replace support to Bulk Editor." in the "Added" section.

Comment thread client/components/bulk/BulkEditor.tsx Outdated
Comment on lines +110 to +122
if (findString == "") {
setResults("No search string provided.");
return;
}
if (selectedRecordIds.length < 1) {
setResults("No records selected.");
return;
}
const replacements = await getFieldReplacements();
if (replacements.length < 1) {
setResults(`No matches for "${findString}" in ${dcField}.`);
return;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could reduce some redundancy by refactoring this code to a separate isReplacementFormValid(): bool function, and then both doPreviewFieldText and doReplaceFieldText can just start with:

if (!isReplacementFormValid()) {
    return;
}

Saves some lines of code and centralizes the logic so it doesn't get out of sync if we change things in future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants