Iniit
This commit is contained in:
@@ -0,0 +1,708 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var Unibase;
|
||||
(function (Unibase) {
|
||||
let Forms;
|
||||
(function (Forms) {
|
||||
let Controls;
|
||||
(function (Controls) {
|
||||
class FileDragNDrop extends Unibase.Platform.Core.BaseComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.formPropArray = [];
|
||||
this.isMultipleArray = [];
|
||||
this.files_array = [];
|
||||
this.documentId = [];
|
||||
this.fileSize = 20971520;
|
||||
}
|
||||
init(formpropertyid, prop, callback) {
|
||||
var container = "control-container-" + prop.UniqueId;
|
||||
var instance = this;
|
||||
if (instance.formPropArray.length == 0 || $("#file_" + prop.UniqueId).val() == "") {
|
||||
instance.itemid = 0;
|
||||
instance.doc_array = [];
|
||||
instance.files_array[formpropertyid] = [];
|
||||
$("#hf_file_" + formpropertyid).val("");
|
||||
instance.documentId[formpropertyid] = 0;
|
||||
instance.Singledoc_array = [];
|
||||
instance.rmvFiles_array = [];
|
||||
instance.ismultiple = "false";
|
||||
instance.local_container = container;
|
||||
instance.singlefile = "";
|
||||
}
|
||||
else {
|
||||
var newValues = instance.formPropArray.find(x => x.formpropertyid = prop.UniqueId);
|
||||
instance.assignValues(newValues);
|
||||
}
|
||||
instance.loadPropertySettings(prop.PropertySettings, prop.UniqueId);
|
||||
$('#browse_' + prop.UniqueId).click(function () {
|
||||
$("#file_" + prop.UniqueId).click();
|
||||
});
|
||||
instance.dragNdrop(prop.UniqueId);
|
||||
$("#file_" + prop.UniqueId).change(function () {
|
||||
instance.UploadFile(prop.UniqueId);
|
||||
});
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentTypes().then(function (response) {
|
||||
instance.documenttypes = response.result;
|
||||
}).then(function () {
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
loadControl(container, prop) {
|
||||
var instance = this;
|
||||
instance.local_container = container;
|
||||
instance.emptydoc_array(container);
|
||||
var index = instance.formPropArray.findIndex((obj => obj.key == prop.UniqueId));
|
||||
if (index >= 0) {
|
||||
instance.formPropArray.splice(index, 1);
|
||||
}
|
||||
var regExpr = "";
|
||||
var ErrMsg = "";
|
||||
var Isrequired = prop.IsRequired != true ? 'hidden' : '';
|
||||
var required = prop.IsRequired != true ? '' : 'required';
|
||||
const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
|
||||
var html = "";
|
||||
var fileControlObj = prop.PropertySettings.find(x => x.ControlPropertyName == "IsFileControl");
|
||||
if (fileControlObj.ControlPropertyValue == "false") {
|
||||
html = '<div id="paneldrag" class="col-sm-12 mt-20 drag"><div class="col-sm-12" id="panel"><p>' +
|
||||
'<div class="text-center"><i class="fa fa-cloud-download fa-3x" aria-hidden="true"></i></div>' +
|
||||
'<div class="text-center" id="drag" style="font-size:medium">Drag and drop files here</div>' +
|
||||
'<div class="text-center">Or</div>' +
|
||||
'</p></div>' +
|
||||
'<div class="row mb-10" id="UploadDiv_' + prop.DocPropertyName + '">' +
|
||||
'<input type="text" class="hidden ' + required + '" id="hf_file_' + prop.UniqueId + '" value=""/>' +
|
||||
'<div class="upload-btn-wrapper text-center container">' +
|
||||
'<input id="file_' + prop.UniqueId + '" title="" type="file" onclick="this.value=null;" class="hidden d-none fileUpload_ form-control type-control value-control" data-isrequired="' + prop.IsRequired + '" data-propertyname="' + prop.DocPropertyName + '" data-isdefault="' + prop.IsDefault + '" data-propdoctypename="' + prop.DocTypeName + '" data-required="' + prop.IsRequired + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" data-formdata="" value="Unibase.Forms.Controls.FileDragNDrop.Instance().fileDragNDropObj(' + prop.UniqueId + ');"/>' +
|
||||
'<input type="button" value="Browse" class="btn btn-primary btn-lg center-block" id="browse_' + prop.UniqueId + '" />' +
|
||||
'</div></div><div class="text-center my-1 control-help">' + helpTooltipHtml + helpTextHtml + '</div></div>' +
|
||||
'<div class="row ml-15 fileuploads_ filename" id="fileuploads_' + prop.UniqueId + '"><div class="row col-sm-12 ml-10 mt-10 pull-center thumb_doc"><div class="col-sm-12 row pl-0"><div class="input-group">' +
|
||||
'<span class="Selectedfile_ text-dark hidden"><h5 class="Selection mb-10 mt-10">Selected Files :</h5> <span class="Selectedfile"></span></span>' +
|
||||
'</div></div><div class="row col-sm-12 pl-0 pr-0">' +
|
||||
'<ul id="ulselectedfiles_' + prop.UniqueId + '" class="list-group mb-n mt-n-15 no-border ulselectedfiles col-sm-12 pl-0 pr-0">' +
|
||||
'<li class="hidden no-border"></li>' +
|
||||
'</ul></div></div></div>';
|
||||
}
|
||||
else {
|
||||
var hiddenClass = "hidden";
|
||||
if (prop.IsRequired) {
|
||||
hiddenClass = "";
|
||||
}
|
||||
html = '<h6>' + helpTooltipHtml + prop.LabelName + '<span class="text-danger ' + hiddenClass + '"> *</span> :</h6><div class="row" id="UploadDiv_' + prop.DocPropertyName + '">' +
|
||||
'<input type="text" class="hidden ' + required + '" id="hf_file_' + prop.UniqueId + '" value=""/>' +
|
||||
'<div class="btn text-left container">' +
|
||||
'<input id="file_' + prop.UniqueId + '" title="" type="file" onclick="this.value=null;" class="hidden d-none fileUpload_ form-control value-control" data-isrequired="' + prop.IsRequired + '" data-propertyname="' + prop.DocPropertyName + '" data-isdefault="' + prop.IsDefault + '" data-propdoctypename="' + prop.DocTypeName + '" data-required="' + prop.IsRequired + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" data-formdata="" value="Unibase.Forms.Controls.FileDragNDrop.Instance().fileDragNDropObj(' + prop.UniqueId + ');"/>' +
|
||||
'<input type="button" value="Browse" class="" id="browse_' + prop.UniqueId + '" />' + helpTextHtml +
|
||||
'</div></div>' +
|
||||
'<div class="row ml-15 fileuploads_ filename" id="fileuploads_' + prop.UniqueId + '"><div class="row col-sm-12 ml-10 pull-center thumb_doc"><div class="col-sm-12 row pl-0"><div class="input-group">' +
|
||||
'<span class="Selectedfile_ text-dark hidden"><h6 class="Selection">Selected Files :</h6> <span class="Selectedfile"></span></span>' +
|
||||
'</div></div><div class="row col-sm-12 pl-0 pr-0">' +
|
||||
'<ul id="ulselectedfiles_' + prop.UniqueId + '" class="list-group mb-n mt-n-15 no-border ulselectedfiles col-sm-12 pl-0 pr-0">' +
|
||||
'<li class="hidden no-border"></li>' +
|
||||
'</ul></div></div></div>';
|
||||
}
|
||||
$("#" + container).html(html);
|
||||
if (prop.PropertySettings[0].ControlPropertyValue == "false") {
|
||||
$(".drag").css("border", "3px dashed #cccccc");
|
||||
}
|
||||
}
|
||||
loadControlSettings(controlsettingjson, formpropertyid) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
});
|
||||
}
|
||||
loadPropertySettings(propertysettings, formpropertyid) {
|
||||
var instance = this;
|
||||
if (propertysettings != null) {
|
||||
for (var i = 0; i < propertysettings.length; i++) {
|
||||
var data = propertysettings[i];
|
||||
if (data.ControlPropertyName == "IsMultiple" && data.ControlPropertyValue != "") {
|
||||
if (data.ControlPropertyValue == "true") {
|
||||
instance.ismultiple = "true";
|
||||
$("#file_" + formpropertyid).attr("multiple", "multiple");
|
||||
}
|
||||
else {
|
||||
instance.ismultiple = "false";
|
||||
$("#file_" + formpropertyid).removeAttr("multiple");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var index = instance.isMultipleArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
instance.isMultipleArray[index].value = instance.ismultiple;
|
||||
}
|
||||
else {
|
||||
instance.isMultipleArray.push({ "key": formpropertyid, "value": instance.ismultiple });
|
||||
}
|
||||
}
|
||||
bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
|
||||
var instance = this;
|
||||
propval = propval.replaceAll("\\", "/");
|
||||
var documentInfo = "";
|
||||
var containerid = "control-container-" + formpropertyid;
|
||||
if (!isNaN(Number(propval))) {
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentByRefId(Number(propval), formpropertyid).then(function (response) {
|
||||
documentInfo = response.result;
|
||||
}).then(function () {
|
||||
if (documentInfo !== "") {
|
||||
instance.documentId[formpropertyid] = documentInfo.DocumentId;
|
||||
instance.bindData(documentInfo, formpropertyid);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
documentInfo = JSON.parse(propval);
|
||||
instance.documentId[formpropertyid] = documentInfo.DocumentId;
|
||||
instance.bindData(documentInfo, formpropertyid);
|
||||
}
|
||||
}
|
||||
bindData(documentInfo, formpropertyid) {
|
||||
var instance = this;
|
||||
var filesList = documentInfo.DocumentFiles;
|
||||
for (var i = 0; i < filesList.length; i++) {
|
||||
var isRequired = $("#file_" + formpropertyid).data("isrequired");
|
||||
if (isRequired) {
|
||||
$("#file_" + formpropertyid).removeClass("required");
|
||||
}
|
||||
filesList[i].DocumentFilePath = filesList[i].DocumentFilePath.replaceAll("\\", "/");
|
||||
var documentImage = '';
|
||||
var imgSrc = "";
|
||||
if (filesList[i].DocumentGroup != "") {
|
||||
if (filesList[i].DocumentGroup == "Unknown")
|
||||
documentImage = 'tenants/default/documenttypes/unknown.png';
|
||||
else if (filesList[i].DocumentGroup == "Image") {
|
||||
var byteCharacters = atob(filesList[i].FileData);
|
||||
var byteNumbers = new Array(byteCharacters.length);
|
||||
for (var k = 0; k < byteCharacters.length; k++) {
|
||||
byteNumbers[k] = byteCharacters.charCodeAt(k);
|
||||
}
|
||||
var byteArray = new Uint8Array(byteNumbers);
|
||||
var fileTemp = new Blob([byteArray], { type: filesList[i].DocumentGroup + '/' + filesList[i].FileType + ';base64' });
|
||||
imgSrc = URL.createObjectURL(fileTemp);
|
||||
documentImage = imgSrc;
|
||||
}
|
||||
else if (filesList[i].DocumentGroup == "Excel")
|
||||
documentImage = 'tenants/default/documenttypes/excel.png';
|
||||
else if (filesList[i].DocumentGroup == "Pdf")
|
||||
documentImage = 'tenants/default/documenttypes/pdf.png';
|
||||
else if (filesList[i].FileType == "csv")
|
||||
documentImage = 'tenants/default/documenttypes/csv.png';
|
||||
else if (filesList[i].DocumentGroup == "Word")
|
||||
documentImage = 'tenants/default/documenttypes/word.png';
|
||||
else if (filesList[i].DocumentGroup == "Video")
|
||||
documentImage = 'tenants/default/documenttypes/video.png';
|
||||
else if (filesList[i].DocumentGroup == "Audio")
|
||||
documentImage = 'tenants/default/documenttypes/audio.png';
|
||||
}
|
||||
instance.itemid++;
|
||||
var docFilePath = filesList[i].DocumentFilePath.split('/');
|
||||
var docFileName = docFilePath[docFilePath.length - 1];
|
||||
var name = filesList[i].DocumentFilePath.split('/');
|
||||
var tempName = name[name.length - 1].split('.');
|
||||
name = tempName[tempName.length - 1];
|
||||
name = encodeURIComponent(name).replace(/\'/g, "%2E");
|
||||
var html = '<li class="list-group-item b-a clear pl-0 pr-0" style="border: none !important">' +
|
||||
'<span id="fileuploads_' + formpropertyid + '_' + instance.itemid + '" class="block fileuploads_' + instance.itemid + ' filename">' +
|
||||
'<span class="pull-left col-sm-12 pl-0 pr-0">' +
|
||||
'<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" ; href="javascript:;" onclick="javascript:Unibase.Forms.Controls.FileDragNDrop.Instance().removeFile(' + formpropertyid + ',' + instance.itemid + ',\'' + name + '\'' + ',' + filesList[i].DocumentFileId + ');" title="Click to Delete"></span>' +
|
||||
'<img class="mr-20" style="height:35px;width:35px;vertical-align:middle;" onerror="ReloadImage(event)" alt="" src="' + documentImage + '">' +
|
||||
'<span class="fileName">' + docFileName + '</span>' +
|
||||
'</span></span></li>';
|
||||
$('#ulselectedfiles_' + formpropertyid).append(html);
|
||||
$("#hf_file_" + formpropertyid).val("fileexists");
|
||||
var file = filesList[i];
|
||||
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').removeClass("hidden");
|
||||
var item = { Files: file };
|
||||
instance.doc_array.push(item);
|
||||
}
|
||||
}
|
||||
dragNdrop(formpropertyid) {
|
||||
var instance = this;
|
||||
instance.navigationHelper.showLoading();
|
||||
$('#paneldrag').on('dragover', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
$('#paneldrag').on('dragenter', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
$('#paneldrag').on('drop', function (e) {
|
||||
if (e.originalEvent.dataTransfer) {
|
||||
if (e.originalEvent.dataTransfer.files.length) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (instance.formPropArray.length > 0) {
|
||||
var index = instance.formPropArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
var newValues = instance.formPropArray[index].value;
|
||||
instance.assignValues(newValues);
|
||||
}
|
||||
}
|
||||
if (instance.ismultiple == "false" && instance.doc_array.length < 1) {
|
||||
instance.SingleUploadFile(e.originalEvent.dataTransfer.files, formpropertyid);
|
||||
}
|
||||
else if (instance.ismultiple == "true" || instance.doc_array.length > 1) {
|
||||
instance.MultipleUploadFile(e.originalEvent.dataTransfer.files, formpropertyid);
|
||||
$("#file_" + formpropertyid).attr("multiple", "multiple");
|
||||
}
|
||||
else {
|
||||
instance.SingleUploadFile(e.originalEvent.dataTransfer.files, formpropertyid);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
window.addEventListener("dragover", function (e) {
|
||||
e = e || event;
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
window.addEventListener("drop", function (e) {
|
||||
e = e || event;
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
instance.navigationHelper.hideLoading();
|
||||
}
|
||||
UploadFile(formpropertyid) {
|
||||
var instance = this;
|
||||
instance.navigationHelper.showLoading();
|
||||
var prq = instance.isMultipleArray.find(x => x.key == formpropertyid);
|
||||
instance.ismultiple = prq.value;
|
||||
if (instance.formPropArray.length > 0) {
|
||||
var index = instance.formPropArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
var newValues = instance.formPropArray[index].value;
|
||||
instance.assignValues(newValues);
|
||||
}
|
||||
}
|
||||
if (instance.ismultiple == "false") {
|
||||
$('#fileuploads_' + formpropertyid).find('.Selection').text("Selected File :");
|
||||
$('#fileuploads_' + formpropertyid).find('.Selection').addClass("text-dark");
|
||||
instance.SingleUploadFile(null, formpropertyid);
|
||||
}
|
||||
else if (instance.ismultiple == "true" || instance.doc_array.length > 1) {
|
||||
instance.MultipleUploadFile(null, formpropertyid);
|
||||
$("#file_" + formpropertyid).attr("multiple", "multiple");
|
||||
}
|
||||
else {
|
||||
instance.SingleUploadFile(null, formpropertyid);
|
||||
$('#fileuploads_' + formpropertyid).find('.Selection').text("Selected File :");
|
||||
$('#fileuploads_' + formpropertyid).find('.Selection').addClass("text-dark");
|
||||
}
|
||||
instance.navigationHelper.hideLoading();
|
||||
}
|
||||
SingleUploadFile(event, formpropertyid) {
|
||||
var instance = this;
|
||||
if (instance.formPropArray.length > 0) {
|
||||
var index = instance.formPropArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
var newValues = instance.formPropArray[index].value;
|
||||
instance.assignValues(newValues);
|
||||
}
|
||||
}
|
||||
var fileUpload = $("#file_" + formpropertyid).get(0);
|
||||
var files = fileUpload.files;
|
||||
if (event != null)
|
||||
files = event;
|
||||
instance.singlefile = "";
|
||||
var flag = 0;
|
||||
if (files.length > 0) {
|
||||
var html = "";
|
||||
var count = 0;
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
if (files[i].size <= instance.fileSize) {
|
||||
instance.navigationHelper.showLoading();
|
||||
flag = 0;
|
||||
if (flag == 0) {
|
||||
instance.itemid++;
|
||||
var imgShow = '';
|
||||
if (!files[i].type.match('image.*')) {
|
||||
if (files[i].type.match('pdf.*')) {
|
||||
imgShow = 'tenants/default/documenttypes/pdf.png';
|
||||
}
|
||||
else if (files[i].type.match('csv.*')) {
|
||||
imgShow = 'tenants/default/documenttypes/csv.png';
|
||||
}
|
||||
else if (files[i].type.match('wordprocessingml.*') || files[i].type.match('text.*')) {
|
||||
imgShow = 'tenants/default/documenttypes/word.png';
|
||||
}
|
||||
else if (files[i].type.match('spreadsheetml.*')) {
|
||||
imgShow = 'tenants/default/documenttypes/excel.png';
|
||||
}
|
||||
else if (files[i].type.match('excel.*')) {
|
||||
imgShow = 'tenants/default/documenttypes/excel.png';
|
||||
}
|
||||
else
|
||||
imgShow = 'tenants/default/documenttypes/unknown.png';
|
||||
}
|
||||
else {
|
||||
var tmppath = URL.createObjectURL(files[i]);
|
||||
imgShow = tmppath;
|
||||
}
|
||||
var filename = encodeURIComponent(files[i].name).replace(/\'/g, "%2E");
|
||||
html = '<li class="list-group-item b-a clear pl-0 pr-0" style="border: none !important">' +
|
||||
'<span id="fileuploads_' + formpropertyid + '_' + instance.itemid + '" class="block fileuploads_' + instance.itemid + ' filename">' +
|
||||
'<span class="pull-left">' +
|
||||
'<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" href="javascript:;" onclick="javascript:Unibase.Forms.Controls.FileDragNDrop.Instance().removeFile(' + formpropertyid + ',' + instance.itemid + ',\'' + filename + '\'' + ',' + 0 + ');" title = "Click to Delete"></span>' +
|
||||
'<img style="height:35px;width:35px;vertical-align:middle;" onerror="ReloadImage(event)" alt="" src="' + imgShow + '">' +
|
||||
'<span class="ml-20 fileName">' + files[i].name + '</span>' +
|
||||
'</span></span></li>';
|
||||
instance.singlefile = files[i];
|
||||
$('#ulselectedfiles_' + formpropertyid).html(html);
|
||||
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').removeClass("hidden");
|
||||
var item = { Files: instance.singlefile };
|
||||
if (item.Files.size <= instance.fileSize) {
|
||||
if (instance.Singledoc_array.length = 1) {
|
||||
instance.Singledoc_array.pop();
|
||||
instance.Singledoc_array.push(item);
|
||||
instance.getBase64(item).then(function (response) {
|
||||
var fileInfo = response;
|
||||
instance.files_array[formpropertyid] = [];
|
||||
instance.files_array[formpropertyid].push(fileInfo);
|
||||
$("#hf_file_" + formpropertyid).val("fileexists");
|
||||
count++;
|
||||
if (count == files.length) {
|
||||
instance.navigationHelper.hideLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert("Cannot Upload File More Than 20MB");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert("Cannot Upload File More Than 20MB");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var formPropDetails = { "Singledoc_array": instance.Singledoc_array, "doc_array": instance.doc_array, "rmvFiles_array": instance.rmvFiles_array, "itemid": instance.itemid, "ismultiple": instance.ismultiple, "local_container": instance.local_container, "instance.singlefile": instance.singlefile, "documentid": instance.documentId };
|
||||
if (index >= 0)
|
||||
instance.formPropArray[index].value = formPropDetails;
|
||||
else
|
||||
instance.formPropArray.push({ "key": formpropertyid, "value": formPropDetails });
|
||||
}
|
||||
MultipleUploadFile(event, formpropertyid) {
|
||||
var instance = this;
|
||||
if (instance.formPropArray.length > 0) {
|
||||
var index = instance.formPropArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
var newValues = instance.formPropArray[index].value;
|
||||
instance.assignValues(newValues);
|
||||
}
|
||||
}
|
||||
var errormsg = $("#" + instance.local_container).parents().find(".bizgaze_FormErrorMessages").attr("id");
|
||||
var fileUpload = $("#file_" + formpropertyid).get(0);
|
||||
var files = fileUpload.files;
|
||||
if (event != null)
|
||||
files = event;
|
||||
var file = "";
|
||||
var flag = 0;
|
||||
if (files.length > 0) {
|
||||
var xyz = "";
|
||||
var html = "";
|
||||
var count = 0;
|
||||
instance.navigationHelper.showLoading();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
flag = 0;
|
||||
if (files[i].size <= instance.fileSize) {
|
||||
$("#ulselectedfiles_" + formpropertyid + " li").each(function (index, element) {
|
||||
if (index != 0 && flag == 0) {
|
||||
var filesSelected = $(this).find(".fileName").text();
|
||||
if (files[i].name == filesSelected) {
|
||||
xyz += files[i].name + " ";
|
||||
MessageHelper.Instance().showError(xyz + " files already exist", "" + errormsg);
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (flag == 0) {
|
||||
instance.itemid++;
|
||||
var imgShow = '';
|
||||
var filename = files[i].name;
|
||||
var fileExt = files[i].name.split(".");
|
||||
if (files[i].type.match('image.*')) {
|
||||
var tmppath = URL.createObjectURL(files[i]);
|
||||
}
|
||||
var docData = instance.documenttypes.find(x => x.documenttypename == fileExt[fileExt.length - 1].toLowerCase());
|
||||
if (docData != null) {
|
||||
if (docData.documentgroup == "Pdf") {
|
||||
imgShow = 'tenants/default/documenttypes/pdf.png';
|
||||
}
|
||||
else if (docData.documentgroup == "Image") {
|
||||
imgShow = tmppath;
|
||||
}
|
||||
else if (docData.documentgroup == "Word") {
|
||||
imgShow = 'tenants/default/documenttypes/word.png';
|
||||
}
|
||||
else if (files[i].type.match('csv.*')) {
|
||||
imgShow = 'tenants/default/documenttypes/csv.png';
|
||||
}
|
||||
else if (docData.documentgroup == "Excel") {
|
||||
imgShow = 'tenants/default/documenttypes/excel.png';
|
||||
}
|
||||
else if (docData.documentgroup == "Video") {
|
||||
imgShow = 'tenants/default/documenttypes/video.png';
|
||||
}
|
||||
else if (docData.documentgroup == "Audio") {
|
||||
imgShow = 'tenants/default/documenttypes/audio.png';
|
||||
}
|
||||
}
|
||||
else
|
||||
imgShow = 'tenants/default/documenttypes/unknown.png';
|
||||
filename = encodeURIComponent(filename).replace(/\'/g, "%2E");
|
||||
html = '<li class="list-group-item b-a clear pl-0 pr-0" style="border: none !important">' +
|
||||
'<span id="fileuploads_' + formpropertyid + '_' + instance.itemid + '" class="block fileuploads_' + instance.itemid + ' filename">' +
|
||||
'<span class="pull-left col-sm-12 pl-0 pr-0">' +
|
||||
'<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" ; href="javascript:;" onclick="javascript:Unibase.Forms.Controls.FileDragNDrop.Instance().removeFile(' + formpropertyid + ',' + instance.itemid + ',\'' + filename + '\'' + ',' + 0 + ');" title="Click to Delete"></span>' +
|
||||
'<img class="mr-20" style="height:35px;width:35px;vertical-align:middle;" onerror="ReloadImage(event)" alt="" src="' + imgShow + '">' +
|
||||
'<span class="fileName">' + files[i].name + '</span>' +
|
||||
'</span></span></li>';
|
||||
$('#ulselectedfiles_' + formpropertyid).append(html);
|
||||
file = files[i];
|
||||
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').removeClass("hidden");
|
||||
var item = { Files: file };
|
||||
instance.doc_array.push(item);
|
||||
instance.getBase64(item).then(function (response) {
|
||||
var fileInfo = response;
|
||||
instance.files_array[formpropertyid].push(fileInfo);
|
||||
$("#hf_file_" + formpropertyid).val("fileexists");
|
||||
count++;
|
||||
if (count == files.length) {
|
||||
instance.navigationHelper.hideLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert("file cannot be more than 20Mb");
|
||||
break;
|
||||
}
|
||||
}
|
||||
instance.navigationHelper.hideLoading();
|
||||
}
|
||||
var formPropDetails = { "Singledoc_array": instance.Singledoc_array, "doc_array": instance.doc_array, "rmvFiles_array": instance.rmvFiles_array, "itemid": instance.itemid, "ismultiple": instance.ismultiple, "local_container": instance.local_container, "instance.singlefile": instance.singlefile, "documentid": instance.documentId };
|
||||
if (index >= 0)
|
||||
instance.formPropArray[index].value = formPropDetails;
|
||||
else
|
||||
instance.formPropArray.push({ "key": formpropertyid, "value": formPropDetails });
|
||||
}
|
||||
emptydoc_array(container) {
|
||||
var instance = this;
|
||||
instance.itemid = 0;
|
||||
instance.doc_array = [];
|
||||
instance.Singledoc_array = [];
|
||||
instance.rmvFiles_array = [];
|
||||
instance.ismultiple = "false";
|
||||
instance.local_container = container;
|
||||
instance.singlefile = "";
|
||||
}
|
||||
removeFile(formpropertyid, itemid, name, DocumentFileId) {
|
||||
name = decodeURIComponent(name.replace(/\%2E/g, "'"));
|
||||
var instance = this;
|
||||
var isRequired = $("#file_" + formpropertyid).data("isrequired");
|
||||
if (instance.formPropArray.length > 0) {
|
||||
var index = instance.formPropArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
var newValues = instance.formPropArray[index].value;
|
||||
instance.assignValues(newValues);
|
||||
}
|
||||
}
|
||||
instance.rmvFiles_array.push({ DocumentFileId: DocumentFileId, name: name });
|
||||
$("#fileuploads_" + formpropertyid + "_" + itemid).addClass("hidden");
|
||||
$("#fileuploads_" + formpropertyid + "_" + itemid).parents('.list-group-item').remove();
|
||||
for (var i = 0; i < instance.doc_array.length; i++) {
|
||||
var filename = "";
|
||||
filename = instance.doc_array[i].Files.DocumentFileName;
|
||||
if (filename == undefined)
|
||||
filename = instance.doc_array[i].Files.name;
|
||||
if (filename == name) {
|
||||
var fileNameWithoutExt = name.split(/\.(?=[^\.]+$)/)[0];
|
||||
var fileIndex = instance.files_array[formpropertyid].findIndex(x => x.FileName == fileNameWithoutExt);
|
||||
instance.files_array[formpropertyid].splice(fileIndex, 1);
|
||||
if (instance.files_array[formpropertyid].length == 0) {
|
||||
$("#file_" + formpropertyid).val(null);
|
||||
$("#hf_file_" + formpropertyid).val("");
|
||||
}
|
||||
instance.doc_array = $.grep(instance.doc_array, function (value) {
|
||||
return value != instance.doc_array[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
for (var j = 0; j < instance.Singledoc_array.length; j++) {
|
||||
var filename = "";
|
||||
filename = instance.Singledoc_array[j].Files.DocumentFileName;
|
||||
if (filename == undefined)
|
||||
filename = instance.Singledoc_array[j].Files.name;
|
||||
if (filename == name) {
|
||||
instance.Singledoc_array = $.grep(instance.Singledoc_array, function (value) {
|
||||
return value != instance.Singledoc_array[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
if ($('#ulselectedfiles_' + formpropertyid + ' li').length == 1) {
|
||||
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').addClass("hidden");
|
||||
}
|
||||
if (isRequired) {
|
||||
var fileArray = instance.files_array[formpropertyid];
|
||||
var fileCount = $("#ulselectedfiles_" + formpropertyid + " li").length;
|
||||
if (fileArray.length == 0) {
|
||||
if (fileCount == 1) {
|
||||
$("#file_" + formpropertyid).addClass("required");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
getFormData(formpropertyid) {
|
||||
var index = Unibase.Forms.Controls.FileDragNDrop.Instance().formPropArray.findIndex((obj => obj.key == formpropertyid));
|
||||
if (index >= 0) {
|
||||
var documentArray = Unibase.Forms.Controls.FileDragNDrop.Instance().formPropArray[index].value.doc_array;
|
||||
var fileData = new FormData();
|
||||
for (var i = 0; i < documentArray.length; i++) {
|
||||
var files = documentArray[i].Files;
|
||||
fileData.append(files.name, files);
|
||||
}
|
||||
}
|
||||
return fileData;
|
||||
}
|
||||
fileDragNDropObj(formpropertyid) {
|
||||
var instance = this;
|
||||
var fileArray = [];
|
||||
fileArray = instance.files_array[formpropertyid];
|
||||
for (var i = 0; i < instance.rmvFiles_array.length; i++) {
|
||||
var documentFileId = instance.rmvFiles_array[i].DocumentFileId;
|
||||
if (documentFileId != 0) {
|
||||
var fileReq = {
|
||||
FileId: documentFileId,
|
||||
FilePath: instance.rmvFiles_array[i].name,
|
||||
};
|
||||
fileArray.push(fileReq);
|
||||
}
|
||||
}
|
||||
var fileObj = [...fileArray];
|
||||
fileObj.unshift({
|
||||
FileId: instance.documentId[formpropertyid],
|
||||
});
|
||||
return fileObj;
|
||||
}
|
||||
saveFile(formpropertyid, callback) {
|
||||
var instance = this;
|
||||
var fileArray = [];
|
||||
fileArray = instance.files_array[formpropertyid];
|
||||
var count = 0;
|
||||
if (fileArray != undefined && fileArray.length > 0) {
|
||||
instance.navigationHelper.showLoading();
|
||||
for (var i = 0; i <= fileArray.length - 1; i++) {
|
||||
var file = fileArray[i];
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance()._tempFileSave(file).then((res) => {
|
||||
if (res.status == Unibase.Data.Status.Success) {
|
||||
var result = res.result;
|
||||
if (result != null) {
|
||||
fileArray[count].FileData = "";
|
||||
fileArray[count].Status = "Uploaded";
|
||||
count++;
|
||||
if (count == fileArray.length) {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileArray[count].Status = "Failed";
|
||||
instance.navigationHelper.hideLoading();
|
||||
Unibase.Platform.Forms.Components.FormViewer.Instance().showError("File Upload Failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
assignValues(newValues) {
|
||||
var instance = this;
|
||||
instance.itemid = newValues.itemid;
|
||||
instance.doc_array = newValues.doc_array;
|
||||
instance.Singledoc_array = newValues.Singledoc_array;
|
||||
instance.rmvFiles_array = newValues.rmvFiles_array;
|
||||
instance.ismultiple = newValues.ismultiple;
|
||||
instance.local_container = newValues.local_container;
|
||||
instance.singlefile = newValues.singlefile;
|
||||
}
|
||||
getBase64(item) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var fileName = "";
|
||||
fileName = item.Files.DocumentFileName;
|
||||
if (fileName == undefined)
|
||||
fileName = item.Files.name;
|
||||
var refId = 0;
|
||||
let file = item.Files;
|
||||
let fileInfo = item.Files.name.split('.');
|
||||
let fileType = ".unknown";
|
||||
if (fileInfo.length > 0) {
|
||||
fileType = fileInfo[fileInfo.length - 1];
|
||||
fileInfo.splice(fileInfo.length - 1, 1);
|
||||
fileName = fileInfo.join('.');
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let content = '';
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(item.Files);
|
||||
reader.onloadend = function () {
|
||||
var base64String = reader.result.toString().replace(/^data:.+;base64,/, '');
|
||||
var fileReq = {
|
||||
FileData: base64String,
|
||||
FileName: fileName,
|
||||
FileType: fileType,
|
||||
RefId: refId,
|
||||
ByteData: null,
|
||||
Status: "Converted",
|
||||
FilePath: "_files/documents/" + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().tenantId + "/" + Unibase.Forms.Controls.FileDragNDrop.Instance().generateUUID().trim() + "/" + fileName + "." + fileType
|
||||
};
|
||||
resolve(fileReq);
|
||||
};
|
||||
reader.onerror = function (e) {
|
||||
reject(e);
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
generateUUID() {
|
||||
var d = new Date().getTime();
|
||||
var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now() * 1000)) || 0;
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = Math.random() * 16;
|
||||
if (d > 0) {
|
||||
r = (d + r) % 16 | 0;
|
||||
d = Math.floor(d / 16);
|
||||
}
|
||||
else {
|
||||
r = (d2 + r) % 16 | 0;
|
||||
d2 = Math.floor(d2 / 16);
|
||||
}
|
||||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
||||
});
|
||||
}
|
||||
static Instance() {
|
||||
if (this._instance === undefined)
|
||||
this._instance = new FileDragNDrop();
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
Controls.FileDragNDrop = FileDragNDrop;
|
||||
})(Controls = Forms.Controls || (Forms.Controls = {}));
|
||||
})(Forms = Unibase.Forms || (Unibase.Forms = {}));
|
||||
})(Unibase || (Unibase = {}));
|
||||
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,90 @@
|
||||
var Unibase;
|
||||
(function (Unibase) {
|
||||
let Forms;
|
||||
(function (Forms) {
|
||||
let Controls;
|
||||
(function (Controls) {
|
||||
class FileDragNDrop_Settings {
|
||||
loadSettingHtml() {
|
||||
return ``;
|
||||
}
|
||||
bindControlData(controldatajson) {
|
||||
return "";
|
||||
}
|
||||
SaveControlData(controldatajson) {
|
||||
return "";
|
||||
}
|
||||
loadControlPropertiesHtml(Container) {
|
||||
var html = `<section class="">` +
|
||||
`<div class="card PropertySettings">` +
|
||||
`<div class="card-header"><h6><b>Property Settings</b></h6></div>` +
|
||||
`<div class="card-body" id="divPropSetting"><div class="row"><div class="col-sm-6 Controlproperties-Element" data-propertysettingid="0" data-controlpropertyid="0" data-controlpropertyname="IsMultiple"><label for="IsMultiple" style="margin-top:19px"><b>IsMultiple</b></label><label id="lblIsMultiple" class="switch m-t form-inline pull-right mt-10" style="color:grey"><input id="IsMultiple" data-group="IsRequired" type="checkbox"><span></span></label></div><div class="col-sm-6 Controlproperties-Element" data-propertysettingid="0" data-controlpropertyid="0" data-controlpropertyname="IsFileControl"><label for="IsFileControl" style="margin-top:19px"><b>IsFileControl</b></label><label id="lblIsFileControl" class="switch m-t form-inline pull-right mt-10" style="color:grey"><input id="IsFileControl" data-group="IsRequired" type="checkbox"><span></span></label></div></div>` +
|
||||
`<div class="row" id="divValidate"><div class="col-sm-6 Controlproperties-Element" data-propertysettingid="0" data-controlpropertyid="0" data-controlpropertyname="IsValidate"><label for="IsValidate" style="margin-top:19px"><b>IsValidate</b></label><label id="lblIsValidate" class="switch m-t form-inline pull-right mt-10" style="color:grey"><input id="IsValidate" data-group="IsRequired" type="checkbox"><span></span></label></div></div></div>` +
|
||||
`</div></section>`;
|
||||
$(Container).html(html);
|
||||
$("#divPropSetting").removeClass('hidden');
|
||||
}
|
||||
bindPropertySettings(prop) {
|
||||
var propertySettings = prop.PropertySettings;
|
||||
if (propertySettings != null && propertySettings != undefined) {
|
||||
var i = 0;
|
||||
$(".Controlproperties-Element").each(function () {
|
||||
var currentPropSetting = $(this).children().find("input").attr("id");
|
||||
var propSetting = propertySettings.find(x => x.ControlPropertyName == currentPropSetting);
|
||||
$(this).attr("data-controlpropertyid", propSetting.ControlPropertyId);
|
||||
$(this).attr("data-controlpropertyname", propSetting.ControlPropertyName);
|
||||
$(this).attr("data-propertysettingid", propSetting.PropertySettingId);
|
||||
if (currentPropSetting == "IsMultiple") {
|
||||
if (propSetting.ControlPropertyValue == "true") {
|
||||
$("#IsMultiple").prop("checked", true);
|
||||
}
|
||||
else {
|
||||
$("#IsMultiple").prop("checked", false);
|
||||
}
|
||||
}
|
||||
if (currentPropSetting == "IsFileControl") {
|
||||
if (propSetting.ControlPropertyValue == "true") {
|
||||
$("#IsFileControl").prop("checked", true);
|
||||
}
|
||||
else {
|
||||
$("#IsFileControl").prop("checked", false);
|
||||
}
|
||||
}
|
||||
if (currentPropSetting == "IsValidate") {
|
||||
if (propSetting.ControlPropertyValue == "true") {
|
||||
$("#IsValidate").prop("checked", true);
|
||||
}
|
||||
else {
|
||||
$("#IsValidate").prop("checked", false);
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
savePropertySettings(prop) {
|
||||
var propertySettings = prop.PropertySettings;
|
||||
var propSettingReq = [];
|
||||
$(".Controlproperties-Element").each(function () {
|
||||
var data = {
|
||||
FormPropertyId: isNaN(Number(prop.FormPropertyId)) ? 0 : Number(prop.FormPropertyId),
|
||||
ControlPropertyId: Number($(this).attr("data-controlpropertyid")),
|
||||
ControlPropertyValue: $(this).children().find("input").prop("checked").toString(),
|
||||
ControlPropertyName: $(this).attr("data-controlpropertyname"),
|
||||
ControlId: isNaN(Number(prop.ControlId)) ? 0 : Number(prop.ControlId),
|
||||
PropertySettingId: Number($(this).attr("data-propertysettingid")),
|
||||
};
|
||||
propSettingReq.push(data);
|
||||
});
|
||||
return propSettingReq;
|
||||
}
|
||||
static Instance() {
|
||||
if (this._instance === undefined)
|
||||
this._instance = new FileDragNDrop_Settings();
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
Controls.FileDragNDrop_Settings = FileDragNDrop_Settings;
|
||||
})(Controls = Forms.Controls || (Forms.Controls = {}));
|
||||
})(Forms = Unibase.Forms || (Unibase.Forms = {}));
|
||||
})(Unibase || (Unibase = {}));
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filedragndrop.settings.js","sourceRoot":"","sources":["filedragndrop.settings.ts"],"names":[],"mappings":"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"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
var Unibase;(function(n){let t;(function(n){let t;(function(n){class t{loadSettingHtml(){return``}bindControlData(){return""}SaveControlData(){return""}loadControlPropertiesHtml(n){var t=`<section class="">`+`<div class="card PropertySettings">`+`<div class="card-header"><h6><b>Property Settings</b></h6></div>`+`<div class="card-body" id="divPropSetting"><div class="row"><div class="col-sm-6 Controlproperties-Element" data-propertysettingid="0" data-controlpropertyid="0" data-controlpropertyname="IsMultiple"><label for="IsMultiple" style="margin-top:19px"><b>IsMultiple</b></label><label id="lblIsMultiple" class="switch m-t form-inline pull-right mt-10" style="color:grey"><input id="IsMultiple" data-group="IsRequired" type="checkbox"><span></span></label></div><div class="col-sm-6 Controlproperties-Element" data-propertysettingid="0" data-controlpropertyid="0" data-controlpropertyname="IsFileControl"><label for="IsFileControl" style="margin-top:19px"><b>IsFileControl</b></label><label id="lblIsFileControl" class="switch m-t form-inline pull-right mt-10" style="color:grey"><input id="IsFileControl" data-group="IsRequired" type="checkbox"><span></span></label></div></div>`+`<div class="row" id="divValidate"><div class="col-sm-6 Controlproperties-Element" data-propertysettingid="0" data-controlpropertyid="0" data-controlpropertyname="IsValidate"><label for="IsValidate" style="margin-top:19px"><b>IsValidate</b></label><label id="lblIsValidate" class="switch m-t form-inline pull-right mt-10" style="color:grey"><input id="IsValidate" data-group="IsRequired" type="checkbox"><span></span></label></div></div></div>`+`</div></section>`;$(n).html(t);$("#divPropSetting").removeClass("hidden")}bindPropertySettings(n){var t=n.PropertySettings,i;t!=null&&t!=undefined&&(i=0,$(".Controlproperties-Element").each(function(){var r=$(this).children().find("input").attr("id"),n=t.find(n=>n.ControlPropertyName==r);$(this).attr("data-controlpropertyid",n.ControlPropertyId);$(this).attr("data-controlpropertyname",n.ControlPropertyName);$(this).attr("data-propertysettingid",n.PropertySettingId);r=="IsMultiple"&&(n.ControlPropertyValue=="true"?$("#IsMultiple").prop("checked",!0):$("#IsMultiple").prop("checked",!1));r=="IsFileControl"&&(n.ControlPropertyValue=="true"?$("#IsFileControl").prop("checked",!0):$("#IsFileControl").prop("checked",!1));r=="IsValidate"&&(n.ControlPropertyValue=="true"?$("#IsValidate").prop("checked",!0):$("#IsValidate").prop("checked",!1));i+=1}))}savePropertySettings(n){var i=n.PropertySettings,t=[];return $(".Controlproperties-Element").each(function(){var i={FormPropertyId:isNaN(Number(n.FormPropertyId))?0:Number(n.FormPropertyId),ControlPropertyId:Number($(this).attr("data-controlpropertyid")),ControlPropertyValue:$(this).children().find("input").prop("checked").toString(),ControlPropertyName:$(this).attr("data-controlpropertyname"),ControlId:isNaN(Number(n.ControlId))?0:Number(n.ControlId),PropertySettingId:Number($(this).attr("data-propertysettingid"))};t.push(i)}),t}static Instance(){return this._instance===undefined&&(this._instance=new t),this._instance}}n.FileDragNDrop_Settings=t})(t=n.Controls||(n.Controls={}))})(t=n.Forms||(n.Forms={}))})(Unibase||(Unibase={}));
|
||||
@@ -0,0 +1,147 @@
|
||||
var Unibase;
|
||||
(function (Unibase) {
|
||||
let Platform;
|
||||
(function (Platform) {
|
||||
let Forms;
|
||||
(function (Forms) {
|
||||
let Components;
|
||||
(function (Components) {
|
||||
class DocumentFiles extends Platform.Core.BaseComponent {
|
||||
previewDocument(documentFileId, previewicon) {
|
||||
if (previewicon == "disabled") {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
var instance = this;
|
||||
instance.fileCacheHelper.loadJsFiles(["platform/files/managers/filemanager.js", "platform/core/helpers/mobile/mobilehelper.js", "platform/core/helpers/mobile/interfaces/imobilehelper.js", "platform/core/helpers/mobile/android/androidhelper.js"], function () {
|
||||
if (isMobileApp()) {
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentFile(documentFileId).then(function (response) {
|
||||
var filePath = response.result.DocumentFilePath;
|
||||
if (filePath != null && filePath != undefined && filePath != "") {
|
||||
filePath = filePath.replace("file://" + '/', '');
|
||||
filePath = filePath.replace(window.location.origin + '/', '');
|
||||
Unibase.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(response, filePath, Unibase.Platform.Forms.Components.DocumentFiles.Instance().MobileFilePathPreviewCallBack);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentBase64File(documentFileId).then(function (response) {
|
||||
var result = response.result;
|
||||
var byteCharacters = atob(result.FileData);
|
||||
var byteNumbers = new Array(byteCharacters.length);
|
||||
for (var i = 0; i < byteCharacters.length; i++) {
|
||||
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
||||
}
|
||||
var byteArray = new Uint8Array(byteNumbers);
|
||||
var file = new Blob([byteArray], { type: result.DocumentGroup + '/' + result.FileType + ';base64' });
|
||||
var fileURL = URL.createObjectURL(file);
|
||||
var fileName = result.DocumentFileName + "." + result.FileType;
|
||||
window.open(fileURL, fileName, "width=600,height=600,scrollbars=yes");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
downloadDocument(documentFileId) {
|
||||
var instance = this;
|
||||
instance.fileCacheHelper.loadJsFiles(["platform/files/managers/filemanager.js", "platform/core/helpers/mobile/mobilehelper.js", "platform/core/helpers/mobile/interfaces/imobilehelper.js", "platform/core/helpers/mobile/android/androidhelper.js"], function () {
|
||||
if (isMobileApp()) {
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentFile(documentFileId).then(function (response) {
|
||||
var filePath = response.result.DocumentFilePath;
|
||||
if (filePath != null && filePath != undefined && filePath != "") {
|
||||
filePath = filePath.replace("file://" + '/', '');
|
||||
filePath = filePath.replace(window.location.origin + '/', '');
|
||||
Unibase.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(response, filePath, Unibase.Platform.Forms.Components.DocumentFiles.Instance().MobileFilePathDownloadCallBack);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentBase64File(documentFileId).then(function (response) {
|
||||
var a = document.createElement("a");
|
||||
a.href = "data:" + response.result.FileType + ";base64," + response.result.FileData;
|
||||
a.download = response.result.DocumentFileName + "." + response.result.FileType;
|
||||
a.click();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
MobileFilePathDownloadCallBack(response, filePath, mobileFilePath) {
|
||||
mobileFilePath.replace(/^\//, '');
|
||||
filePath = filePath.replace(mobileFilePath + '/', '');
|
||||
var tempPath = filePath.split("~/");
|
||||
var checkPath = tempPath[tempPath.length - 1];
|
||||
filePath = checkPath;
|
||||
var server_url = _appsettings.server_url();
|
||||
if (!filePath.includes(server_url)) {
|
||||
filePath = server_url + "/" + filePath;
|
||||
}
|
||||
var a = document.createElement("a");
|
||||
a.href = filePath;
|
||||
a.download = response.result.DocumentFileName + "." + response.result.FileType;
|
||||
a.click();
|
||||
}
|
||||
MobileFilePathPreviewCallBack(response, filePath, mobileFilePath) {
|
||||
mobileFilePath.replace(/^\//, '');
|
||||
filePath = filePath.replace(mobileFilePath + '/', '');
|
||||
var tempPath = filePath.split("~/");
|
||||
var checkPath = tempPath[tempPath.length - 1];
|
||||
filePath = checkPath;
|
||||
var server_url = _appsettings.server_url();
|
||||
if (!filePath.includes(server_url)) {
|
||||
filePath = server_url + "/" + filePath;
|
||||
}
|
||||
Unibase.Platform.Helpers.MobileHelper.Instance().openNewWindow(filePath);
|
||||
}
|
||||
deleteDocumentFile(DocumentFileId) {
|
||||
var instance = this;
|
||||
bootbox.confirm("Do you want to Delete this File ?", function (result) {
|
||||
if (result == true) {
|
||||
instance.fileCacheHelper.loadJsFile("platform/files/managers/filemanager.js", function () {
|
||||
Unibase.Platform.Files.Managers.FileManager.Instance().deleteDocumentFile(DocumentFileId).then(function (response) {
|
||||
MessageHelper.Instance().showSuccess("Document File Deleted Successfully.", "");
|
||||
var ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
|
||||
if (ContainerId != null && ContainerId != undefined && ContainerId != '') {
|
||||
var viewall = ContainerId.toString().includes("_viewall");
|
||||
if (viewall) {
|
||||
var refreshButton = $("#" + ContainerId).find(".report-refresh-btn");
|
||||
if (refreshButton.length > 0) {
|
||||
refreshButton.click();
|
||||
}
|
||||
}
|
||||
else {
|
||||
instance.reloadPortlet();
|
||||
}
|
||||
}
|
||||
else {
|
||||
instance.reloadPortlet();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
reloadPortlet() {
|
||||
var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
|
||||
var containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
|
||||
var portletId = 0;
|
||||
var activePortletIndex = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets.findIndex(x => x.InstalledAppId == installedAppId);
|
||||
if (activePortletIndex > -1) {
|
||||
portletId = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets[activePortletIndex].ActivePortletId;
|
||||
}
|
||||
if (portletId == 0) {
|
||||
portletId = Number($("#hf_PortletId").val());
|
||||
}
|
||||
Unibase.Themes.Compact.Components.Details.Instance().loadWidgets(installedAppId, portletId, containerId);
|
||||
}
|
||||
static Instance() {
|
||||
if (this.instance === undefined) {
|
||||
this.instance = new DocumentFiles();
|
||||
}
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
Components.DocumentFiles = DocumentFiles;
|
||||
})(Components = Forms.Components || (Forms.Components = {}));
|
||||
})(Forms = Platform.Forms || (Platform.Forms = {}));
|
||||
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
|
||||
})(Unibase || (Unibase = {}));
|
||||
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
var Unibase;(function(n){let t;(function(t){let i;(function(i){let r;(function(i){class r extends t.Core.BaseComponent{previewDocument(t,i){if(i=="disabled")return!1;var r=this;r.fileCacheHelper.loadJsFiles(["platform/files/managers/filemanager.js","platform/core/helpers/mobile/mobilehelper.js","platform/core/helpers/mobile/interfaces/imobilehelper.js","platform/core/helpers/mobile/android/androidhelper.js"],function(){isMobileApp()?n.Platform.Files.Managers.FileManager.Instance().getDocumentFile(t).then(function(t){var i=t.result.DocumentFilePath;i!=null&&i!=undefined&&i!=""&&(i=i.replace("file:///",""),i=i.replace(window.location.origin+"/",""),n.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(t,i,n.Platform.Forms.Components.DocumentFiles.Instance().MobileFilePathPreviewCallBack))}):n.Platform.Files.Managers.FileManager.Instance().getDocumentBase64File(t).then(function(n){for(var t=n.result,r=atob(t.FileData),u=new Array(r.length),i=0;i<r.length;i++)u[i]=r.charCodeAt(i);var f=new Uint8Array(u),e=new Blob([f],{type:t.DocumentGroup+"/"+t.FileType+";base64"}),o=URL.createObjectURL(e),s=t.DocumentFileName+"."+t.FileType;window.open(o,s,"width=600,height=600,scrollbars=yes")})})}downloadDocument(t){var i=this;i.fileCacheHelper.loadJsFiles(["platform/files/managers/filemanager.js","platform/core/helpers/mobile/mobilehelper.js","platform/core/helpers/mobile/interfaces/imobilehelper.js","platform/core/helpers/mobile/android/androidhelper.js"],function(){isMobileApp()?n.Platform.Files.Managers.FileManager.Instance().getDocumentFile(t).then(function(t){var i=t.result.DocumentFilePath;i!=null&&i!=undefined&&i!=""&&(i=i.replace("file:///",""),i=i.replace(window.location.origin+"/",""),n.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(t,i,n.Platform.Forms.Components.DocumentFiles.Instance().MobileFilePathDownloadCallBack))}):n.Platform.Files.Managers.FileManager.Instance().getDocumentBase64File(t).then(function(n){var t=document.createElement("a");t.href="data:"+n.result.FileType+";base64,"+n.result.FileData;t.download=n.result.DocumentFileName+"."+n.result.FileType;t.click()})})}MobileFilePathDownloadCallBack(n,t,i){var u,e,f,r;i.replace(/^\//,"");t=t.replace(i+"/","");u=t.split("~/");e=u[u.length-1];t=e;f=_appsettings.server_url();t.includes(f)||(t=f+"/"+t);r=document.createElement("a");r.href=t;r.download=n.result.DocumentFileName+"."+n.result.FileType;r.click()}MobileFilePathPreviewCallBack(t,i,r){var u,e,f;r.replace(/^\//,"");i=i.replace(r+"/","");u=i.split("~/");e=u[u.length-1];i=e;f=_appsettings.server_url();i.includes(f)||(i=f+"/"+i);n.Platform.Helpers.MobileHelper.Instance().openNewWindow(i)}deleteDocumentFile(t){var i=this;bootbox.confirm("Do you want to Delete this File ?",function(r){r==!0&&i.fileCacheHelper.loadJsFile("platform/files/managers/filemanager.js",function(){n.Platform.Files.Managers.FileManager.Instance().deleteDocumentFile(t).then(function(){var t,u,r;MessageHelper.Instance().showSuccess("Document File Deleted Successfully.","");t=n.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();t!=null&&t!=undefined&&t!=""?(u=t.toString().includes("_viewall"),u?(r=$("#"+t).find(".report-refresh-btn"),r.length>0&&r.click()):i.reloadPortlet()):i.reloadPortlet()})})})}reloadPortlet(){var i=n.Themes.Providers.DetailHelper.installedAppId,u="#"+n.Platform.Helpers.NavigationHelper.Instance().getLastContainerId(),t=0,r=n.Themes.Providers.Detail_Settings.Instance().ActivePortlets.findIndex(n=>n.InstalledAppId==i);r>-1&&(t=n.Themes.Providers.Detail_Settings.Instance().ActivePortlets[r].ActivePortletId);t==0&&(t=Number($("#hf_PortletId").val()));n.Themes.Compact.Components.Details.Instance().loadWidgets(i,t,u)}static Instance(){return this.instance===undefined&&(this.instance=new r),this.instance}}i.DocumentFiles=r})(r=i.Components||(i.Components={}))})(i=t.Forms||(t.Forms={}))})(t=n.Platform||(n.Platform={}))})(Unibase||(Unibase={}));
|
||||
Reference in New Issue
Block a user