public_html/layouts/basic/modules/Documents/resources/MassAddDocuments.min.js
'use strict';
/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */"use strict";/**
* Class Documents_MassAddDocuments_Js.
* @type {window.Documents_MassAddDocuments_Js}
*/function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _createForOfIteratorHelper(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function(){};return {s:F,n:function n(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return {s:function s(){it=it.call(o);},n:function n(){var step=it.next();return normalCompletion=step.done,step},e:function e(_e2){didErr=!0,err=_e2;},f:function f(){try{normalCompletion||null==it.return||it.return();}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return "Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return "symbol"===_typeof(key)?key:String(key)}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===hint?String:Number)(input)}window.Documents_MassAddDocuments_Js=/*#__PURE__*/function(){function Documents_MassAddDocuments_Js(){_classCallCheck(this,Documents_MassAddDocuments_Js);}return _createClass(Documents_MassAddDocuments_Js,[{key:"registerSubmit",value:function registerSubmit(){var _this=this,uploadButton=this.modal.find("#filesToUpload"),template=this.modal.find(".fileContainer"),uploadContainer=this.modal.find(".uploadFileContainer");uploadButton.on("change",function(){uploadContainer.find(".fileItem").remove();var _step,files=uploadButton[0].files,_iterator=_createForOfIteratorHelper(files);try{for(_iterator.s();!(_step=_iterator.n()).done;){var file=_step.value;uploadContainer.append(template.html()),uploadContainer.find("[name=\"nameFile[]\"]:last").val(file.name);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}),this.form.on("submit",function(e){e.preventDefault(),_this.submit();});}/**
* Submit
*/},{key:"submit",value:function submit(){var _this2=this,moduleName=app.getModuleName(),recordId=app.getRecordId();0<this.modal.find("[name=\"sourceModule\"]").length&&(moduleName=this.modal.find("[name=\"sourceModule\"]").val()),0<this.modal.find("[name=\"sourceRecord\"]").length&&(recordId=this.modal.find("[name=\"sourceRecord\"]").val()),app.removeEmptyFilesInput(this.form[0]);var formData=new FormData(this.form[0]);"Detail"===this.button.data("view")&&(formData.append("createmode","link"),formData.append("return_module",moduleName),formData.append("return_id",recordId));var progressIndicatorElement=$.progressIndicator({blockInfo:{enabled:!0}});AppConnector.request({url:"index.php",type:"POST",data:formData,processData:!1,contentType:!1}).done(function(response){switch(progressIndicatorElement.progressIndicator({mode:"hide"}),app.hideModalWindow(null,_this2.modal.parent().attr("id")),_this2.button.data("view")){case"Detail":var detailView=Vtiger_Detail_Js.getInstance(),selectedTabElement=detailView.getSelectedTab();if("Documents"===selectedTabElement.data("reference"))detailView.reloadTabContent();else if("Documents"===detailView.getContentHolder().find(".detailViewBlockLink").data("reference"))Vtiger_RelatedList_Js.getInstance(detailView.getRecordId(),app.getModuleName(),selectedTabElement,"Documents").loadRelatedList();else {var updatesWidget=_this2.button.closest(".widgetContentBlock");0<updatesWidget.length&&detailView.loadWidget(updatesWidget,detailView.getFiltersData(updatesWidget).params);}break;case"List":var listInstance=Vtiger_List_Js.getInstance();listInstance.getListViewRecords().done(function(){listInstance.calculatePages().done(function(){listInstance.updatePagination();});});break;case"Edit":if(response.result){var fieldBlock=_this2.button.closest(".js-field-block-column"),field=fieldBlock.find("[name=\""+fieldBlock.data("field")+"[]\"]");App.Fields.Utils.setValue(field,response.result,{extend:!0},!1);}}});}/**
* Register events.
* @param {jQuery} modal
* @param {jQuery.Event} e
*/},{key:"registerEvents",value:function registerEvents(modal,e){this.modal=modal,this.form=modal.find("form"),this.button=$(e.currentTarget),this.registerSubmit();}}],[{key:"register",value:/**
* Create a class object
* @param {jQuery} modal
* @param {jQuery.Event} e
*/function register(modal,e){var self=new window[this.name];self.registerEvents(modal,e);}}]),Documents_MassAddDocuments_Js}();
//# sourceMappingURL=MassAddDocuments.min.js.map