fix: check cannot attach more than one file
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-03-04 11:59:45 +01:00
parent d22be6620c
commit b58020978a
1 changed files with 2 additions and 5 deletions

View File

@ -62,6 +62,7 @@ class Controller extends Section {
}
onSubmit() {
if (this.dms.files.length > 1) throw new UserError('You cannot attach more than one document');
const query = `dms/uploadFile`;
const options = {
method: 'POST',
@ -72,10 +73,7 @@ class Controller extends Section {
},
transformRequest: files => {
const formData = new FormData();
for (let i = 0; i < files.length; i++)
formData.append(files[i].name, files[i]);
formData.append(files[0].name, files[0]);
return formData;
},
data: this.dms.files
@ -83,7 +81,6 @@ class Controller extends Section {
this.$http(options).then(res => {
if (res) {
const addedDms = res.data;
if (addedDms.length > 1) throw new UserError('You cannot attach more than one document');
this.$.watcher.updateOriginalData();
const params = {