Dc field replace - #368
Conversation
|
Looks like this broke some tests. I'll tackle those next. |
demiankatz
left a comment
There was a problem hiding this comment.
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.
| 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; | ||
| } |
There was a problem hiding this comment.
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!
…level pid, replace whole dc field
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.