orchidsoftware / orchidsoftware/platform
branch 11.0.1 Upload field - removing files
@tabuna is already working on this.
Since Jun 21, 2022.
- 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:
- Create screeen with upload
- Create model that will contain the attachments
- Upload some files and save them to model.
- Open that screen again.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.