cozy / cozy-banks

A Banks Aggregator on Cozy
https://cozy.io
GNU Affero General Public License v3.0
59 stars 26 forks source link

feat: edit transaction label in list and modal #2702

Closed feugy closed 8 months ago

feugy commented 8 months ago

✨ What's in there?

Hi Cozy! As discussed on the forum this is an attempt to allow users editing their transaction labels.

image

After considering adding a new comments field, I've leveraged the existing manualLabel which is used in recurring transactions.

Users can now:

🧪 How to test?

Here is a possible scenario:

  1. Grab the code, locally, assuming you already have Cozy server set up and ready, with some fixtures install
  2. Connect to http://banks.cozy.localhost:8080/#/balances/details

    in the transaction list, you'll have new pen icons

  3. Click on a pen icon

    the label is replaced with a text field with the original label as value, focus, and a close button in it

  4. Change the value, and click on the close button/hit Escape key/click somewhere else

    the manual value is saved, text field replaced with read-only value, and the original value is visible below.

  5. Click on the transaction row

    it opens the modal, with the manual and original labels, both followed by search icons

  6. Click on the manual label pen icon

    the manual field is editable, it has focus, close and restore icon

  7. Hit Tab twice to focus on the restore icon, then Enter to trigger it

    the manual label is discarded, text field replaced by read-only value. The original label row is gone, and the value in transaction list is also restored

There's plenty of other ways to test it, you can also try to search for manual labels.

❗ Notes to reviewers

This PR is draft, and I'd like to collect some feedback before adding automated tests. In particular, I'd like to draw reviewers' attention on some tradeoffs:

  1. the "pen" icon button are very small, which isn't convenient on mobile. However making them bigger makes the transaction row higher, which does not look good

  2. the "close" button comes before "restore" button to make keyboard edition smoother.

  3. the transaction is only saved when the text field is losing focus: no complicate throttle needed

  4. I've styled the TextField so it looks like a Input field with "tiny" size, like in cozy-drive FilenameInput

Finally it worth calling out the great dev material you made to ease contributions. The setup isn't too complicated, and it's easy for a React dev to contribute. I couldn't make HMR work (despite running my cozy-app-dev docker container with -e COZY_DISABLE_CSP=1), but it's not too bad.

cballevre commented 8 months ago

Thank you for taking the time to make this PR 👏 I'm testing all these tomorrow morning