1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
"use strict";(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["portal-header-HeaderUploadResumeWidget"],{3295:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"HeaderUploadResumeWidget\": () => (/* binding */ HeaderUploadResumeWidget)\n/* harmony export */ });\n/* harmony import */ var _views_TTBackboneView__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6739);\n/* harmony import */ var _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7526);\n/* harmony import */ var _global_TTUUID__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4936);\n/* harmony import */ var _services_ServiceCaller__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);\n/* provided dependency */ var _ = __webpack_require__(9050);\n/* provided dependency */ var $ = __webpack_require__(9755);\n\n\n\n\n\nclass HeaderUploadResumeWidget extends _views_TTBackboneView__WEBPACK_IMPORTED_MODULE_0__.TTBackboneView {\n\tconstructor( options = {} ) {\n\t\t_.defaults( options, {} );\n\n\t\tsuper( options );\n\t}\n\n\tinitialize( options ) {\n\t\tsuper.initialize( options );\n\t\tvar tpl = Global.loadWidget( 'views/portal/header/HeaderUploadResumeWidget.html' );\n\t\tthis.setElement( _.template( tpl )() );\n\t\tthis.document_id = null;\n\t\tthis.profileView = null;\n\t\tif ( options.profileView ) {\n\t\t\tthis.profileView = options.profileView;\n\t\t}\n\t\t// this.render();\n\t}\n\n\trender() {\n\t\tvar $this = this;\n\t\tif ( !this.uploader ) {\n\t\t\tthis.uploader = this.$( '.register-resume' ).TImageBrowser( {\n\t\t\t\tfield: 'file',\n\t\t\t\tname: 'filedata',\n\t\t\t\taccept_filter: '*',\n\t\t\t\tchangeHandler: function( a ) {\n\t\t\t\t\tvar file_name = $( this ).find( '.browser' )[0].files[0].name;\n\t\t\t\t\t$this.$( '#fileName' ).val( file_name );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tIndexViewController.instance.router.showFormModal( this.$el, {\n\t\t\ttitle: $.i18n._( 'Upload Resume' ),\n\t\t\tactions: [\n\t\t\t\t{ label: 'Close', isClose: true },\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Upload Resume' ), callBack: function( e ) {\n\t\t\t\t\t\t$this.uploadResume();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t} );\n\t}\n\n\tuploadResume() {\n\t\tvar $this = this;\n\t\tif ( !this.uploader ) {\n\t\t\treturn false;\n\t\t}\n\t\tvar uploader = this.uploader;\n\t\tvar name = uploader.attr( 'file_name' );\n\t\tvar file = uploader.getValue();\n\t\tif ( file ) {\n\t\t\tthis.document_api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APIDocumentPortal */ .y.APIDocumentPortal;\n\t\t\tvar document_name = 'Resume' + ' - ' + LocalCacheData.getPortalLoginUser().first_name + ' ' + LocalCacheData.getPortalLoginUser().last_name;\n\t\t\tvar result = this.document_api.addAttachment( document_name, '', { async: false } ).getResult();\n\t\t\tthis.document_id = result['document_id'];\n\t\t\tthis.uploadFile( file, result['document_revision_id'] );\n\t\t}\n\t}\n\n\tuploadFile( file_data, document_revision_id ) {\n\t\tvar $this = this;\n\t\tvar url = _services_ServiceCaller__WEBPACK_IMPORTED_MODULE_3__/* .ServiceCaller.getAPIURL */ .n.getAPIURL( 'Class=' + this.document_api.className + '&Method=uploadAttachment' + '&v=2' );\n\t\tif ( LocalCacheData.getAllURLArgs() ) {\n\t\t\tif ( LocalCacheData.getAllURLArgs().hasOwnProperty( 'company_id' ) ) {\n\t\t\t\turl = url + '&company_id=' + LocalCacheData.getAllURLArgs().company_id;\n\t\t\t}\n\t\t}\n\t\turl = url + '&object_id=' + document_revision_id;\n\t\tvar message_id = _global_TTUUID__WEBPACK_IMPORTED_MODULE_2__/* .TTUUID.generateUUID */ .d.generateUUID();\n\t\tProgressBar.showProgressBar( message_id );\n\t\tProgressBar.changeProgressBarMessage( $.i18n._( 'File Uploading' ) + '...' );\n\t\t$.ajax( {\n\t\t\turl: url, //Server script to process data\n\t\t\theaders: {\n\t\t\t\t//Handle CSRF tokens and related headers here.\n\t\t\t\t'X-Client-ID': 'Browser-TimeTrex',\n\t\t\t\t'X-CSRF-Token': getCookie( 'CSRF-Token' ),\n\t\t\t},\n\t\t\ttype: 'POST',\n\t\t\tdata: file_data,\n\t\t\tsuccess: function( res ) {\n\t\t\t\tProgressBar.removeProgressBar();\n\t\t\t\t$this.uploaded();\n\t\t\t\tif ( res.error ) {\n\t\t\t\t\t$this.showUploadedMessage( res.error );\n\t\t\t\t} else {\n\t\t\t\t\t$this.showUploadedMessage( $.i18n._( 'Upload Successful!' ) );\n\t\t\t\t\t$this.refreshSubDocument();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcache: false,\n\t\t\tcontentType: false,\n\t\t\tprocessData: false\n\t\t} );\n\t}\n\n\trefreshSubDocument() {\n\t\tif ( this.profileView ) {\n\t\t\tthis.profileView.addDocumentRow( this.document_id );\n\t\t}\n\t}\n\n\tuploaded() {\n\t\tthis.uploader = null;\n\t\tIndexViewController.instance.router.hideFormModal();\n\t}\n\n\tshowUploadedMessage( message ) {\n\t\tIndexViewController.instance.router.showTipModal( message );\n\t}\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzI5NS5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQXdEO0FBQ0g7QUFDWjtBQUNnQjs7QUFFbEQsdUNBQXVDLGlFQUFjO0FBQzVELDJCQUEyQjtBQUMzQixFQUFFLENBQUMsdUJBQXVCOztBQUUxQjtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBLG1CQUFtQixDQUFDO0FBQ3BCO0FBQ0E7QUFDQ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