/** * lookup_4useform.js - Apply lookup for new features : Use Form */ // The condition of using feature [Use Form] function canUseFeatureLookupByUseForm() { return isVersion1_3(); } // The global variable about Lookup Manager var lookupManagerUtils = lookupManagerUtils || {}; var manageLookupActiveClass = ""; var isFileLargeSize = false; /** * Process initializing controls and binding events for [Use Form] */ function initLookup4UseForm() { // Init variable for saving the current selected project key, form key glbHashObject['useform.store_lookup_file_title'] = ''; glbHashObject['useform.current_project_key'] = ''; glbHashObject['useform.current_form_key'] = ''; // Only using this features from version 1.31 and later if (false == canUseFeatureLookupByUseForm()) { return; } if($('.uploadDialog4UseForm #gotoUseFormScreen').attr('initialization')) { return; } $('.uploadDialog4UseForm #gotoUseFormScreen').attr('initialization','true'); // Binding all related events // Button OK => Switch into the next screen (Show file and input Description) $('.uploadDialog4UseForm .lookUp_Ok4UseForm').on('click', function() { // Validate data input var cProjectVal = $('#cboProject4UseForm').val(); if (cProjectVal == '') { jAlert(msg_project_key_4_useform_empty); return; } var cFormVal = $('#cboFrom4UseForm').val(); if (cFormVal == '') { jAlert(msg_form_key_4_useform_empty); return; } // Advanced Data Manager if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { // Get list selected columns names + validation var selectColNames = $("#rndToListBox_Item4LKAdv option").toArray(); if (selectColNames.length <= 0) { jAlert(msg_select_field_for_advanced_lk_required); return; } $('.uploadDialog4UseForm .region4LKAdvanceUseForm').hide(); } //hideAllControlsInUseForm(); $('.lookUp_SaveTable4UseForm').show(); $('#useFormLookup,#lookupFile4UseForm,#lookupFile4UseForm *,#descriptionRegion4UseForm,.uploadDialog4UseForm .lookUp_Ok4UseForm').hide(); // Update label of [Lookup file] var projectText = $("#cboProject4UseForm option:selected").text(); var formText = $('#cboFrom4UseForm option:selected').text(); // Create new lookup file title in case of [Add New] or user change [ProjectKey], [FormKey] if (cProjectVal != glbHashObject['useform.current_project_key'] || cFormVal != glbHashObject['useform.current_form_key'] || glbHashObject['useform.store_lookup_file_title'] == '') { $('#lookupTableName4UseForm').text(projectText.replace(/[ -]/g, '_') + "_" + formText.replace(/[ -]/g, '_')); $('.lookupTblName4UseFormInpt').val(projectText.replace(/[ -]/g, '_') + "_" + formText.replace(/[ -]/g, '_')); // Add New // Advanced Data Manager // if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { // $('.lookupTblName4UseFormInpt').val(''); // } } else { $('#lookupTableName4UseForm').text(glbHashObject['useform.store_lookup_file_title']); $('.lookupTblName4UseFormInpt').val(glbHashObject['useform.store_lookup_file_title']); // Update mode // Advanced Data Manager // if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { // $('.lookupTblName4UseFormInpt').val(glbHashObject['useform.store_lookup_file_title']); // } } // Show the FileName and description $('#lookupFile4UseForm,#lookupTableNameTitle4UseForm,#lookupTableName4UseForm').show(); $('.lookUp_SaveTable4UseForm').show(); $('#descriptionRegion4UseForm').show(); // Advanced Data Manager // if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { $('#lookupFile4UseForm .break_line').css(CONST_CSS_KEY_DISPLAY, 'block'); $('#lookupTableName4UseFormInput').css(CONST_CSS_KEY_DISPLAY, 'inline'); $('#lookupTableName4UseForm').hide(); // Focus into first input field $('.lookupTblName4UseFormInpt').focus(); // } else { // $('#lookupTableName4UseFormInput').hide(); // $('#lookupTableName4UseForm').css(CONST_CSS_KEY_DISPLAY, 'inline'); // } }); // Button "Upload" [gotoUploadScreen] // $('.uploadDialog4UseForm #gotoUploadScreen').on('click', function() { // // // Hide the current dialog // $('.uploadDialog4UseForm').jqmHide(); // // // Show the upload dialog // //$('.uploadDialog').jqmShow(); // // $('.uploadDialog .lk_title').html(lbl_add_lookup_table); // $('.uploadDialog .lookup_upload .upload_multiple').empty(); // // // Trigger event for button upload (dummy event for preventing errors) // //$('#lookUp_Upload').trigger('click').trigger('mouseover'); // // }); // Fill data into Project form (only for the first time) // Get list of Projects and fill into Combobox // Button "Use Form" [gotoUseFormScreen] $('.uploadDialog4UseForm #gotoUseFormScreen').on('click', function(e, data) { waitForDataLoading(true); if (data == undefined || data.isFirstClicked !== false) { setTimeout(function() { $('.uploadDialog4UseForm #gotoUseFormScreen').trigger('click', [{ isFirstClicked: false }]); }, 1000); return; } // Hide all uneeded controls $('#lookupFile4UseForm, #descriptionRegion4UseForm, .lookUp_SaveTable4UseForm').hide(); $('#updateAutomaticallyId').prop('checked', false); $('#ignoreFieldsInTablesAndRepeatablesID').prop('checked', true); $('.showTableRepeatableFields').addClass('hideItem'); $('#showTableRepeatableFieldsInLookupFieldID').prop('checked', false); $('#showTableRepeatableFieldsInDestinationFieldsID').prop('checked', true); // $('#includeTableFieldsID').prop('checked', false); $('#lookupDescription4UseForm').val(''); $('.uploadDialog4UseForm #useFormLookup, .uploadDialog4UseForm .lookUp_Ok4UseForm').show(); $('#filterRecordsID').prop('checked', false); $('.lookupConditionFieldsList2').empty(); $('.filterRecordsContainer').addClass('hideItem'); $('.uploadDialog4UseForm .caseSensitive').prop('checked', false); refreshProjectListData(function(response, status) { $('#cboProject4UseForm')[0].selectedIndex = 0; cboProjectChange4UseForm($('#cboProject4UseForm').val()); }); // Advanced Data Manager if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { $('#updateAutomaticallyId').prop('checked', true); // $('#ignoreFieldsInTablesAndRepeatablesID').prop('checked', true); $('.uploadDialog4UseForm .updateAutomaticallyUseForm').hide(); $('.uploadDialog4UseForm .region4LKAdvanceUseForm').show(); } else { $('.uploadDialog4UseForm .region4LKAdvanceUseForm').hide(); $('.uploadDialog4UseForm .updateAutomaticallyUseForm').show(); } // Enabled all item in edit mode $('#cboProject4UseForm,#cboFrom4UseForm,#rndFromListBox_Item4LKAdv,#rndToListBox_Item4LKAdv').removeAttr('disabled'); if(authNS.currentUser.last_n_days_lookup) { $('.uploadDialog4UseForm .period_arrow, .uploadDialog4UseForm .period').removeClass(CONST_CSS_CLASS_HIDE_SESSION); } }); // The change event for select box "Project" $('#cboProject4UseForm').change(function(){ cboProjectChange4UseForm($('#cboProject4UseForm').val()); }); // Button [Save Table] $('.uploadDialog4UseForm .lookUp_SaveTable4UseForm').on('click', function() { var lookupTableName = $('#lookupTableName4UseForm').text(); // Advanced Data Manager // if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { // Get custom Lookup Table Name lookupTableName = $('.lookupTblName4UseFormInpt').val(); // Validate input value if (lookupTableName == '') { jAlert(msg_input_lookup_name_required, '', function() { $('.lookupTblName4UseFormInpt').focus(); }); return; } // } writeToLogInfo('lookupTableName :: ' + lookupTableName); var lookupData = {}; lookupData.UseFormFeature = CONST_VALUE_TRUE_STR; lookupData.Key = lookupRecordId; lookupData.TmpBlobKey = lookupBlobKey; lookupData.OldBlobKey = lookupOldBlob; lookupData.Action = lookupAction; lookupData.User = authNS.currentUser.Email; lookupData.TableName = lookupTableName; lookupData.Description = $('#lookupDescription4UseForm').val(); lookupData.isUseForm = true; lookupData.projectKey = $('#cboProject4UseForm').val(); lookupData.formKey = $('#cboFrom4UseForm').val(); lookupData.caseSensitive = $('.uploadDialog4UseForm .caseSensitive').prop('checked'); lookupData.isUpdateAutomatically = convertAttrCheckedToBoolean($('#updateAutomaticallyId').prop('checked')); lookupData.ignoreFieldsInTablesAndRepeatables = convertAttrCheckedToBoolean($('#ignoreFieldsInTablesAndRepeatablesID').prop('checked')); lookupData.showTableRepeatableFieldsInLookupField = convertAttrCheckedToBoolean($('#showTableRepeatableFieldsInLookupFieldID').prop('checked')); lookupData.showTableRepeatableFieldsInDestinationFields = convertAttrCheckedToBoolean($('#showTableRepeatableFieldsInDestinationFieldsID').prop('checked')); // lookupData.isIncludeTableFields = convertAttrCheckedToBoolean($('#includeTableFieldsID').prop('checked')); // Put the flag for deleting current data source lookup to server lookupData.IsDeleteCurrentDatasourceLookup = glbHashObject['is_delete_current_datasource_lookup']; // Advanced Data Manager if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { // Get list selected columns names + validation var selectColNames = $("#rndToListBox_Item4LKAdv option").toArray(); var selectColumnNames = []; for (var i = 0; i < selectColNames.length; i++) { var obj = new Object(); obj.name = selectColNames[i].text; obj.caption = obj.key; selectColumnNames.push(obj); } lookupData.selectColumnNames = selectColumnNames; } lookupData.filterRecords = convertAttrCheckedToBoolean($('#filterRecordsID').prop('checked')); lookupData.lookupConditionField = []; if(lookupData.filterRecords) { var conditions = $('.lookupConditionFieldsList2 li'); for(var i = 0; i < conditions.length; i++) { var condition = {}; condition.coundType = $(conditions[i]).find('.cboLookntrolsType select').val(); condition.coundFieldName = $(conditions[i]).find('.cboLookupConditionField').val(); condition.condOperator = $(conditions[i]).find('select.buildFormControlsType').val(); condition.coundValue = $(conditions[i]).find('input.otherAnswerLookupField').val(); lookupData.lookupConditionField[i] = condition; } //lookupData.lookupConditionField = []; } else { //lookupData.lookupConditionField = []; } // Hide the waiting progress waitForDataLoading(true); $.ajax({ url: '/dataview/lookupprocess', dataType: 'json', data: {action:'check_validate' ,Key:lookupRecordId}, type: 'GET', cache: false, complete: function() { }, success: function(response, status) { if(response && (!response.validate && response.orderOfFieldsInFormChanged)) { jAlert(msg_order_form_fields_changed); waitForDataLoading(false); return; } // Process creating DataSource for Lookup // First we will make sure that the old data will be clean in case of lookupData.IsDeleteCurrentDatasourceLookup == true processDeleteCurrentDatasourceLookup({ IsDeleteCurrentDatasourceLookup : true ,lookupMasterKey : lookupRecordId ,TmpBlobKey : lookupData.TmpBlobKey } , function(hasErrorMessage){ // Make next step (Process creating DataSource for Lookup) if (hasErrorMessage === false) { createDatasourceLookup4UseForm(lookupData); // Mark the flag that the Lookup Manager has been changed (for improving perfomance) isLookupManagerItemChange4IP = true; } }); }, error: function(request, status, error) { jAlert(msg_unknown_error); waitForDataLoading(false); } }); /************************************************************************** * THE FOLLOWING CODES WILL BE MOVE TO FUNCTION createDatasourceLookup4UseForm() **************************************************************************/ // waitForDataLoading(true); // // $.ajax({ // url: '/dataview/lookupprocess', // dataType: 'json', // type: 'Post', // data: JSON.stringify(lookupData), // cache: false, // complete: function() { // // This action will be processed when the creating DataSource timer is completed. // // Reference to function :: updateUploadingProgress4UseForm(); // //// $('.uploadDialog4UseForm').jqmHide(); //// $('#buildFormMenuOptions .manageLookupTable').trigger('click'); //// waitForDataLoading(false); // }, // success: function(response, status) // { // // If not finish transfering data, we will check status by request every 3s // // for checking the data source creating progress // if (response.finishTransfer == false) { // updateUploadingProgress4UseForm('refresh4useform', response.lkMstKey); // } else { // $('.uploadDialog4UseForm').jqmHide(); // $('#mnuMmanageLookupTable .manageLookupTable').trigger('click'); // waitForDataLoading(false); // } // }, // error: function(request, status, error) // { // jAlert(msg_unknown_error); // waitForDataLoading(false); // } // }); }); $('#lookup_html_area .associateFormsDialog .gotoListDataSource').on('click', function() { $('.associateFormsDialog').jqmHide(); // Apply show lookup GUI with filtering data by lookup type : Non-POD/POD/All showLookupDialogIncludingFilterData(); //$('.lookUpDialog').jqmShow(); // Restore the current scroll top of DataSourceManager dialog $('#lookUp_Content').scrollTop(glbHashObject['scrollTop_DataSourceManagerDialog']); }); $('#ignoreFieldsInTablesAndRepeatablesID').on('click', function() { if($(this).prop('checked')) { $('.showTableRepeatableFields').addClass('hideItem'); } else { $('.showTableRepeatableFields').removeClass('hideItem'); } if($('#showTableRepeatableFieldsInLookupFieldID').prop('checked')) { advancedDTM.refreshSelectFieldListLK(); } }); $('#showTableRepeatableFieldsInLookupFieldID').on('click', function() { advancedDTM.refreshSelectFieldListLK(); }); } function hideAllControlsInUseForm() { $('#useFormLookup,#lookupFile4UseForm,#lookupFile4UseForm *,#descriptionRegion4UseForm,.uploadDialog4UseForm .lookUp_Ok4UseForm,.uploadDialog4UseForm .lookUp_SaveTable4UseForm').hide(); } /** * Show the first screen for Lookup select * @returns {} */ function showTheFirstScreen4UseForm() { // Assign events for button Upload initLookupUploadLinkDirectly4Add(''); $('.uploadDialog4UseForm .lk_title, .uploadDialog .lk_title').html(lbl_add_lookup_table); $('.uploadDialog4UseForm #lookupTableName4UseFormInput').hide(); $('.uploadDialog4UseForm #lookupTableName4UseForm').show(); $('.uploadDialog4UseForm .region4LKAdvanceUseForm').hide(); $('.uploadDialog4UseForm .updateAutomaticallyUseForm').hide(); // Advanced Data Manager if (isVersion(VERSION_ADVANCED_DATA_MANAGER)) { if (advancedDTM.isAdvancedLookupGUI) { $('.uploadDialog4UseForm .lk_title, .uploadDialog .lk_title').html(lbl_add_advanced_lookup_table); } } // Hide all uneeded controls hideAllControlsInUseForm(); $('#lookupFile4UseForm, #gotoUploadScreen, #gotoUseFormScreen').show(); // Show the dialog $('.uploadDialog4UseForm').jqmShow(); // 0026696: [Suggestion] Should show Download Excel, Download CSV buttons at 'Update lookup' for Use form in case 'Update auto..' not check // Always hide button of [Download as Excel,Download as CSV] $('#useFormLookup .download4UseFormRegion').hide(); } /** * Loading the form select box when project changed * @param {} projectKey * @param {} frmKey * @returns {} */ function cboProjectChange4UseForm(currentProjectKey, currentFormKey) { waitForDataLoading(true); // Fix bug 0023218: Manage lookup table - Lookup datasource use form is mapping with wrong form if the specified form was unasssigned from project $.ajax({ url: '/homepage/homepage', dataType: 'json', type: 'GET', data: { //action : 'FRM' fnId : 'FRM' ,projectKey : currentProjectKey }, cache: false, async: false, complete: function() { waitForDataLoading(false); }, success: function(response, status) { $('#cboFrom4UseForm').empty(); $('#cboFrom4UseForm').append(response.CboFormData); // decode options html value var cboObj = document.getElementById('cboFrom4UseForm'); if (cboObj.options.length <= 0) { if ($('#cboProject4UseForm option').length <= 0 || $('#cboProject4UseForm').val() == null || $('#cboProject4UseForm').val() == '') { $('#cboFrom4UseForm').append(''); } else { $('#cboFrom4UseForm').append(''); } } // Fix bug 0023218: Manage lookup table - Lookup datasource use form is mapping with wrong form if the specified form was unasssigned from project // Get the first item of combobox [Form] var objFirstValue = $('#cboFrom4UseForm option:first'); var firstValue = objFirstValue.val(); var firstValueHTML = objFirstValue.html(); if (firstValue === undefined || firstValue === null || firstValue === '' || firstValue === firstValueHTML) { // Setting BLANK value into combobox objFirstValue.html('').val(''); } else { // Add BLANK combobox into top of [Forms] objFirstValue.before(''); } // Encode into HTML string (using in HTML code) for (var j = 0; j < cboObj.options.length; j++ ){ cboObj.options[j].text = HtmlDecode(cboObj.options[j].text); } var needTriggerFormChange = false; if (currentFormKey != undefined && currentFormKey != null) { $('#cboFrom4UseForm').val(currentFormKey); } else { // Focus on the first item (if needed) // Fix bug 0023714: Manage lookup table: Use Form - "Form" drop-down list doesn't display with default value ... var objFirstValueCheck = $('#cboFrom4UseForm option:first'); var firstValueCheck = objFirstValueCheck.val(); var firstValueHTMLCheck = objFirstValueCheck.html(); if (firstValueCheck === '' && firstValueHTMLCheck === '') { // Focus on the second item (if exists) try { $('#cboFrom4UseForm')[0].selectedIndex = 1; } catch (e) {} } needTriggerFormChange = true; } // Advanced Data Manager if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { $('.uploadDialog4UseForm .region4LKAdvanceUseForm').show(); $('.uploadDialog4UseForm .updateAutomaticallyUseForm').hide(); $('#cboFrom4UseForm').trigger('change'); // Load current selected fields advancedDTM.loadCurrentUpdColumnsName(); } else if(needTriggerFormChange) { $('#cboFrom4UseForm').trigger('change'); } }, error: function(request, status, error) { jAlert(msg_unknown_error); waitForDataLoading(false); } }); } /** * Refresh the project list data in select box */ function refreshProjectListData(functionComplete) { waitForDataLoading(true); $.ajax({ url: '/homepage/homepage', dataType: 'json', type: 'POST', data: { action : 'PRJ' }, cache: false, async: false, complete: function() { waitForDataLoading(false); if (functionComplete != undefined && functionComplete != null) { functionComplete.call(this); } }, success: function(response, status) { $('#cboProject4UseForm').empty().append(response.CboProjectData); // decode options html value var cboObj = document.getElementById('cboProject4UseForm'); if (cboObj.options.length <= 0) { $('#cboProject4UseForm').append(''); } else { for (var j = 0; j < cboObj.options.length; j++ ){ cboObj.options[j].text = HtmlDecode(cboObj.options[j].text); } } }, error: function(request, status, error) { jAlert(msg_unknown_error); waitForDataLoading(false); } }); } /** * Process timer for checking status of creating DataSource in [UseForm] * @param {} _action * @param {} lkMstKey * @returns {} */ function updateUploadingProgress4UseForm(_action, lkMstKey, actionAddUpdateDelete){ // set time out for updating progress every 3s setTimeout(function() { $.ajax({ url: '/dataview/lookup' +'?action=' + _action +'&unitKey=DUMMYVALUE' +'&lkMstKey=' + lkMstKey, dataType: 'json', type: 'Get', cache: false, complete: function() { }, success: function(response, status) { var finishTransfer = response.finishTransfer; if (finishTransfer == false) { // keep updating progress updateUploadingProgress4UseForm(_action, lkMstKey, actionAddUpdateDelete); } // uploading is completed else{ var resLKTableName = ''; if(undefined != response && undefined != response['lookup_table_name_new']) { resLKTableName = response['lookup_table_name_new']; } var message = ''; if(actionAddUpdateDelete == 'edit') { message = msg_custom_template_success.replace("{Template}", '"' + resLKTableName + '" lookup') .replace("{action}", "updated");//msg_lookup_update_successful; } else { message = msg_custom_template_success.replace("{Template}", '"' + resLKTableName + '" lookup') .replace("{action}", "added");//msg_lookup_add_successful; } jAlert(message, "", function() { $('.uploadDialog4UseForm').jqmHide(); // Process Search/Filter for lookup manager // (Do not set default value when showing Lookup Manager list) // Advanced Data Manager reloadLookupDSManager(); }); waitForDataLoading(false); } }, error: function(request, status, error) { //jAlert(msg_lookup_failed); jAlert(msg_unknown_error); waitForDataLoading(false); } }); }, 3000); } /** * Process the ScrollBar for Add Lookup Table dialog */ function processScrollBar4LookupTables() { // Process the ScrollBar when the items are over 6. if ($('.uploadDialog #list_files_lookup [id^=new_part]:visible').length > 6) { $('.uploadDialog #list_files_lookup').css('overflow-y', 'auto'); // Scroll into the bottom of Upload Lookup Tables (for viewing the [Append more file] button) $(".uploadDialog #list_files_lookup").scrollTop($(".uploadDialog #list_files_lookup")[0].scrollHeight); } else { $('.uploadDialog #list_files_lookup').css('overflow-y', 'hidden'); // Scroll into the top of Upload Lookup Tables $(".uploadDialog #list_files_lookup").scrollTop(0); } // Validate the data files upload var numberMainPart = $('.uploadDialog #lookup_table_name:visible').length; var numberOfNewParts = $('.uploadDialog [id^=new_part_]:visible').length; var isEmptyAllValue = CONST_VALUE_FALSE_STR; if ( (numberMainPart + numberOfNewParts) <= 1 ){ // delete all parts) isEmptyAllValue = CONST_VALUE_TRUE_STR; } // With all emtpy value, we will reset the button content // from ['Append another file'] into [CONST_VALUE_UPLOAD] if (isEmptyAllValue == CONST_VALUE_TRUE_STR) { var lastNewPart = $('.uploadDialog [id^=new_part_]:visible:last'); if (lastNewPart.length > 0) { lastNewPart.find('input[type="button"]').val(CONST_VALUE_UPLOAD).removeClass(CONST_CLASS_REPLACE_BTN); //$('.uploadDialog #lookUp_Upload').show(); } } // Send signal into server for using in update DataSource Lookup sendSignal4UpdateDataSourceToServer (isEmptyAllValue); } /** * Send Signal every update data source from client to Server * @param {} isEmptyAllValue * @returns {} */ function sendSignal4UpdateDataSourceToServer(isEmptyAllValue) { // Sending signal into server var strDeleteMainDS = glbHashObject['is_delete_current_datasource_lookup']; if (strDeleteMainDS == undefined || strDeleteMainDS == null) { strDeleteMainDS = CONST_VALUE_FALSE_STR; } var strLookupBlobKey = glbHashObject['current_lookup_blob_key_for_main_datasource']; if (strLookupBlobKey == undefined || strLookupBlobKey == null) { strLookupBlobKey = ''; } var numberMainPart = $('.uploadDialog #lookup_table_name:visible').length; var numberOfNewParts = $('.uploadDialog [id^=new_part_]:visible').length; waitForDataLoading(true); $.ajax({ url: '/dataview/lookup', dataType: 'json', data : { action : 'flag_data_4_update_lookup_datasource' ,isAllEmptyLookupDataSource4Update : isEmptyAllValue ,isDeleteMainDS : strDeleteMainDS ,lookupBlobKey : strLookupBlobKey ,numberMainPart : numberMainPart ,numberOfNewParts : numberOfNewParts }, type: 'Get', cache: false, complete: function() { // Wait 1.5s for assign all events AjaxUpload complete. setTimeout(function() { waitForDataLoading(false); var uploadCtr = '#gotoUploadScreen'; $(uploadCtr).click(function(){ var resButtonFile = $('INPUT[NAME="resourcesButtonFile"]'); if (resButtonFile != undefined && resButtonFile.is(':visible') || resButtonFile.is(':hidden')) { resButtonFile.show().click(); } }); }, 1500); }, error: function(request, status, error) { } }); } /** * Init Lookup Upload link for Update Label. * This function is ripped from function * var initLookupUploadLink = function(ctrId, _oldBlob) in file auth.js */ function initLookupUploadLink4UpdateLabel(jQueryControl, updateFileBlobKey, isUpdateMainDataSourceLookup) { jQueryControl.off('click').on('click', function(){ // Setting value for the flag [isUpdateMainDataSourceLookup] if (isUpdateMainDataSourceLookup == undefined || isUpdateMainDataSourceLookup == null) { isUpdateMainDataSourceLookup = false; } var oldBlobParam = ''; if(lookupOldBlob != '') oldBlobParam = '&oldLKTableKey=' + lookupRecordId; new AjaxUpload(jQueryControl, { action: '/dataview/lookup?resourcesData=1' +'&actionType=update' + '&blobKey=' + lookupBlobKey + '&isUpdateFile=true' + '&updateFileBlobKey=' + updateFileBlobKey + '&isUpdateMainDS=' + isUpdateMainDataSourceLookup + oldBlobParam, name: 'resourcesButtonFile', responseType: 'json', onSubmit: function(file, ext){ waitForDataLoading(true); // check upload file extension if (! (ext && /^(csv|xlt|xls|xlsx|xlsm|xltx|xltm)$/.test(ext))){ jAlert(msg_invalid_up_file_custom); waitForDataLoading(false); return false; } // check upload file size (with Chrome and Safari) // Get browser name information //var browserNameGlobal = getBrowserInfo(); //if (browserNameGlobal == 'chrome' || browserNameGlobal == 'safari') { var dataSize = getControlUploadSize(this); var isXLSX = ext && /^(xlsx|xlsm|xltx|xltm)$/.test(ext); if((isXLSX && dataSize <= LOOKUP_DS_SMALL_XLSX_MAX_SIZE) || (!isXLSX &&dataSize <= LOOKUP_DS_MAX_SIZE)) { isFileLargeSize = false; return true; } isFileLargeSize = true; var warMsg = !isXLSX ? msg_lookup_warning_file_size_larger_limit : msg_lookup_warning_xlsx_file_size_larger_limit; jAlert(warMsg, lbl_warning, function(result){ if(!result) return false; if ((ext && /^(csv)$/.test(ext)) && dataSize > LOOKUP_DS_CSV_MAX_SIZE) { jAlert(msg_lookup_csv_file_size_limit); waitForDataLoading(false); return false; } if ((ext && /^(xlt|xls)$/.test(ext)) && dataSize > LOOKUP_DS_XLS_MAX_SIZE) { jAlert(msg_lookup_xls_file_size_limit); waitForDataLoading(false); return false; } if ((ext && /^(xlsx|xlsm|xltx|xltm)$/.test(ext)) && dataSize > LOOKUP_DS_XLSX_MAX_SIZE) { jAlert(msg_lookup_xlsx_file_size_limit); waitForDataLoading(false); return false; } }); //} }, onError: function(error) { jAlert(msg_error_upload_lookup_network_connection); waitForDataLoading(false); }, onComplete: function(file, response){ if(response.errorcode == 924 // check max row number - 15000 || response.errorcode == 925){ // check column jAlert(response.error); waitForDataLoading(false); return; } // Handle for case over upload file size limit var signalLimit = response.max_file_size_over_limit; if (signalLimit != undefined && signalLimit != null && signalLimit == true) { //jAlert(msg_lookup_file_size_limit); var ext = response.ext.toLowerCase(); if (ext == 'csv' && dataSize > LOOKUP_DS_CSV_MAX_SIZE) { jAlert(msg_lookup_csv_file_size_limit); } if ((ext == 'xlt' || ext == 'xls') && dataSize > LOOKUP_DS_XLS_MAX_SIZE) { jAlert(msg_lookup_xls_file_size_limit); } if ((ext == 'xlsx' || ext == 'xlsm' || ext == 'xltx' || ext == 'xltm') && dataSize > LOOKUP_DS_XLSX_MAX_SIZE) { jAlert(msg_lookup_xlsx_file_size_limit); } waitForDataLoading(false); return; } if(response.UnitKey == ''){ jAlert(msg_lookup_failed); waitForDataLoading(false); return; } if (!isFileLargeSize) { lookupUploaded = true; lookupBlobKey = response.UnitKey; lookupTotalRow = response.TotalRows; var deletePartKey = response.PartKey; if (response.Headers != '') { lookupTableObj.Headers = response.Headers; } // Setting new upload file name, binding new event for Delete button var jQueryParent = jQueryControl.parent(); if (jQueryParent[0].id == 'list_files_lookup') { jQueryParent.find('#lookup_table_name').text(file); // Refresh the AjaxUpload for the first empty button (if exists) var theFirstPart = $('.uploadDialog [id^=new_part_0]:visible').length; if (theFirstPart > 0) { $('#new_upload_0').click(function() { initLookupUploadLink('0'); }).trigger('click'); } } else { jQueryParent.find('.file_name_label').text(file); // Binding new event for button [Delete] var currentAttribute = jQueryParent.find('.delete_button_label')[0].getAttribute('onclick'); //writeToLogInfo('currentAttribute :: ' + currentAttribute); currentAttribute = currentAttribute.replace(/,'.+$/i, ",'" + deletePartKey + "')"); //writeToLogInfo('currentAttribute :: After :: ' + currentAttribute); jQueryParent.find('.delete_button_label')[0].setAttribute('onclick', currentAttribute); } // Update the flag for deleting current data source lookup (in case of delete the first line) if (response.IsUpdateMainDataSourceLookup != undefined && response.IsUpdateMainDataSourceLookup != null && response.IsUpdateMainDataSourceLookup == true) { // We are in Update Mode of Main DataSource // Update the partKey value for main DataSource // Save it into the global variable for using later in function // sendSignal4UpdateDataSourceToServer glbHashObject['current_lookup_blob_key_for_main_datasource'] = response.UnitKey; } // Init the AjaxUpload for [Update] main DataSource (ONLY in UPDATE MODE) if (lookupAction == 'edit') { // Assign AjaxUpload into button Update var jQueryControl1 = $('#lookUp_Update'); initLookupUploadLink4UpdateLabel(jQueryControl1, 'lookUp_Update', true); } waitForDataLoading(false); return; } checkFinishSaveLookupTemp('', file, 'check_fish_save_temp_lookup', response.UnitKey, 'update'); } }); }).trigger('click'); } /** * Create datasource lookup (for UseForm) * @param {} lookupData * @returns {} */ function createDatasourceLookup4UseForm(lookupData) { waitForDataLoading(true); // Advanced Data Manager lookupData.isAdvancedLookupGUI = false; if (isVersion(VERSION_ADVANCED_DATA_MANAGER)) { if (advancedDTM.isAdvancedLookupGUI) { lookupData.isAdvancedLookupGUI = true; } } $.ajax({ url: '/dataview/lookupprocess', dataType: 'json', type: 'Post', data: JSON.stringify(lookupData), cache: false, complete: function() { // This action will be processed when the creating DataSource timer is completed. // Reference to function :: updateUploadingProgress4UseForm(); }, success: function(response, status) { // If not finish transfering data, we will check status by request every 3s // for checking the data source creating progress if (response.finishTransfer == false) { updateUploadingProgress4UseForm('refresh4useform', response.lkMstKey, lookupData.Action); } else { var resLKTableName = ''; if(undefined != response && undefined != response['lookup_table_name_new']) { resLKTableName = response['lookup_table_name_new']; } var message = ''; if(lookupData.Action == 'edit') { message = msg_custom_template_success.replace("{Template}", '"' + resLKTableName + '" lookup') .replace("{action}", "updated");//msg_lookup_update_successful;//msg_lookup_update_successful; } else { message = msg_custom_template_success.replace("{Template}", '"' + resLKTableName + '" lookup') .replace("{action}", "added");//msg_lookup_add_successful; } jAlert(message, "", function() { $('.uploadDialog4UseForm').jqmHide(); // Process Search/Filter for lookup manager // (Do not set default value when showing Lookup Manager list) // Advanced Data Manager reloadLookupDSManager(); }); waitForDataLoading(false); } }, error: function(request, status, error) { if (getStatus(request) == 993){ jAlert(msg_too_many_index_properties_or_entity_is_too_big); // } else if (getStatus(request) == 999){ // jAlert(msg_no_lookup_field); } else { jAlert(msg_unknown_error); } waitForDataLoading(false); } }); } /** * Process center screen and make scroll bar for LookupManager when the screen resolution is small * @returns {} */ function makeCenterAndScroll4LookupManager() { var winWidth = screen.width; //$(window).width(); var winHeight = screen.height; //$(window).height(); //alert('width : ' + screen.width + ' -- height : ' + screen.height); var jQueryLookup = $('#lookUp_Content'); if (winWidth <= 800) { // Put scrollbar into table jQueryLookup.css('max-width', '790px'); } var browserNameGlobal = getBrowserInfo(); if (winHeight <= 600) { $('.lookUpDialog').css('top', '5px'); if (browserNameGlobal == 'chrome') { jQueryLookup.css('max-height', '290px'); } else if (browserNameGlobal == 'ie') { jQueryLookup.css('max-height', '210px'); } else { jQueryLookup.css('max-height', '250px'); } } else if (winHeight <= 768) { if (browserNameGlobal == 'ie') { jQueryLookup.css('max-height', '320px'); } else { jQueryLookup.css('max-height', '350px'); } } // Make Layout of LookupManager in the center $('.lookUpDialog').centerRegion4Private($(window).height(), winWidth, $(window).scrollTop(), $(window).scrollLeft()); } /** * Process Update CSV DataLine in every Entity records using in DataSource * @param {} inputCondition * @param {} completeFunction * @returns {} */ function processUpdateCSVDataLine(_first, lookupMasterKey, completeFunction) { waitForDataLoading(true); var hasMoreRecords = false; var hasErrorMessage = false; if(_first){ posisionIndex = 0; } $.ajax({ url: '/dataview/lookupprocess', dataType: 'json', data: { action : 'update_csv_data_4datasources' ,offset : posisionIndex ,key : lookupMasterKey }, type: 'GET', cache: false, //async: false, complete: function() { writeToLogInfo('hasMoreRecords :: ' + hasMoreRecords); if (hasMoreRecords === true) { processUpdateCSVDataLine(false, lookupMasterKey , completeFunction); } else { if (completeFunction != undefined && completeFunction != null) { completeFunction.call(this, hasErrorMessage); } else { // Hide the waiting progress waitForDataLoading(false); } } }, success: function(response, status) { hasMoreRecords = response.hasMoreRecords; posisionIndex = response.offset; writeToLogInfo('posisionIndex : ' + posisionIndex); }, error: function(request, status, error) { jAlert(msg_unknown_error); waitForDataLoading(false); hasErrorMessage = true; } }); } /** * Initialize Upload Directly when we are in Add New Lookup * @param {} ctrId * @returns {} */ var initLookupUploadLinkDirectly4Add = function(ctrId){ var uploadCtr = '#gotoUploadScreen'; $(uploadCtr).off().off(); var oldBlobParam = ''; new AjaxUpload($(uploadCtr), { action: '/dataview/lookup?resourcesData=1' + '&blobKey=' + '&actionType=add', name: 'resourcesButtonFile', responseType: 'json', onSubmit: function(file, ext){ if (file === undefined || file === null) { jAlert(msg_unknown_error); waitForDataLoading(false); return; } waitForDataLoading(true); // check upload file extension if (! (ext && /^(csv|xlt|xls|xlsx|xlsm|xltx|xltm)$/.test(ext))){ jAlert(msg_invalid_up_file_custom); waitForDataLoading(false); return false; } // check upload file size (with Chrome and Safari) // Get browser name information //var browserNameGlobal = getBrowserInfo(); //if (browserNameGlobal == 'chrome' || browserNameGlobal == 'safari') { var dataSize = getControlUploadSize(this); var isXLSX = ext && /^(xlsx|xlsm|xltx|xltm)$/.test(ext); if((isXLSX && dataSize <= LOOKUP_DS_SMALL_XLSX_MAX_SIZE) || (!isXLSX &&dataSize <= LOOKUP_DS_MAX_SIZE)) { isFileLargeSize = false; return true; } isFileLargeSize = true; var warMsg = !isXLSX ? msg_lookup_warning_file_size_larger_limit : msg_lookup_warning_xlsx_file_size_larger_limit; jAlert(warMsg, lbl_warning, function(result){ if(!result) return false; if ((ext && /^(csv)$/.test(ext)) && dataSize > LOOKUP_DS_CSV_MAX_SIZE) { jAlert(msg_lookup_csv_file_size_limit); waitForDataLoading(false); return false; } if ((ext && /^(xlt|xls)$/.test(ext)) && dataSize > LOOKUP_DS_XLS_MAX_SIZE) { jAlert(msg_lookup_xls_file_size_limit); waitForDataLoading(false); return false; } if ((ext && /^(xlsx|xlsm|xltx|xltm)$/.test(ext)) && dataSize > LOOKUP_DS_XLSX_MAX_SIZE) { jAlert(msg_lookup_xlsx_file_size_limit); waitForDataLoading(false); return false; } }); //} }, onError: function(error) { writeToLogInfo('error occur : ' + error); // Process when error occur (Network Connections) jAlert(msg_error_upload_lookup_network_connection); waitForDataLoading(false); }, onComplete: function(file, response){ if(!authNS || !authNS.currentUser || !authNS.currentUser.pod){ $('.line_content.lookup_options_pod').hide(); } // Empty region upload datasource. $('.uploadDialog .lookup_upload .upload_multiple').empty(); // We can't upload file if (response === undefined || response === null) { jAlert(msg_unknown_error); waitForDataLoading(false); return; } if (response.errorcode == 924 // check max row number - 15000 || response.errorcode == 925) { // check column jAlert(response.error); waitForDataLoading(false); return; } // Handle for case over upload file size limit var signalLimit = response.max_file_size_over_limit; if (signalLimit != undefined && signalLimit != null && signalLimit == true) { jAlert(msg_lookup_csv_file_size_limit); waitForDataLoading(false); return; } if (response.UnitKey == '') { jAlert(msg_lookup_failed); waitForDataLoading(false); return; } if (!isFileLargeSize) { finishUploadLookup(ctrId, file, response); return; } checkFinishSaveLookupTemp(ctrId, file, 'check_fish_save_temp_lookup', response.UnitKey, 'add'); } }); } function finishUploadLookup(ctrId, file, response, actionType) { lookupUploaded = true; lookupBlobKey = response.UnitKey; lookupTotalRow = response.TotalRows; var deletePartKey = response.PartKey; if (response.Headers != '') lookupTableObj.Headers = response.Headers; // re-initialize html value if (ctrId == '') { document.getElementById('lookup_table_name').innerHTML = file; document.getElementById('lookup_table_name').style.display = "inline-block"; document.getElementById('lookup_table_name').removeAttribute('style'); document.getElementById('lookUp_Upload').style.display = CONST_VALUE_NONE; document.getElementById('lookUp_Delete').setAttribute("onclick", 'deleteLookupContent(\'\',\'' + deletePartKey + '\')'); document.getElementById('lookUp_Delete').style.display = "inline-block"; // Show lookup_Update $('#lookUp_Update').show(); var jQueryControl = $('#lookUp_Update'); // Assign AjaxUpload into button Update if (lookupAction == 'edit') { initLookupUploadLink4UpdateLabel(jQueryControl, 'lookUp_Update', true); } else { initLookupUploadLink4UpdateLabel(jQueryControl, deletePartKey); } } else { var curObj = $('#new_part_' + ctrId); curObj.find('.file_name_label').html(file); curObj.find('.upload_button_label').hide(); curObj.find('.update_button_label,.delete_button_label').show(); curObj.find('.delete_button_label')[0].setAttribute('onclick', "deleteLookupContent('" + ctrId + "','" + deletePartKey + "')"); //curObj.childNodes[4].setAttribute('onclick', 'deleteLookupContent(\''+ ctrId +'\',\''+ deletePartKey +'\')'); // Update content for Update Button var jQueryControl = curObj.find('.update_button_label'); // Assign AjaxUpload into button Update initLookupUploadLink4UpdateLabel(jQueryControl, deletePartKey); } // append new upload file html var multiple_content = $('.uploadDialog .lookup_upload .upload_multiple'); var newId = '' + multiple_content[0].childNodes.length; var newPartContent = ''; newPartContent += '
'; newPartContent += ' '; //newPartContent += '' + lbl_append_another_file + ''; if (actionType != 'update') { newPartContent += ''; //onclick="initLookupUploadLink(\''+ newId +'\''+ oldBlobParam +')" } newPartContent += ''; newPartContent += ' 

'; newPartContent += '
'; writeToLogInfo('new part created : ' + 'new_part_ ' + newId); multiple_content.append(newPartContent); // Init upload for button [Append to new datasource] initLookupUploadLink(newId); // Process the ScrollBar for Add Lookup Table dialog processScrollBar4LookupTables(); // Show screen upload // Hide the current dialog $('.uploadDialog4UseForm').jqmHide(); // Check file name for showing option []Using lookup for POD // Show option []Using lookup for POD // The file name should have the pattern : // // _ var mbNumber = ''; var dateOfPOD = ''; var indexOfSplitChar = file.indexOf('_'); if (indexOfSplitChar > 0) { mbNumber = file.substring(0, indexOfSplitChar); dateOfPOD = file.substring(indexOfSplitChar + 1, file.length); } else { mbNumber = file; } // Process POD in Lookup Upload File if (isVersion(VERSION_POD_WIDGET)) { if (!authNS || !authNS.currentUser || !authNS.currentUser.pod) { $('.line_content.lookup_options_pod').hide(); } else { // Show the flag []Using lookup for POD $('.line_content.lookup_options_pod').show(); $('#lookup_options_pod_id').removeAttr('disabled'); // Setting default value (unchecked) for POD $('#lookup_options_pod_id')[0].checked = false; } } // Show the upload dialog $('.uploadDialog').jqmShow(); waitForDataLoading(false); } /** * Process view information of Associate Forms for current datasource * @returns {} */ function viewAssociateForms4DataSource(rowIndex) { var curLKTable = glbHashObject['lookup_data_store_from_server'][rowIndex]; // Fill data into destination $('#associateFormsTblName').text(curLKTable.TableName); $('#associateFormsColNames').text(curLKTable.ColumnsName); $('#associateFormsDescription').text(curLKTable.Description); // Save row index for using later $('#associateFormsRowIndex').val(rowIndex); // Request to server for getting list form waitForDataLoading(true); $.ajax({ url: '/dataview/lookupprocess', dataType: 'json', type: 'GET', data: { action : 'get_associate_forms' ,datasourceKey : curLKTable.Key }, cache: false, complete: function() { waitForDataLoading(false); }, success: function(response, status) { // Check result value if (response.listFormsDataSource === undefined) { jAlert(msg_unknown_error); return; } var listFormsDataSource = response.listFormsDataSource; // Fill data into GUI var builder = new Array(); for (var i = 0; i < listFormsDataSource.length; i++) { var item = listFormsDataSource[i]; builder.push('

' + HtmlEncode4Website(item['name']) + '

'); } $('#associateFormsRegion').html(builder.join('')); $('.lookUpDialog').jqmHide(); // Save the current scroll top of DataSourceManager dialog glbHashObject['scrollTop_DataSourceManagerDialog'] = $('#lookUp_Content').scrollTop(); $('.associateFormsDialog').jqmShow(); }, error: function(request, status, error) { jAlert(msg_unknown_error); waitForDataLoading(false); } }); } function reloadLookupDSManager() { // Lookup manager - Build form if($('.lookup_manager').html() == '') { if (isVersion(VERSION_ADVANCED_DATA_MANAGER) && advancedDTM.isAdvancedLookupGUI) { $('#mnuMmanageLookupTable .manageLookupTable').trigger('click', [true, true]); } else { $('#mnuMmanageLookupTable .manageLookupTable').trigger('click', true); } } // Lookup manager - View data (CO-2631) else{ showLookupManagerViewdata(); } } /** * Process search filter (by input value) */ lookupManagerUtils.processSearchFilter = function(active) { var sContent = $('.lookUpDialog .lookupFilterContent').val().trim().toLowerCase(); // Get current value of Lookup table type: var currentSel = $('#selectLookupTableTypeId').val(); var objListRows = $('#lookup_Table tbody tr'); // Show all items objListRows.show(); // Clear all backgrounds objListRows.removeClass('odd').removeClass('even'); // Do not process with empty row if (objListRows.length === 1) { var objCellCnt = $(objListRows[0]).find('.col_0').text(); if (objCellCnt == '') { // Do nothing because the LK empty writeToLogInfoRequired('Do not change because the lookup empty'); return; } } // Browse all rows var showIndex = 0; var isVersionPOD = false; if (isVersion(VERSION_POD_WIDGET)) { isVersionPOD = true; } // Process Search/Filter for lookup manager var isVersionFilterLookup = false; if (isVersion(VERSION_SEARCH_FILTER_LOOKUP_MANAGER)) { isVersionFilterLookup = true; } for (var i = 0; i < objListRows.length; i++) { // Get current POD status var itemRow = $(objListRows[i]); var isNeedHideRow = false; // CO-2631 if(active){ var activeFlg = itemRow.find('.lookup_active').prop('checked'); if((active === 'active' && !activeFlg) || (active === 'inactive' && activeFlg)){ isNeedHideRow = true; } } else{ // Filter by POD, if needed if (isVersionPOD) { if (currentSel === LOOKUP_TABLE_TYPE_FILTER_VALUE_NON_POD && itemRow.hasClass('isUsing4POD') ) { // Hide row isNeedHideRow = true; } else if (currentSel === LOOKUP_TABLE_TYPE_FILTER_VALUE_POD_ONLY & !itemRow.hasClass('isUsing4POD')) { // Hide row isNeedHideRow = true; } } // Filter by Search content if (isVersionFilterLookup) { var itemCnt = itemRow.find('.lookup_table_name').text().toLowerCase(); if (itemCnt.indexOf(sContent) < 0) { // Not found matching search table name isNeedHideRow = true; } } } // Process when we need hide current row if (isNeedHideRow) { itemRow.hide(); continue; } // Show current row itemRow.show(); showIndex++; if (showIndex % 2 !== 0) { itemRow.addClass('odd'); } else { itemRow.addClass('even'); } } } /** * Process delete selected items in Lookup Manager GUI */ lookupManagerUtils.btnClickDeleteAllSelected = function () { console.log('Click Delete All Selected'); // Check if there's having any selected items. var items = $('#lookUp_Content .delete_lookup_checkbox:checked'); if (items.length <= 0) { jAlert(msg_select_lookup_items_del); return; } // Ask user for being sure to delete items jConfirm(msg_confirm_to_delete_lookup_items, '', function(result) { if(!result) return false; // Get list check items var items = $('#lookUp_Content .delete_lookup_checkbox:checked'); var listItems = []; for (var i = 0; i < items.length; i++) { // Get current lookup id var id = $(items[i]).closest('tr').attr('id'); listItems.push(id); console.log('id : ' + id); } waitForDataLoading(true); $.ajax({ url: '/dataview/lookup', dataType: 'json', type: 'POST', data: { action : 'delete_selected_lookups' ,listItems : JSON.stringify(listItems) }, cache: false, complete: function() { waitForDataLoading(false); }, success: function(response, status) { if (response.status === true) { // Reload the manager screen (with getting new refresh data from server) // Delay 5s with localhost // Reload the manager screen (with getting new refresh data from server) //$('.lookUp_Close').trigger('click'); // Process Search/Filter for lookup manager // (Do not set default value when showing Lookup Manager list) // Advanced Data Manager reloadLookupDSManager(); return; } // Notice error jAlert(msg_error_in_delete_lookup_items); }, error: function(request, status, error) { jAlert(msg_unknown_error); } }); }); } $('#filterRecordsID').on('change', function() { if($(this).prop('checked')) { $('.filterRecordsContainer').removeClass('hideItem'); if('' == jQuery.trim($('.lookupConditionFieldsList2').html())) { //addCondition(); //$('.lookupConditionFieldsList2 #condition_cboLookupJoinCondition1').addClass('hideItem'); //$('.lookupConditionFieldsList2 li:last .removeConditionField').addClass('hideItem'); //advancedDTM.refreshSelectFieldListLK(); addFirstConditionWithLoadField(); } } else { $('.filterRecordsContainer').addClass('hideItem'); } }); $('.addlookupConditionField').on('click', function() { addCondition(); }); addFirstCondition = function() { $('.lookupConditionFieldsList2').empty(); addCondition(); $('.lookupConditionFieldsList2 #condition_cboLookupJoinCondition1').addClass('hideItem'); $('.lookupConditionFieldsList2 li:last .removeConditionField').addClass('hideItem'); } addFirstConditionWithLoadField = function() { addFirstCondition(); advancedDTM.refreshSelectFieldListLK(); } addCondition = function(lookupCondition) { $('.lookupConditionFieldsList2').append($('.lookupConditionFieldsTemplate li').clone()); if(lookupCondition) { $('.lookupConditionFieldsList2 li:last .cboLookntrolsType select').val(lookupCondition['coundType']); $('.lookupConditionFieldsList2 li:last .cboLookupConditionField').val(lookupCondition['coundFieldName']); $('.lookupConditionFieldsList2 li:last select.buildFormControlsType').val(lookupCondition['condOperator']); $('.lookupConditionFieldsList2 li:last input.otherAnswerLookupField').val(lookupCondition['coundValue']); if('is_empty' == lookupCondition['condOperator'] || 'not_is_empty' == lookupCondition['condOperator']) { $('.lookupConditionFieldsList2 li:last .otherAnswerLookupFieldContainer').addClass('hideItem'); } } $('.lookupConditionFieldsList2 li:last .removeConditionField').on('click', function() { $(this).parents('li').remove(); }); $('.lookupConditionFieldsList2 li:last select.buildFormControlsType').on('change', function() { if('is_empty' == $(this).val() || 'not_is_empty' == $(this).val()) { $(this).parents('li').find('.otherAnswerLookupFieldContainer').addClass('hideItem'); } else { $(this).parents('li').find('.otherAnswerLookupFieldContainer').removeClass('hideItem'); } }); } appendLookupFields = function(builder) { $('.lookupConditionFieldsTemplate li.cboLookupConditionField').html(builder); $('.lookupConditionFieldsTemplate li.cboLookupConditionField option[value="Date_Created"]').remove(); $('.lookupConditionFieldsTemplate li.cboLookupConditionField option[value="Mobile_Device"]').remove(); $('.cboLookupConditionField').html(builder); $('.cboLookupConditionField option[value="Date_Created"]').remove(); $('.cboLookupConditionField option[value="Mobile_Device"]').remove(); } $(document).ready(function(){ //initManageLookupSave = function() { $('.lookUpDialog .lookUp_Save').click(function() { waitForDataLoading(true); var count = Object.keys(jsonChangeLookupActive).length; if(count <= 0) { waitForDataLoading(false); return; } $.ajax({ url: '/dataview/lookupprocess', dataType: 'json', type: 'GET', data: { action : 'saveLookupActive' ,listItems : JSON.stringify(jsonChangeLookupActive) }, cache: false, complete: function() { }, success: function(response, status) { jAlert(msg_custom_template_success.replace('{Template}', 'Lookup tables') .replace("{action}", "saved")); jsonChangeLookupActive = {}; isLookupManagerItemChange4IP = true; reloadLookupDSManager(); }, error: function(request, status, error) { jAlert(msg_unknown_error); waitForDataLoading(false); } }); }); //} }); var checkFinishSaveLookupTemp = function(ctrId, file, _action, _unitKey, actionType){ // set time out for updating progress every 3s setTimeout(function() { $.ajax({ url: '/dataview/lookup' +'?action=' + _action +'&unitKey=' + _unitKey, dataType: 'json', type: 'Get', cache: false, complete: function() { }, success: function(response, status) { if(response.finish == undefined || response.finish == '' || response.finish == 'false') { checkFinishSaveLookupTemp(ctrId, file, _action, _unitKey, actionType); } else { finishUploadLookup(ctrId, file, response, actionType); } }, error: function(request, status, error) { //jAlert(msg_lookup_failed); var msgError = msg_warning_transfer_lookup_data; jAlert(msgError); waitForDataLoading(false); } }); }, 10000); } //don't remove below comment because this comment add myAccount.js file to chrome/firefox debug //# sourceURL=lookup_4useform.js