field-kit icon indicating copy to clipboard operation
field-kit copied to clipboard

Ability to remove photos from a log

Open mstenta opened this issue 4 years ago • 6 comments

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.

mstenta avatar Nov 22 '19 22:11 mstenta

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.

mstenta avatar Nov 22 '19 22:11 mstenta

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.

mstenta avatar Nov 25 '19 16:11 mstenta

For anyone who finds this issue, the easiest workaround is: sync the log to farmOS, then delete the photo in farmOS. :man_shrugging:

mstenta avatar Nov 25 '19 16:11 mstenta

@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 avatar Nov 25 '19 21:11 alexadamsmith

@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.

mstenta avatar Nov 27 '19 21:11 mstenta

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.

jgaehring avatar Feb 24 '23 16:02 jgaehring