Thank you @Maxim, I uploaded the files and got files URLs as array from server, now how could I send these URL back to the server on sync.
This is my task modal
class Task extends TaskModel {
static fields = [
{name: 'name', type: 'string', defaultValue: 'New task'},
{name: 'description', type: 'string', defaultValue: ''},
{name: 'commit_date', type: 'date', defaultValue: null},
{name: 'priority', type: 'string', defaultValue: 'low'},
{name: 'status', type: 'string'},
{name: 'completed', type: 'boolean', defaultValue: false},
{name: 'uploaded_files[]', type: 'string'},
];
}
This is my items in task editor config
items : {
// Change the label for the name field
name : { label : 'Title' },
description : { label : 'Description' , type : 'textarea', height : '10em'},
commit_date : { label : 'Commit date', type : 'date' },
priority : {
type : 'combo',
label : 'Priority',
items : [{
id : 'low',
text : 'Low',
}, {
id : 'medium',
text : 'Medium',
}, {
id : 'high',
text : 'High',
}]
},
completed: { label: 'Completed', type: 'checkbox'},
color: null,
fileUpload : {
type : 'filepicker',
ref : 'input',
fileFieldConfig : {
multiple : true,
// label : 'Upload File',
// accept : "image/*"
},
buttonConfig : {
text : 'Upload files',
icon : 'b-fa-folder-open'
},
listeners : {
change : ({ files }) => {
taskFileUpload(files);
},
clear : () => {
}
}
},
}
and this is my taskFileUpload
const taskFileUpload = (files) => {
let formData = new FormData();
for (let i = 0; i < files.length; i++) {
formData.append('files[]', files[i]);
}
$.ajax({
url: "{{route('task-boards.uploadFiles')}}",
method: 'POST',
data: formData,
contentType: false,
processData: false,
beforeSend: function (){
mask('taskBoardContainer')
},
success: function (resp){
if(resp.status){
//need to place this stringify values to the upload_files
//JSON.stringify(resp.data.files);
}
},
error: function(xhr) {
let obj = JSON.parse(xhr.responseText);
Toast.show({html: obj.message, cls : 'b-red text-white' });
},
complete: function (){
unmask('taskBoardContainer')
}
});
}
now how can I set this JSON.stringify(resp.data.files);
need to place this stringified values to the upload_files field. so that it could send as well during sync