Skip to content

Commit

Permalink
Merge pull request #6429 from getkirby/fix/6380-file-upload-sort
Browse files Browse the repository at this point in the history
File upload: fix sort number
  • Loading branch information
bastianallgeier committed May 2, 2024
2 parents 7235440 + 3370774 commit 8a62f05
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions panel/src/panel/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,14 @@ export default (panel) => {
file.error = null;
file.progress = 0;

// clone the attributes to ensure that
// each file has its own copy, e.g. of sort
// (otherwise all files would use the state
// of attributes from the last file in the loop)
const attributes = { ...this.attributes };

// add file to upload queue
files.push(async () => await this.upload(file));
files.push(async () => await this.upload(file, attributes));

const sort = this.attributes?.sort;

Expand All @@ -304,10 +310,10 @@ export default (panel) => {
return this.done();
}
},
async upload(file) {
async upload(file, attributes) {
try {
const response = await upload(file.src, {
attributes: this.attributes,
attributes: attributes,
headers: { "x-csrf": panel.system.csrf },
filename: file.name + "." + file.extension,
url: this.url,
Expand Down

0 comments on commit 8a62f05

Please sign in to comment.