jonaswinkler / paperless-ng

A supercharged version of paperless: scan, index and archive all your physical documents
https://paperless-ng.readthedocs.io/en/latest/
GNU General Public License v3.0
5.37k stars 356 forks source link

Support bulk editing #60

Closed fdw closed 3 years ago

fdw commented 3 years ago

I haven't found a way to edit several documents at once (f.e. adding a document type or a tag to all of them). This would be very helpful, especially after importing or migrating a large number of documents.

jonaswinkler commented 3 years ago

I want this and I'm drafting the UI right now. I'm thinking about a Bulk-Edit dropdown button with all the operations listed, and popups for additional information / delete confirmations.

Bulk operations I can think of right now.

I'll also need API support for this.

jayme-github commented 3 years ago

I want this and I'm drafting the UI right now. I'm thinking about a Bulk-Edit dropdown button with all the operations listed, and popups for additional information / delete confirmations.

Bulk operations I can think of right now.

* Add/Remove Tags, Correspondents, Types

What I did use a lot (had that patched into paperless) was a bulk action "Remove INBOX tag" .

fdw commented 3 years ago

I'm thinking about a Bulk-Edit dropdown button with all the operations listed, and popups for additional information / delete confirmations.

That sounds very good to me. Only thing that might be obvious to you, but not to me, is that I'd add some way to select the affected documents (for example, checkboxes).

Bulk operations I can think of right now.

  • Add/Remove Tags, Correspondents, Types
  • Delete
  • Re-assign metadata by matching rules
  • Redo OCR (this will come in handy later, when OCRmyPDF is in the dev branch). This will allow users to embed OCR'ed text into existing documents directly from the front end instead of executing some management command.

That should at the least cover the basics. I can't think of anything else yet, anyway ;)

I'll also need API support for this.

That's the thing I'm curious about as well. The trivial way would be to have one PATCH call per document, but I think bulk might be nicer. Would be a non-standard use of PATCH though, if it contains not just the changes, but also the targets. Do you have an idea already?

jonaswinkler commented 3 years ago

I'm thinking about a Bulk-Edit dropdown button with all the operations listed, and popups for additional information / delete confirmations.

That sounds very good to me. Only thing that might be obvious to you, but not to me, is that I'd add some way to select the affected documents (for example, checkboxes).

Something like this.

image

Checkboxes, of course. I'd show them in the top left corner of the preview image and have them visible only on hover / when checked to keep the list clean.

Edit: I think slightly altering the color of selected items would be super nice.

Bulk operations I can think of right now.

  • Add/Remove Tags, Correspondents, Types
  • Delete
  • Re-assign metadata by matching rules
  • Redo OCR (this will come in handy later, when OCRmyPDF is in the dev branch). This will allow users to embed OCR'ed text into existing documents directly from the front end instead of executing some management command.

That should at the least cover the basics. I can't think of anything else yet, anyway ;)

I'll also need API support for this.

That's the thing I'm curious about as well. The trivial way would be to have one PATCH call per document, but I think bulk might be nicer. Would be a non-standard use of PATCH though, if it contains not just the changes, but also the targets. Do you have an idea already?

Some operations aren't simple PATCH calls, since they'd fire some process in the back end instead of assigning new model properties, so I'm thinking about a new end point /api/documents/bulkedit/ that accepts POST requests. Each request would specify a set of document id's, a task, and optional parameters. The easy tasks will block, longer tasks will use the task queue.

jonaswinkler commented 3 years ago

This is now mostly working as pictured above. The only thing left to figure out is how to display check boxes on the small and large cards.

jonaswinkler commented 3 years ago

Oh, and I need to write some test cases.

shamoon commented 3 years ago

How’s this going UI-wise? Can I help? πŸ™‚

jonaswinkler commented 3 years ago

Check out the feature-bulk-edit branch.

Pretty much the only thing left to do is the check boxes on the cards. No check boxes on the search results though (also uses large cards).

I've done that on the small cards already, but I'm not entirely happy.

I'd be happy for some help.

shamoon commented 3 years ago

With that second thing in mind, here's what I was thinking (see gif attached). This UI slides out once an item(s) is selected and allows for more quickly doing things than the dropdown. In playing with it works pretty goodβ€”let me know what you think!

ezgif-2-4880df4e5b14

jonaswinkler commented 3 years ago

Here are my thoughts:

shamoon commented 3 years ago

Of course, youre the boss! I will say:

Anyway, again of course your call

totti4ever commented 3 years ago

Hey, I am really excited what you guys are performing here I have to say!

Reading this discussion, I'd just like to add my view in case it's of interest: I actually see your points, Jonas. But I am on Michael's side when it comes to the frequency of use, as especially new users will need them a lot to structure their documents. And also once that has been done, in the second you add another category or so, the bulk mode heavily helps again! This means, I like the instant availability

keep up this great effort, thanks a lot!

shamoon commented 3 years ago

Yea I know people have their own workflows. Attached is a screenshot of a smaller version (that's still pretty usable IMHO) if that makes any difference.

Screen Shot 2020-12-15 at 10 49 52 AM
jonaswinkler commented 3 years ago

Is this working? Can I try that somewhere?

shamoon commented 3 years ago

Yes there’s a branch on my fork: https://github.com/shamoon/paperless-ng/tree/feature-bulk-editor (I don’t have a backend setup with the API version that includes bulk editing but the new UI component uses the same logic as your menu did so should be fine)

jonaswinkler commented 3 years ago

Alright, I see where this is useful now. Much of the editing work is just setting types tags and correspondents and that's where all the use of this feature will come from. I can see how having quick access to that will be useful.

I'm just not entirely sold on the layout yet. It's somewhat annoying on the list view when you try to select multiple items, the check boxes always move after selecting the first. Just had a look at how github does it. They replace much of the filter options with mass manipulation menus. Could we do the same?

What do you think?

shamoon commented 3 years ago

Thats an interesting approach, I think it could work. In an effort to coordinate πŸ˜ƒ how about I take a crack at it and let you know how it goes?

jonaswinkler commented 3 years ago

Sure thing!

The idea behind that is that filtering does not work all that well together with mass editing anyway. Filtering removes the selection from filtered items. Don't want to modify invisible items. Therefore, I don't see any immediate concerns with disabling the filters when the user starts to select things.

If that works out usability wise, I'd probably move the bulk edit functions into the filter editor as well, hook that up with the document list service to get the current selection, and maybe rename that component to something that describes the combined functionality better.

I've also considered disabling the confirmation dialogs when only very few items are selected (< 5, or something, except for delete, of course). It would be ideal if we could use the same drop downs for selecting correspondents / types / tags that we also use for filtering. That way, we need to (select) -> (click the drop down) -> (click the thing) -> (optionally confirm for large selections) and that's it.

These are just some ideas that just came to mind.

shamoon commented 3 years ago

I'll have a think. I will keep it DRY by reusing the smaller components (and making them common) but I was thinking to just use a separate component, a BulkEditor vs FitlerEditor, I think it will end up cleaner.

jonaswinkler commented 3 years ago

Actually, yes.

You might want to pull dev before making too many changes, some changes to the large cards.

FitlerEditor, again. :)

shamoon commented 3 years ago

Phew, yea I did 1h ago but Im moving things around so hopefully no more big changes until I have something to show you...

jonaswinkler commented 3 years ago

Seems I forgot to merge that into the feature-bulk-edit branch, which would have been important. Anyway, I'll leave it as it is.

shamoon commented 3 years ago

My branch is based off that one so should be OK.

So Im pretty happy with how this is working, needs more testing but should be close. A couple things wanted to discuss:

Let me know about tags and hopefully will have something to look at soon!

jonaswinkler commented 3 years ago

I can't quite follow.

  • I implemented a mechanism where once documents are selected the menu items either get a βœ“ if every item in the list or – if only some do.

Which menu?

Do you mean:

Or

Or did you take that into consideration?

Regarding multiple tags: I can add that to the backend.

shamoon commented 3 years ago

Sorry my bad, its hard to explain without a photo or something. The βœ“/– just refers to the selected documents. Please see the short video below to illustrate (essentially works the same for correspondents / doc types just not multiple).

bulk-edit-d91fa99

jonaswinkler commented 3 years ago

Looks pretty good! I have two concerns.

shamoon commented 3 years ago

Cool 😎

Regarding the paging issue I think the most obvious solution is to make it that when there are items selected on a different page we just hide all – / βœ“ and it becomes "βœ“ something to apply". Only other way I can think of would be to build something additional into DocumentListViewService (probably would need to come from the API) that when given a set of selected documents returns the used tags and a count of documents within the set with that tag i.e. [{tag: "Inbox", count: 275}, {tag: "Auto", count: 121}], that would be enough to do – / βœ“. But not sure if that would work performance-wise?

Im on the fence about the action on closing. At first I thought was weird but I actually think it works, especially because of the confirm dialog. It wouldn't make sense to do on clicking each item because for tags you want to wait until the user is done checking / un-checking things. Alternatives I can see would be:

  1. Add a little "Apply" button at the bottom of the dropdown. In this case I would still vote we leave it to apply on close as well.
  2. We could have one big "Apply" button in the toolbar. BTW, GitHub labels work like no. 1 without the confirmation dialog but I didn't like that because I really didn't even know it was going to do something. I think at the moment I prefer 1.
shamoon commented 3 years ago

Ok! I'm pretty happy with this. In practice I think just 'turning off' the – / βœ“ when "All" is chosen is a good solution. I added:

Only remaining question is about the UI for applying changes, let me know your thoughts. Or I can just create a PR and you can test it out and see how you feel?

Screen Shot 2020-12-20 at 12 50 07 AM Screen Shot 2020-12-20 at 12 49 01 AM
jonaswinkler commented 3 years ago

Please make a PR.