"use strict";(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["DocumentSubViewController","portal-hr-my_profile-JobApplicantSubBaseViewController","JobApplicantSubBaseViewController"],{9495:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"DocumentSubViewController\": () => (/* binding */ DocumentSubViewController)\n/* harmony export */ });\n/* harmony import */ var _views_portal_hr_my_profile_JobApplicantSubBaseViewController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3757);\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 DocumentSubViewController extends _views_portal_hr_my_profile_JobApplicantSubBaseViewController__WEBPACK_IMPORTED_MODULE_0__.JobApplicantSubBaseViewController {\n\tconstructor( options = {} ) {\n\t\t_.defaults( options, {\n\t\t} );\n\n\t\tsuper( options );\n\t}\n\n\tinit( options ) {\n\t\tthis.document_api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APIDocumentPortal */ .y.APIDocumentPortal;\n\t\tthis.attachment_data = null;\n\t}\n\n\trender() {\n\t\tvar $this = this;\n\t\tvar list_tpl = Global.loadWidget( 'views/portal/hr/my_profile/MyProfileSubView.html' );\n\t\tvar unique_id = this.sub_view_id + '-' + this.model.id;\n\t\tthis.unique_id = unique_id;\n\t\tthis.sub_view = _.template( list_tpl )( {} );\n\t\tif ( this.table_container.find( '.table-container' ).length == 0 ) {\n\t\t\tthis.table_container.html( '
' );\n\t\t}\n\t\tif ( this.table_container.find( '#' + unique_id ).length === 0 ) {\n\t\t\tvar tbody = $( '' ).attr( 'id', unique_id );\n\t\t\t$( this.table_container.find( 'tbody' )[0] ).append( tbody );\n\t\t} else {\n\t\t\tthis.table_container.find( '#' + unique_id ).html( '' );\n\t\t}\n\t\tvar thead = $( '' );\n\t\tfor ( var column in this.display_columns ) {\n\t\t\tif ( !this.display_columns.hasOwnProperty( column ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvar column_val;\n\t\t\tswitch ( column ) {\n\t\t\t\tdefault:\n\t\t\t\t\tif ( !this.model.get( column ) ) {\n\t\t\t\t\t\tcolumn_val = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcolumn_val = this.model.get( column );\n\t\t\t\t\t}\n\t\t\t\t\tif ( column === 'name' ) {\n\t\t\t\t\t\tthis.table_container.find( '#' + unique_id ).append( '' + column_val + '' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.table_container.find( '#' + unique_id ).append( '' + column_val + '' );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthead.append( '' + this.display_columns[column] + '' );\n\t\t}\n\t\tthead.append( '' + $.i18n._( 'Action' ) + '' );\n\t\tif ( this.table_container.find( 'thead' ).html() === '' ) {\n\t\t\tthis.table_container.find( 'thead' ).html( thead );\n\t\t}\n\t\tthis.table_container.find( '#' + unique_id ).append( this.sub_view );\n\t\tthis.table_container.find( '#' + unique_id ).find( '.download-attachment' ).unbind( 'click' ).bind( 'click', function( e ) {\n\t\t\tvar filter = {};\n\t\t\tfilter.filter_data = {};\n\t\t\tfilter.filter_data.id = $this.model.id;\n\t\t\t$this.document_api['getAttachment']( filter, {\n\t\t\t\tonResult: function( result_data ) {\n\t\t\t\t\t$this.downloadFile( result_data );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t\tthis.table_container.find( '#' + unique_id ).find( '.edit-icon' ).unbind( 'click' ).bind( 'click', function( e ) {\n\t\t\t$this['get' + $this.sub_view_id]( function() {\n\t\t\t\t$this.setEditView();\n\t\t\t} );\n\t\t} );\n\t\tthis.table_container.find( '#' + unique_id ).find( '.delete-icon' ).unbind( 'click' ).bind( 'click', function( e ) {\n\t\t\t$this['get' + $this.sub_view_id]( function() {\n\t\t\t\t$this.onDeleteClick();\n\t\t\t} );\n\t\t} );\n\t}\n\n\tdownloadFile( result_data ) {\n\t\tvar $this = this;\n\t\tvar data = result_data.getResult();\n\t\tif ( data.length > 0 ) {\n\t\t\tvar document_id = data[0].id;\n\t\t\tvar document_revision_id = data[0].document_revision_id;\n\n\t\t\tvar url = _services_ServiceCaller__WEBPACK_IMPORTED_MODULE_3__/* .ServiceCaller.getAPIURL */ .n.getAPIURL( 'Class=APIDocumentPortal&Method=downloadAttachment' + '&v=2' );\n\t\t\tif ( LocalCacheData.getAllURLArgs().company_id ) {\n\t\t\t\turl = url + '&company_id=' + LocalCacheData.getAllURLArgs().company_id;\n\t\t\t}\n\n\t\t\tvar post_data = { parent_id: document_id, object_id: document_revision_id };\n\n\t\t\tGlobal.APIFileDownload( null, null, post_data, url );\n\t\t}\n\t}\n\n\tinitOptions() {\n\t\tvar $this = this;\n\t}\n\n\tgetDocument( callback ) {\n\t\tvar $this = this;\n\t\tvar filter = {};\n\t\tfilter.filter_data = {};\n\t\tfilter.filter_data.id = this.model.id;\n\t\tthis.api['getDocument']( filter, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\tvar result_data = result.getResult();\n\t\t\t\t\tif ( !result_data ) {\n\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t}\n\t\t\t\t\tresult_data = result_data[0];\n\t\t\t\t\t$this.model.set( result_data );\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$this.showErrorAlert( result );\n\t\t\t\t\tProgressBar.closeOverlay();\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\tsetCurrentEditRecordData() {\n\t\tsuper.setCurrentEditRecordData();\n\t\tvar field_selector;\n\t\tvar field_control;\n\t\t//Set current edit record data to all widgets\n\t\tfor ( var key in this.model.attributes ) {\n\t\t\tif ( !this.model.has( key ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'private':\n\t\t\t\tcase 'template':\n\t\t\t\t\tfield_selector = 'input[name=\"' + key + '\"]';\n\t\t\t\t\tif ( this.model.get( key ) === true ) {\n\t\t\t\t\t\tthis.$( field_selector ).prop( 'checked', 'checked' );\n\t\t\t\t\t} else if ( this.model.get( key ) === false ) {\n\t\t\t\t\t\tthis.$( field_selector ).removeAttr( 'checked' );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tif ( this.model.get( key ) === false ) {\n\t\t\t\t\t\tthis.model.set( key, '' );\n\t\t\t\t\t}\n\t\t\t\t\tfield_selector = '.form-control[name=\"' + key + '\"]';\n\t\t\t\t\tfield_control = this.$( field_selector );\n\t\t\t\t\tif ( field_control && field_control[0] ) {\n\t\t\t\t\t\tthis.$( field_selector ).val( this.model.get( key ) );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\t\t}\n\t}\n\n\tonSaveClick() {\n\t\tvar $this = this;\n\t\tif ( _.size( this.edit_view_error_ui_dic ) > 0 ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !this.model.get( 'name' ) ) {\n\t\t\tthis.model.set( 'name', 'Resume' + ' - ' + LocalCacheData.getPortalLoginUser().first_name + ' ' + LocalCacheData.getPortalLoginUser().last_name );\n\t\t}\n\t\tthis.api['set' + this.sub_view_id]( this.model.toJSON(), {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\tvar result_data = result.getResult();\n\t\t\t\t\tif ( result_data !== true && _global_TTUUID__WEBPACK_IMPORTED_MODULE_2__/* .TTUUID.isUUID */ .d.isUUID( result_data ) && result_data != _global_TTUUID__WEBPACK_IMPORTED_MODULE_2__/* .TTUUID.zero_id */ .d.zero_id && result_data != _global_TTUUID__WEBPACK_IMPORTED_MODULE_2__/* .TTUUID.not_exist_id */ .d.not_exist_id ) {\n\t\t\t\t\t\t$this.model.set( 'id', result_data );\n\t\t\t\t\t}\n\t\t\t\t\t$this.onSaveResult( result, function() {\n\t\t\t\t\t\t$this['get' + $this.sub_view_id]( function() {\n\t\t\t\t\t\t\tProgressBar.changeProgressBarMessage( 'Processing...' );\n\t\t\t\t\t\t\t// $this.render();\n\t\t\t\t\t\t\t$this.closeEditView();\n\t\t\t\t\t\t\t$this._delegate.refreshProfile();\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\t$this.setErrorTips( result );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\tonSaveResult( document_result, callback ) {\n\t\tvar document_id = document_result.getResult();\n\t\tvar $this = this;\n\n\t\t// var file = this.attachment_data;\n\n\t\tvar file = this.$( 'input[name=\"filedata\"]' )[0].files[0];\n\t\tvar form = new FormData();\n\t\tif ( document_id === true ) { // edit\n\t\t\tdocument_id = this.model.id;\n\t\t}\n\t\t//Save a document revision data if has upload file, otherwise don't\n\t\tif ( file ) {\n\t\t\tvar document_name = this.model.get( 'name' );\n\t\t\tvar revision = this.model.get( 'revision' );\n\t\t\tvar document_revision_id = this.document_api.addAttachment( document_name, document_id, revision, { async: false } ).getResult()['document_revision_id'];\n\t\t\tform.append( 'filedata', file );\n\t\t\tthis.uploadFile( form, document_revision_id, callback );\n\t\t} else {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tuploadFile( file_data, document_revision_id, callback ) {\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().company_id ) {\n\t\t\turl = url + '&company_id=' + LocalCacheData.getAllURLArgs().company_id;\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( '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\tif ( res.error.length > 0 ) {\n\t\t\t\t\tIndexViewController.instance.router.showTipModal( res.error );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcallback();\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\tonFormItemChange( e, doNotValidate ) {\n\t\tvar key = e.currentTarget.name;\n\t\tthis.model.set( key, $( e.currentTarget ).val() );\n\t\tswitch ( key ) {\n\t\t\t// case 'country':\n\t\t\t// case 'identification_country':\n\t\t\t// \tvar widget = this.$('select[name=\"' + key + '\"]');\n\t\t\t// \twidget.val( null );\n\t\t\t// \tbreak;\n\t\t\tcase 'private':\n\t\t\tcase 'template':\n\t\t\t\tif ( $( e.currentTarget ).is( ':checked' ) ) {\n\t\t\t\t\tthis.model.set( key, true );\n\t\t\t\t} else {\n\t\t\t\t\tthis.model.set( key, false );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tif ( !doNotValidate ) {\n\t\t\tthis.validate();\n\t\t}\n\t}\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9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ApO1xuXHRcdFx0Ly8gXHRicmVhaztcblx0XHRcdGNhc2UgJ3ByaXZhdGUnOlxuXHRcdFx0Y2FzZSAndGVtcGxhdGUnOlxuXHRcdFx0XHRpZiAoICQoIGUuY3VycmVudFRhcmdldCApLmlzKCAnOmNoZWNrZWQnICkgKSB7XG5cdFx0XHRcdFx0dGhpcy5tb2RlbC5zZXQoIGtleSwgdHJ1ZSApO1xuXHRcdFx0XHR9IGVsc2Uge1xuXHRcdFx0XHRcdHRoaXMubW9kZWwuc2V0KCBrZXksIGZhbHNlICk7XG5cdFx0XHRcdH1cblx0XHRcdFx0YnJlYWs7XG5cdFx0fVxuXHRcdGlmICggIWRvTm90VmFsaWRhdGUgKSB7XG5cdFx0XHR0aGlzLnZhbGlkYXRlKCk7XG5cdFx0fVxuXHR9XG59Il0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///9495\n")},3757:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"JobApplicantSubBaseViewController\": () => (/* binding */ JobApplicantSubBaseViewController)\n/* harmony export */ });\n/* harmony import */ var _views_portal_PortalBaseViewController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(97);\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/* provided dependency */ var _ = __webpack_require__(9050);\n/* provided dependency */ var $ = __webpack_require__(9755);\n\n\n\n\nclass JobApplicantSubBaseViewController extends _views_portal_PortalBaseViewController__WEBPACK_IMPORTED_MODULE_0__.PortalBaseViewController {\n\tconstructor( options = {} ) {\n\t\t_.defaults( options, {\n\t\t\tevents: {\n\t\t\t\t'change input[type=\"text\"]': 'onFormItemChange',\n\t\t\t\t'change input[type=\"checkbox\"]': 'onFormItemChange',\n\t\t\t\t'change select.form-control': 'onFormItemChange',\n\t\t\t\t'change textarea.form-control': 'onFormItemChange'\n\t\t\t\t// 'click .styled-select .glyphicon': 'onSelectClick',\n\t\t\t}\n\t\t} );\n\n\t\tsuper( options );\n\t}\n\n\tpreInit( options ) { //Since this is an intermediary class between *SubViewController and PortalBaseViewController, we need to use preInit() so this is called before init() of each child class.\n\t\tthis.api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APIJobApplicantPortal */ .y.APIJobApplicantPortal;\n\t\tthis.qualification_api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APIQualificationPortal */ .y.APIQualificationPortal;\n\t\tthis.company_api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APICompanyPortal */ .y.APICompanyPortal;\n\t\tthis.sub_view_id = options.sub_view_id;\n\t\tthis.display_columns = options.display_columns;\n\t\tthis.table_container = options.table_container;\n\t\tthis.available_fields = options.available_fields;\n\t\tthis._delegate = options._delegate;\n\t\tthis.edit_view_error_ui_dic = {};\n\t\tthis.enable_add_qualification = options.enable_add_qualification || false;\n\n\t}\n\n\tpostInit() {\n\t\tif ( !this.model.id ) {\n\t\t\tthis.setEditView();\n\t\t} else {\n\t\t\tthis.render();\n\t\t}\n\t}\n\n\trender() {\n\t\tvar $this = this;\n\t\tvar list_tpl = Global.loadWidget( 'views/portal/hr/my_profile/MyProfileSubView.html' );\n\t\tvar unique_id = this.sub_view_id + '-' + this.model.id;\n\t\tthis.unique_id = unique_id;\n\t\tthis.sub_view = _.template( list_tpl )( {} );\n\t\tif ( this.table_container.find( '.table-container' ).length == 0 ) {\n\t\t\tthis.table_container.html( '
' );\n\t\t}\n\t\tif ( this.table_container.find( '#' + unique_id ).length === 0 ) {\n\t\t\tvar tbody = $( '' ).attr( 'id', unique_id );\n\t\t\t$( this.table_container.find( 'tbody' )[0] ).append( tbody );\n\t\t} else {\n\t\t\tthis.table_container.find( '#' + unique_id ).html( '' );\n\t\t}\n\t\tvar thead = $( '' );\n\t\tfor ( var column in this.display_columns ) {\n\t\t\tif ( !this.display_columns.hasOwnProperty( column ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// comment this, this will cause some default display columns cannot be shown.\n\t\t\t// if ( !this.available_fields.hasOwnProperty( column ) ) {\n\t\t\t// \tcontinue;\n\t\t\t// }\n\t\t\tvar column_val;\n\t\t\tswitch ( column ) {\n\t\t\t\tcase 'is_current_employer':\n\t\t\t\tcase 'is_contact_available':\n\t\t\t\t\tif ( this.model.get( column ) ) {\n\t\t\t\t\t\tcolumn_val = $.i18n._( 'Yes' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcolumn_val = $.i18n._( 'No' );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tif ( !this.model.get( column ) ) {\n\t\t\t\t\t\tcolumn_val = '';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcolumn_val = this.model.get( column );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthead.append( '' + this.display_columns[column] + '' );\n\t\t\tthis.table_container.find( '#' + unique_id ).append( '' + column_val + '' );\n\t\t}\n\t\tthead.append( '' + $.i18n._( 'Action' ) + '' );\n\t\tif ( this.table_container.find( 'thead' ).html() === '' ) {\n\t\t\tthis.table_container.find( 'thead' ).html( thead );\n\t\t}\n\t\tthis.table_container.find( '#' + unique_id ).append( this.sub_view );\n\t\tthis.table_container.find( '#' + unique_id ).find( '.edit-icon' ).unbind( 'click' ).bind( 'click', function( e ) {\n\t\t\t$this['get' + $this.sub_view_id]( function() {\n\t\t\t\t$this.setEditView();\n\t\t\t} );\n\t\t} );\n\t\tthis.table_container.find( '#' + unique_id ).find( '.delete-icon' ).unbind( 'click' ).bind( 'click', function( e ) {\n\t\t\t$this['get' + $this.sub_view_id]( function() {\n\t\t\t\t$this.onDeleteClick();\n\t\t\t} );\n\t\t} );\n\t}\n\n\tinitOptions() {\n\t\tvar $this = this;\n\t\tvar args = {};\n\t\tvar filter_data = {};\n\t\tfilter_data.type_id = [this.qualification_type_id];\n\t\targs.filter_data = filter_data;\n\t\targs.filter_columns = {\n\t\t\t'id': true,\n\t\t\t'name': true\n\t\t};\n\t\tthis.qualification_api.getQualification( args, true, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tvar res = result.getResult();\n\t\t\t\tvar options = {};\n\t\t\t\tfor ( var i in res ) {\n\t\t\t\t\tif ( !res.hasOwnProperty( i ) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar row = res[i];\n\t\t\t\t\toptions[row.id] = $.i18n._( row.name );\n\t\t\t\t}\n\t\t\t\t$this.setSourceData( 'qualification_id', options, true );\n\t\t\t}\n\t\t} );\n\t}\n\n\tonSelectClick( e ) {\n\t\tvar elem = $( e.currentTarget ).parent().find( 'select' );\n\t\tif ( document.createEvent ) {\n\t\t\tvar e = document.createEvent( 'MouseEvents' );\n\t\t\te.initMouseEvent( 'mousedown', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null );\n\t\t\telem[0].dispatchEvent( e );\n\t\t} else if ( element.fireEvent ) {\n\t\t\telem[0].fireEvent( 'onmousedown' );\n\t\t}\n\t}\n\n\tsetEditView() {\n\t\tvar tpl = Global.loadWidget( 'views/portal/hr/my_profile/' + this.sub_view_id + 'SubEditView.html' );\n\t\tthis.setElement( _.template( tpl )( {\n\t\t\tavailable_fields: this.available_fields,\n\t\t\tenable_add_qualification: this.enable_add_qualification\n\t\t} ) );\n\t\tthis.initOptions();\n\t\tthis.registerDatePicker();\n\t\tthis.setCurrentEditRecordData();\n\t\tthis.openEditView();\n\t}\n\n\tonDeleteClick() {\n\t\tvar $this = this;\n\t\tIndexViewController.instance.router.showConfirmModal( Global.delete_confirm_message, {\n\t\t\ttitle: '',\n\t\t\tactions: [\n\t\t\t\t{ label: 'No', isClose: true },\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Yes', callBack: function( e ) {\n\t\t\t\t\t\t$this.closeConfirmModal();\n\t\t\t\t\t\tProgressBar.showOverlay();\n\t\t\t\t\t\t$this.api['delete' + $this.sub_view_id]( $this.model.id, {\n\t\t\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t\t\tProgressBar.closeOverlay();\n\t\t\t\t\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\t\t\t\t\t// $this.remove();\n\t\t\t\t\t\t\t\t\t// $this.table_container.find('#'+$this.unique_id).remove();\n\t\t\t\t\t\t\t\t\t$this._delegate.setSubViews( $this.sub_view_id, $this.display_columns );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t$this.showErrorAlert( result );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t} );\n\t}\n\n\tsetSourceData( field, source_data, set_empty ) {\n\t\tvar $this = this;\n\t\tvar field_selector = 'select[name=\"' + field + '\"]';\n\t\tif ( this.$( field_selector ) && this.$( field_selector )[0] ) {\n\t\t\tthis.$( field_selector ).empty();\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\tif ( !Global.isSet( this.model.get( field ) ) ) {\n\t\t\tthis.model.set( field, '' ); // initialize a value;\n\t\t}\n\t\tif ( _.size( source_data ) == 0 ) {\n\t\t\tset_empty = true;\n\t\t\tthis.model.set( field, '' );\n\t\t}\n\t\tswitch ( field ) {\n\t\t\tcase 'qualification_id':\n\t\t\t\tif ( this.enable_add_qualification ) {\n\t\t\t\t\tvar option_name;\n\t\t\t\t\tswitch ( this.sub_view_id ) {\n\t\t\t\t\t\tcase 'JobApplicantSkill':\n\t\t\t\t\t\t\toption_name = $.i18n._( 'Add New Skill' );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'JobApplicantEducation':\n\t\t\t\t\t\t\toption_name = $.i18n._( 'Add New Course' );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'JobApplicantLicense':\n\t\t\t\t\t\t\toption_name = $.i18n._( 'Add New Type' );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'JobApplicantLanguage':\n\t\t\t\t\t\t\toption_name = $.i18n._( 'Add New Language' );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'JobApplicantMembership':\n\t\t\t\t\t\t\toption_name = $.i18n._( 'Add New Membership' );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tset_empty = false;\n\t\t\t\t\tthis.$( field_selector ).append( $( '' ).prop( 'value', '' ).text( '-- ' + option_name + ' --' ) );\n\t\t\t\t}\n\t\t\t//break; -- Do not break here, it should fall through to default.\n\t\t\tdefault:\n\t\t\t\tif ( set_empty === true ) {\n\t\t\t\t\tthis.$( field_selector ).append( $( '' ).prop( 'value', '' ).text( '-- ' + $.i18n._( 'None' ) + ' --' ) );\n\t\t\t\t}\n\t\t\t\tif ( _.size( source_data ) > 0 ) {\n\t\t\t\t\t$.each( source_data, function( value, label ) {\n\t\t\t\t\t\t$this.$( field_selector ).append( $( '' ).prop( 'value', value ).text( label ) );\n\t\t\t\t\t\tif ( $this.model.get( field ) == value ) {\n\t\t\t\t\t\t\t$this.$( field_selector ).val( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\t$this.$( field_selector ).selectpicker();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tregisterDatePicker() {\n\t\tvar time_format = 'h:mm TT';\n\t\tvar format = 'dd-M-y';\n\t\tvar focus_out_timer;\n\t\tvar is_open = false;\n\t\t// When portal mode, no user preference.\n\t\t// if ( LocalCacheData.getLoginUserPreference() ) {\n\t\t// \tformat = LocalCacheData.getLoginUserPreference().date_format_1;\n\t\t// \ttime_format = LocalCacheData.getLoginUserPreference().time_format_1;\n\t\t// }\n\t\tvar day_name_min = [\n\t\t\t$.i18n._( 'Sun' ), $.i18n._( 'Mon' ), $.i18n._( 'Tue' ),\n\t\t\t$.i18n._( 'Wed' ), $.i18n._( 'Thu' ), $.i18n._( 'Fri' ), $.i18n._( 'Sat' )\n\t\t];\n\t\tvar month_name_short = [\n\t\t\t$.i18n._( 'Jan' ), $.i18n._( 'Feb' ),\n\t\t\t$.i18n._( 'Mar' ), $.i18n._( 'Apr' ), $.i18n._( 'May' ),\n\t\t\t$.i18n._( 'Jun' ), $.i18n._( 'Jul' ), $.i18n._( 'Aug' ),\n\t\t\t$.i18n._( 'Sep' ), $.i18n._( 'Oct' ), $.i18n._( 'Nov' ),\n\t\t\t$.i18n._( 'Dec' )\n\t\t];\n\t\tvar current_text = $.i18n._( 'Today' );\n\t\tvar close_text = $.i18n._( 'Close' );\n\t\tvar options = {\n\t\t\tshowTime: false,\n\t\t\tdateFormat: format,\n\t\t\tshowHour: false,\n\t\t\tshowMinute: false,\n\t\t\tchangeMonth: true,\n\t\t\tchangeYear: true,\n\t\t\tshowButtonPanel: true,\n\t\t\tduration: '',\n\t\t\tshowAnim: '',\n\t\t\tyearRange: '-100:+10',\n\t\t\tshowOn: '',\n\t\t\tdayNamesMin: day_name_min,\n\t\t\tcurrentText: current_text,\n\t\t\tmonthNamesShort: month_name_short,\n\t\t\tcloseText: close_text,\n\t\t\tbeforeShow: function() {\n\t\t\t},\n\t\t\tonSelect: function( dateText ) {\n\t\t\t\t$( this ).change();\n\t\t\t},\n\t\t\tonClose: function() {\n\t\t\t\tfocus_out_timer = setTimeout( function() {\n\t\t\t\t\tis_open = false;\n\t\t\t\t}, 100 );\n\t\t\t}\n\n\t\t};\n\t\tthis.$( 'input[type=\"text\"].datepicker' ).datepicker( options );\n\t\tthis.$( 'input[type=\"text\"].datepicker' ).attr( 'placeholder', 'dd-mmm-yy' );\n\t\tthis.$( 'input[type=\"text\"].datepicker' ).bind( 'mouseup', function() {\n\t\t\tif ( !is_open ) {\n\t\t\t\t$( this ).datepicker( 'show' );\n\t\t\t\tis_open = true;\n\t\t\t} else {\n\t\t\t\tis_open = false;\n\t\t\t\tif ( focus_out_timer ) {\n\t\t\t\t\tclearTimeout( focus_out_timer );\n\t\t\t\t\tfocus_out_timer = null;\n\t\t\t\t}\n\t\t\t}\n\t\t} ).next('.glyphicon').bind( 'mouseup', function() { $(this).prev().trigger( 'mouseup' ) } ); // this allows clicking on the calendar icon as well as the input box\n\t}\n\n\tsetCurrentEditRecordData() {\n\t\tvar self = this;\n\t\tvar unindexed_array = this.$( '.detail-form' ).serializeArray();\n\t\t$.map( unindexed_array, function( row, i ) {\n\t\t\tif ( !Global.isSet( self.model.get( row['name'] ) ) ) {\n\t\t\t\tself.model.set( row['name'], row['value'] );\n\t\t\t}\n\t\t} );\n\t\tif ( !this.model.has( 'qualification_id' ) ) {\n\t\t\tthis.model.set( 'qualification_id', false );\n\t\t}\n\t}\n\n\taddQualification() {\n\t\tvar $this = this;\n\t\tvar args = {};\n\t\targs.type_id = this.qualification_type_id;\n\t\tvar name = args.name = this.getQualificationWidget().val();\n\t\tthis.qualification_api.setQualification( args, {\n\t\t\tonResult: function( res ) {\n\t\t\t\tif ( !res.isValid() ) {\n\t\t\t\t\t$this.setErrorTips( res );\n\t\t\t\t} else {\n\t\t\t\t\t$this.$( 'select[name=\\'qualification_id\\']' ).selectpicker( 'destroy' );\n\t\t\t\t\tvar new_id = res.getResult();\n\t\t\t\t\t$( '