[Client] Fix bug
This commit is contained in:
parent
306da1b43a
commit
c338c1b844
3 changed files with 18 additions and 7 deletions
|
@ -516,13 +516,23 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.chooseFile = file => {
|
this.chooseFile = file => {
|
||||||
if (this.selectedFiles.some(f => f.id == file.id)) {
|
const isAlreadySelected = this.selectedFiles.some(f => f.id == file.id);
|
||||||
this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id);
|
if (this.multiple) {
|
||||||
|
if (isAlreadySelected) {
|
||||||
|
this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id);
|
||||||
|
} else {
|
||||||
|
this.selectedFiles.push(file);
|
||||||
|
}
|
||||||
|
this.update();
|
||||||
|
this.trigger('change-selection', this.selectedFiles);
|
||||||
} else {
|
} else {
|
||||||
this.selectedFiles.push(file);
|
if (isAlreadySelected) {
|
||||||
|
this.trigger('selected', file);
|
||||||
|
} else {
|
||||||
|
this.selectedFiles = [file];
|
||||||
|
this.trigger('change-selection', [file]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.update();
|
|
||||||
this.trigger('change-selection', this.selectedFiles);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.newWindow = folderId => {
|
this.newWindow = folderId => {
|
||||||
|
|
|
@ -156,6 +156,7 @@
|
||||||
|
|
||||||
this.browser.on('change-selection', selections => {
|
this.browser.on('change-selection', selections => {
|
||||||
this.isSelected = selections.some(f => f.id == this.file.id);
|
this.isSelected = selections.some(f => f.id == this.file.id);
|
||||||
|
this.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.onclick = () => {
|
this.onclick = () => {
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
|
|
||||||
this.on('mount', () => {
|
this.on('mount', () => {
|
||||||
this.refs.window.refs.browser.on('selected', file => {
|
this.refs.window.refs.browser.on('selected', file => {
|
||||||
this.files = file;
|
this.files = [file];
|
||||||
this.ok();
|
this.ok();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ok = () => {
|
this.ok = () => {
|
||||||
this.trigger('selected', this.files);
|
this.trigger('selected', this.multiple ? this.files : this.files[0]);
|
||||||
this.refs.window.close();
|
this.refs.window.close();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue