Repository: internetarchive/openlibrary

Issue:
Better Editor for "Alternative Names"
Many Editors have plenty of broken Alternative names like the name in lower case but otherwise identical, abbreviations wix different spaces (i.e. Edmund E. W. / Edmund E.W. / Edmund e. w.).

### Describe the problem that you'd like solved
Easier editing. Maybe like the Authors fields in Works or directly where the alternative names are now instead of the current editor. 

Finding the delimiting ; between names in the current editor is sometimes a bit difficult and is potetially risky. I often have to be very careful not to delete more than I want to. (accessibility)

### Proposal & Constraints
1. Edit button next to the Heading "Alternative Names"

<img width="715" alt="alt_names-btn" src="https://github.com/internetarchive/openlibrary/assets/2772669/ace170a7-9ca3-45c7-980e-4baec172a5b5">

2. After pushin edit the names turn into text-fields where the name can be edited or with an X deleted.

<img width="715" alt="alt_names copy" src="https://github.com/internetarchive/openlibrary/assets/2772669/121a1f96-9f99-4ccd-8b6f-4347e37d4970">


### Additional context
Maybe there should be also a page with short description how names should be written. It should be linked at that place. (which abbreviations are wanted, which are not, Pseudonyms like _Allen White (pseud.)_ or just _Allen White_? Is Lastname, Firstname necessary not (because search engine)?



Discussion:
#7846 is related to this.

In addition to helping the editor not have to find semicolons (;), some other things which would be useful include:
* flagging / deleting alternative names which are duplicates of the primary name
* flagging / deleting duplicate alternative names
* consolidating / normalizing trivial name variations (J. W Smith, J.W. Smith, J W Smith all become J. W. Smith with duplicates eliminated)
* flagging invalid words which should be deleted (translated by, translator, editor, ed., compiler, comp., from old, from old catalog, from old cat, etc)


The new authors editor in the works page looks pretty good. Maybe this could be repurposed for the alt-name-editor too. This one should not have the sort funktion like the author list and all including the first one would need a remove butten. Besides that it could work similar to the editor for authors. And the same thing could be used for editing subject as well. 

BTW: the improved author edit function made thigs much better. Used it for a while now and its great.
@cdrini I've been putting some time into testing some solutions for this. The current alternate names editor really needs to go and I figure that it can be updated to mimic the author edit on a work like @bitnapper suggested. I would be happy to pick up this issue to implement that at the very least.

As far as inline editing of the names, probably going to be too much effort and would be completely new functionality as far as I can tell. I did come up with a simpler, but more basic solution pictured here: 
![image](https://github.com/internetarchive/openlibrary/assets/29631356/d25b2833-3d51-4fa6-8dfd-86dd43637c1d)
The edit link simply redirects to http://localhost:8080/authors/OL20585A/Edwin_Abbott_Abbott/edit#alternate_names. This could maybe be added to the other 2 sections as well, but just updating the alternate names editor might be enough. Let me know what you think.

I'm also interested in #7846 that @tfmorris mentioned. If we get a good solution for this I could adapt the new alternate names editor to include a swap feature later on.
Spoke with @sbwhitt on call ; having this textarea delimit by newlines seems like the best approach. That'll avoid having a heavy UI which will make bulk operations potentially more difficult for librarians, and add a decent amount of code for us to maintain.

Resolving patch:
diff --git a/openlibrary/plugins/upstream/addbook.py b/openlibrary/plugins/upstream/addbook.py
--- a/openlibrary/plugins/upstream/addbook.py
+++ b/openlibrary/plugins/upstream/addbook.py
@@ -1010,9 +1010,7 @@ def process_input(self, i):
             author = trim_doc(i.author)
             alternate_names = author.get('alternate_names', None) or ''
             author.alternate_names = [
-                name.strip()
-                for name in alternate_names.replace("\n", ";").split(';')
-                if name.strip()
+                name.strip() for name in alternate_names.split('\n') if name.strip()
             ]
             author.links = author.get('links') or []
             return author


Test patch: