orchidsoftware / orchidsoftware/platform

branch 11.0.1 Upload field - removing files

Open
#2,282 1 comment 2 reactions 1 assignee View on GitHub

@tabuna is already working on this.

Since Jun 21, 2022.

Errors
Dominant language
PHP
Stars
4.8k
Forks
662
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Files not removing from html
Hi! For the bunch of reasons I'm stuck with 11.0.1 and I found that when clicking the button remove on the thumbnail of the picture, the thumbnail is beeing removed but the hidden input field not. So the request contains those ids of the files. I believe this is fixed in new releases :)

To Reproduce
Steps to reproduce the behavior:

  1. Create screeen with upload
  2. Create model that will contain the attachments
  3. Upload some files and save them to model.
  4. Open that screen again.
  5. Remove some file
    if take a look through the html of the widget you can see those hidden inputs wilth the file ids like that
    <input type="hidden" class="files-31" name="attachments[]" value="31">

So when saving, the request will contain the "removed" ids.

Expected behavior
The request should not contain the ids of the removed files

Additional context
This can be fixed in upload_controller.js

this.on('removedfile', file => {
                    if (file.hasOwnProperty('id')) { //the file contains not data.id but id
                        $(dropname).find(`.files-${file.id}`).remove();
                        !isMediaLibrary && axios
                            .delete(urlDelete + file.id, {
                                storage: storage,
                            })
                            .then();
                    }else if (file.hasOwnProperty('data.id')) { //old behavoir
                        $(dropname).find(`.files-${file.data.id}`).remove();
                        !isMediaLibrary && axios
                            .delete(urlDelete + file.data.id, {
                                storage: storage,
                            })
                            .then();
                    }
                });

may be I should do pull request to fix that in that branch?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.