TimeTrex/interface/html5/dist/portal-header-HeaderUploadResumeWidget.bundle.js

1 line
11 KiB
JavaScript
Raw Permalink Normal View History

2022-12-13 07:10:06 +01:00
"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' )