Commit 114be7c5 authored by Clément Damiens's avatar Clément Damiens
Browse files

uploader refactor multi working
parent 222760aa
......@@ -143,8 +143,8 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
<button type="button" class="qq-ok-button-selector">Ok</button>
</div>
</dialog>
<div class="col-xs-12 text-center" style="display: none;">
<a href="javascript:;" class="btn btn-success margin-top-10 col-sm-6 col-sm-offset-3" id="<?php echo $domUploader ?>_submit"><?php echo Yii::t("common","Save") ?></a>
<div class="col-xs-12 text-center fineUploaderOpenFormSubmit" style="display: none;">
<a href="javascript:;" class="btn btn-success margin-top-10 col-sm-6 col-sm-offset-3 fineUploader_submit" data-dom-uploader="<?php echo $domUploader ?>" id="<?php echo $domUploader ?>_submit"><?php echo Yii::t("common","Save") ?></a>
</div>
</div>
</script>
......@@ -190,10 +190,11 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
},
callbacks: {
//when a img is selected
onSubmit: function(id, fileName) {
/*onSubmit: function(id, fileName) {
//if(typeof v.endPoint == "undefined")
// $(domElement).fineUploader('setEndpoint',uploadObj.path);
console.log("coucou",id,this);
alert(uploadAnswerObj.dom);
listObject=$("#"+uploadAnswerObj.dom).fineUploader('getUploads');
showBtnUpload=false;
if(listObject.length > 0){
......@@ -206,7 +207,7 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
$("#"+uploadAnswerObj.dom+"_submit").parent().show();//.fineUploader('uploadStoredFiles');
}
},
},*/
/* onCancel: function(id) {
if(($("ul.qq-upload-list > li").length-1)<=0)
$('#trigger-upload').addClass("hide");
......@@ -239,33 +240,7 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
mylog.log("onCompleate", id, fileName, responseJSON);
setFiles={};
setFiles[responseJSON.id.$id]=responseJSON;
//$("#"+uploadAnswerObj.dom).fineUploader("cancel",id);
//var fileContainer = this.getItemByFileId(responseJSON._id.$id);
//$child = $(fileContainer).find("{{CHILD ELEMENT SELECTOR HERE}}");
//$(fileContainer).attr("data-id", responseJSON._id.$id);
//$("#"+uploadAnswerObj.dom).fineUploader("addInitialFiles",prepFileForFormsUploader(setFiles));
//$.each(initListUploader, function(e,v){
//$("#"+uploadAnswerObj.dom).find(".qq-file-id-"+id+" .qq-upload-link").attr("href", responseJSON.docPath);
// $i++;
//});
/*if(typeof responseJSON.docPath != "undefined"){
mylog.log("suckmrewell",id);
//fileItem = self.getItemByFileId(id);
fileItem =$("#"+uploadAnswerObj.dom).fineUploader("getItemByFileId", id);
mylog.log("suckmrewell2",fileItem);
var linkBtn = $("#"+uploadAnswerObj.dom).fineUploader(getByClass("qq-upload-link");
mylog.log("suckmrewell2",linkBtn);
//linkBtn.setAttribute("href", cannedFile.pathUrl);
}*/
// var serverPathToFile = response.filePath,
// fileItem = this.getItemByFileId(id);
/*if (response.success) {
var viewBtn = qq(fileItem).getByClass("view-btn")[0];
viewBtn.setAttribute("href", serverPathToFile);
qq(viewBtn).removeClass("hide");
}*/
var serverPathToFile = responseJSON.docPath,
fileItem = this.getItemByFileId(id);
var viewTnh = qq(fileItem).getByClass("qq-upload-link")[0];
......@@ -288,10 +263,10 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
onSessionRequestComplete:function(response, success, xhrOrXdr){
},
//when all upload is complete whatever the result
onAllComplete: function(succeeded, failed) {
/* onAllComplete: function(succeeded, failed) {
mylog.log("ooooooooooooo",succeeded,failed);
$("#"+uploadAnswerObj.dom+"_submit").parent().fadeOut();
},
},*/
onError: function(id) {
toastr.info(trad.somethingwentwrong);
}
......@@ -303,7 +278,43 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
}
},
autoUpload: false
});
}).on("submit", function(event,id, fileName) {
//if(typeof v.endPoint == "undefined")
// $(domElement).fineUploader('setEndpoint',uploadObj.path);
listObject=$(this).fineUploader('getUploads');
showBtnUpload=false;
if(listObject.length > 0){
$.each(listObject, function(e,v){
if(v.status == "submitting")
showBtnUpload=true;
});
}
if( showBtnUpload ){
$(this).find(".fineUploaderOpenFormSubmit").show();//.fineUploader('uploadStoredFiles');
}
})/*.on("complete", function(event, id, fileName,responseJSON,xhr){
mylog.log("onCompleate", id, fileName, responseJSON);
setFiles={};
setFiles[responseJSON.id.$id]=responseJSON;
var serverPathToFile = responseJSON.docPath,
fileItem = this.getItemByFileId(id);
var viewTnh = qq(fileItem).getByClass("qq-upload-link")[0];
if(typeof viewTnh != "undefined")
viewTnh.setAttribute("href", serverPathToFile);
// $fileItem.find(".qq-upload-link")
// .attr("href", serverPathToFile)
// .removeClass("hide");
this.setDeleteFileEndpoint(baseUrl+"/"+moduleId+"/document/deletedocumentbyid/id/"+responseJSON.id.$id, id);
if(!responseJSON.result){
toastr.error(trad.somethingwentwrong+" : "+responseJSON.msg );
mylog.error(trad.somethingwentwrong , responseJSON.msg)
}
})*/.on("allComplete", function(event, succeeded, failed) {
mylog.log("ooooooooooooo",succeeded,failed);
$(this).find(".fineUploaderOpenFormSubmit").fadeOut();
});
if(typeof initListUploader != "undefined" && Object.keys(initListUploader).length > 0){
//objectListFiles=uploadObj.prepareInit(initFiles);
//console.log(objectListFiles,"bloublou");
......@@ -315,8 +326,9 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
});
}
$("#"+uploadAnswerObj.dom+"_submit").click(function(){
listObject=$("#"+uploadAnswerObj.dom).fineUploader('getUploads');
$(".fineUploader_submit").off().on("click",function(){
idUploader=$(this).data("dom-uploader");
listObject=$("#"+idUploader).fineUploader('getUploads');
goToUpload=false;
if(listObject.length > 0){
$.each(listObject, function(e,v){
......@@ -326,7 +338,7 @@ $initAnswerFiles=Document::getListDocumentsWhere(array(
}
if( goToUpload ){
insideCallBMulti=true;
$("#"+uploadAnswerObj.dom).fineUploader('uploadStoredFiles');
$("#"+idUploader).fineUploader('uploadStoredFiles');
//principalement pour les surveys
//if(typeof callB == "function")
// callB();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment