field-kit
field-kit copied to clipboard
Ability to remove photos from a log
If you make a mistake when selecting photos to attach to a log, or when you take a picture with your camera, there is no way to remove the photo. And due to #261, if you click the back arrow and then reopen the log, you can't see the photos at all.
I'm putting this in the v1.0.0 milestone, but if we need to bump it to v1.1.0 I think that's OK. It's a major limitation, but only when a mistake is made by the user in selecting/taking a photo.
Another important point here is the difference between photos that are synced to the server vs ones that are just cached in the database and are waiting to be synced. My original thought with this issue was just to focus on the cached photos as a first step.
For anyone who finds this issue, the easiest workaround is: sync the log to farmOS, then delete the photo in farmOS. :man_shrugging:
@mstenta and @jgaehring I'd be glad to look into this over Thanksgiving as well. I agree we should be able to remove images!
@alexadamsmith This one is a lower priority (I removed it from the v1.0.0 milestone) but you're more than welcome to look into it! I would recommend waiting until after #132 / #162 are resolved, as that may change how this needs to work.
This should be some pretty low-hanging fruit at this point, mostly achieved by the yet untested removeFile()
funciton:
https://github.com/farmOS/field-kit/blob/0394dc3412604aa363d2b832a20c09cd31262faa/packages/field-kit/src/entities/index.js#L491-L506
Assuming that works as intended, all that's needed in ObservationsContainer.vue
is to call it with the log reference, the name of the field, and the file to be removed (or its url, or a reference to it, or an array of such values):
removeFile(log, 'image', logImages[2]);
... or something along those lines.