Commit 87d0bb88 authored by Trushant's avatar Trushant

Committing js file

parent d7de6a1f
/**
* Added on 03-12-20 new format itemCode
* @author Shrutika N
*
*/
var globalFormNo = "";
var globalGroupBoxId = "";
var globalDomId = "";
var globalAttributeJson = {};
var allFormValues = {};
var oldAttributeJson = {};
var oldAttributeArray = [];
function creteItemCode(groupBoxId, fieldName, id, label, formNo ,domId, applColour )
{
try
{
globalFormNo = formNo;
globalGroupBoxId = groupBoxId;
globalDomId = domId;
globalApplColour = applColour;
var feedHtml = drawFields(groupBoxId, fieldName, id, label, formNo ,domId,false);
setTimeout(() => {
drawOtherFields(groupBoxId, "item_type", "", "Item Type:", formNo ,domId, false );
drawOtherFields(groupBoxId, "item_type_descr", "", "Item Type Description:", formNo ,domId, true);
}, 1000);
return feedHtml;
}
catch (error)
{
console.log('Exception inside creteItemCode',error);
return "";
}
}
function drawOtherItemCodeFields(groupBoxId, fieldName, id, label, formNo ,domId )
{
console.log("drawOtherItemCodeFields...............33");
// drawOtherFields(groupBoxId, "item_type", "", "Item Type:", formNo ,domId, false );
//drawOtherFields(groupBoxId, "item_type_descr", "", "Item Type Description:", formNo ,domId, true);
}
function drawFields( groupBoxId, fieldName, id, label, formNo ,domId, isReadOnly )
{
try
{
var fieldId = "Detail"+formNo +"."+ domId +"."+fieldName;
var isPophelpField = window.parent.isPophelpField(fieldName);
var inputFieldId = "Detail"+formNo +"."+ domId +"."+fieldName +"_input";
globalAttributeJson[fieldName] = inputFieldId;
if( isPophelpField )
{
window.parent.getPopUpLabelForomJS(fieldId,formNo, label);
}
if( fieldName == "item_code" )
{
var html = "<table cellspacing='0' cellpadding='0'";
html = html + "class='horWizardTextPnl responsiveHoriPnlWidth' id='"+groupBoxId+"'>";
html = html + "<tbody>";
html = html + "<tr>";
html = html + "<td align='left' style='vertical-align: top;'>";
html = html + "<div style='display:flex;width:100%'>";
html = html + "<div class='e12CustomInputPanel' id='"+fieldName+"'";
html = html + "style='width:calc(97% - 36px);'>";
if( isReadOnly )
{
html = html + "<input style='width:calc(100% - 30px)' type='text' value=''" ;
html = html + " class='textReadOnly1 removeBorder textReadOnly1-readonly dsabled-field gwtTextFieldEditor gwt-field-groupbox' readonly ";
}
else
{
html = html + "<input style='width:calc(100% - 30px)' onblur=onBlurItemCodeFields(this); fieldName='"+fieldName+"' type='text' value=''" ;
html = html + " class='textBox1 responsivePnlWidth gwtTextFieldEditor fontstylewidget gwt-field-groupbox'";
}
html = html + "fieldid='"+fieldId+"' id='"+fieldId+"_input' format='TextBox'";
html = html + "groupboxid='"+groupBoxId+"' maxlength='120' required=''/>";
html = html + "<div ";
html = html + "class='label1 fontstylewidget gwtLabelflickerEditor gwt-label-groupbox'";
html = html + "id='"+fieldId+"_t' required=''>"+label+"</div>";
if( isPophelpField )
{
html = html + "<div";
html = html + " class='wizTransPophelpImg icon-pophelp pophelpTransactionEffect gwtPopUpTxtLabel'";
html = html + " onclick=window.parent.openPophelp(this); id='"+fieldId+"'>"
html = html + "</div>";
}
if( fieldName == "item_code")
{
}
html = html + "</div>";
html = html + "<div id='inserItemCodeImgIdDiv' onclick=insertItemCode(); class='addItemCodeDiv' >";
html = html + "<svg style='height: 20px;fill: "+globalApplColour+"' viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg' "
html = html + " xmlns='http://www.w3.org/2000/svg' data-name='Layer 1' id='Layer_1' >"
html = html + "<title>add</title>"
html = html + "<path class='cls-1' d='M24,15a1,1,0,0,1-1,1H16v7a1,1,0,0,1-2,0V16H7a1,1,0,0,1,0-2h7V7a1,1,0,0,1,2,0v7h7A1,1,0,0,1,24,15Z'></path>"
html = html + "</svg>"
html = html + "</div>";
html = html + "</div>";
html = html + "</td>";
html = html + "</tr>";
html = html + "</tbody>";
html = html + "</table>";
}
else
{
var html = "<table cellspacing='0' cellpadding='0'";
html = html + "class='horWizardTextPnl responsiveHoriPnlWidth' id='"+groupBoxId+"'>";
html = html + "<tbody>";
html = html + "<tr>";
html = html + "<td align='left' style='vertical-align: top;'>";
html = html + "<div class='e12CustomInputPanel' id='"+fieldName+"'";
html = html + "style='position: relative; overflow: hidden; padding-left: 8px;width: calc(100% - 8px);'>";
if( isReadOnly )
{
html = html + "<input type='text' value=''" ;
html = html + " class='textReadOnly1 removeBorder textReadOnly1-readonly dsabled-field gwtTextFieldEditor gwt-field-groupbox' readonly ";
}
else
{
html = html + "<input onblur=onBlurItemCodeFields(this); fieldName='"+fieldName+"' type='text' value=''" ;
html = html + " class='textBox1 responsivePnlWidth gwtTextFieldEditor fontstylewidget gwt-field-groupbox'";
}
html = html + "fieldid='"+fieldId+"' id='"+fieldId+"_input' format='TextBox'";
html = html + "groupboxid='"+groupBoxId+"' maxlength='120' required=''/>";
html = html + "<div ";
html = html + "class='label1 fontstylewidget gwtLabelflickerEditor gwt-label-groupbox'";
html = html + "id='"+fieldId+"_t' required=''>"+label+"</div>";
if( isPophelpField )
{
html = html + "<div";
html = html + " class='wizTransPophelpImg icon-pophelp pophelpTransactionEffect gwtPopUpTxtLabel'";
html = html + " onclick=window.parent.openPophelp(this); id='"+fieldId+"'>"
html = html + "</div>";
}
if( fieldName == "item_code")
{
html = html + "<div id='inserItemCodeImgIdDiv' onclick=insertItemCode(); class='addItemCodeDiv' >";
html = html + "<svg style='height: 20px;fill: "+globalApplColour+"' viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg' "
html = html + " xmlns='http://www.w3.org/2000/svg' data-name='Layer 1' id='Layer_1' >"
html = html + "<title>add</title>"
html = html + "<path class='cls-1' d='M24,15a1,1,0,0,1-1,1H16v7a1,1,0,0,1-2,0V16H7a1,1,0,0,1,0-2h7V7a1,1,0,0,1,2,0v7h7A1,1,0,0,1,24,15Z'></path>"
html = html + "</svg>"
html = html + "</div>";
}
html = html + "</div>";
html = html + "</td>";
html = html + "</tr>";
html = html + "</tbody>";
html = html + "</table>";
}
return html;
}
catch (error)
{
console.log('Exception inside drawFields',error);
return "";
}
}
function onBlurItemCodeFields(event)
{
var previousValue = window.parent.getFldData(event.getAttribute("fieldId"));
window.parent.setFldData(event.getAttribute("fieldId"), event.value);
allFormValues[event.id] = event.value;
console.log('inside onBlurItemCodeFields........178 previousValue',previousValue);
console.log('inside onBlurItemCodeFields........180 currentValue',event.value);
if( (previousValue != event.value) || ( previousValue == event.value && window.parent.geSetFromPophelp() ) )
{
window.parent.setDataSetFromPophelp("false");
if( event.getAttribute("fieldName") == "item_type")
{
var JSONObj = {};
JSONObj['item_type'] = event.value;
JSONObj['focusColumn'] = "item_type";
var itemCodeInputId = "Detail"+globalFormNo+"."+globalDomId+"."+"item_code_input";
var itemCodeField = document.getElementById(itemCodeInputId);
$.ajax({
type: 'GET',
url: '/ibase/rest/ItemCodeService/getdataattributes',
// data: strJSON,
data: { "jsonitem" : JSON.stringify(JSONObj) },
dataType : 'text',
success: function (data) {
// alert("Success getDataAttribute");
console.log('inside ItemCode.......105',data);
var jsonData = JSON.parse(data);
oldAttributeArray = oldAttributeJson[event.getAttribute("fieldId")];
if( oldAttributeArray != null )
{
console.log('inside ItemCode.......109',oldAttributeArray.length);
for (var i = 0; i < oldAttributeArray.length; i++)
{
console.log('inside ItemCode.......113',oldAttributeArray[i]);
var oldAttribute = document.getElementById(oldAttributeArray[i]);
if( oldAttribute != null )
{
oldAttribute.remove();
}
}
}
drawAttributeFields(jsonData,event.getAttribute("fieldId"));
},
error: function (data) {
alert("Faild getDataAttribute");
}
});
}
else if( event.getAttribute("fieldName") == "item_code")
{
var JSONObj = {};
JSONObj['item_code'] = event.value;
JSONObj['focusColumn'] = "item_code";
var itemCodeInputId = "Detail"+globalFormNo+"."+globalDomId+"."+"item_code_input";
$.ajax({
type: 'GET',
url: '/ibase/rest/ItemCodeService/getdataattributes',
data: { "jsonitem" : JSON.stringify(JSONObj) },
dataType : 'text',
success: function (data) {
console.log('inside ItemCode.......105',data);
var jsonData = JSON.parse(data);
oldAttributeArray = oldAttributeJson[event.getAttribute("fieldId")];
if( oldAttributeArray != null )
{
console.log('inside ItemCode.......298',oldAttributeArray.length);
for (var i = 0; i < oldAttributeArray.length; i++)
{
var oldAttribute = document.getElementById(oldAttributeArray[i]);
if( oldAttribute != null )
{
oldAttribute.remove();
}
}
}
drawAttributeFields(jsonData,event.getAttribute("fieldId"));
},
error: function (data) {
alert("Faild getDataAttribute");
}
});
}
}
}
function drawAttributeFields(jsonData, fieldId )
{
try
{
oldAttributeArray = [];
for (var key of Object.keys(jsonData))
{
if( key == "item_type_descr" || key == "item_type")
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+key+"_input";
var labelId = "Detail"+globalFormNo+"."+globalDomId+"."+key+"_t";
if( document.getElementById(inputId) != null )
{
document.getElementById(inputId).value = jsonData[key];
globalAttributeJson[inputId] = document.getElementById(inputId).value;
console.log("Call setFieldData......283");
var id = "Detail"+globalFormNo+"."+globalDomId+"."+key;
window.parent.setFldData(id, jsonData[key]);
allFormValues[inputId] = jsonData[key];
var label = document.getElementById(labelId);
label.classList.add("labelflickerFixPosition");
}
}
else if( key == "descr")
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+key;
var labelId = "Detail"+globalFormNo+"."+globalDomId+"."+key+"_t";
if( document.getElementById(inputId) != null )
{
document.getElementById(inputId).value = jsonData[key];
globalAttributeJson[inputId] = document.getElementById(inputId).value;
window.parent.setFldData(inputId, jsonData[key]);
var label = document.getElementById(labelId);
label.classList.add("labelflickerFixPosition");
}
}
else if( key != "no_of_attributes" && key.includes("phy_attrib_") )
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+jsonData[key]+"_input";
if( document.getElementById(inputId) == null )
{
var feedHtml = drawAttributes(globalGroupBoxId, jsonData[key], "", jsonData[key], globalFormNo ,globalDomId , key, "");
}
}
else if( key != "no_of_attributes")
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+key+"_input";
var labelId = "Detail"+globalFormNo+"."+globalDomId+"."+key+"_t";
if( document.getElementById(inputId) == null )
{
console.log('inside itemcode.js file......325',key);
var feedHtml = drawAttributes(globalGroupBoxId, key, "", key, globalFormNo ,globalDomId , key, jsonData[key]);
}
else
{
console.log('inside itemcode.js file......330',key);
document.getElementById(inputId).value = jsonData[key];
globalAttributeJson[key] = document.getElementById(inputId).value;
var label = document.getElementById(labelId);
label.classList.add("labelflickerFixPosition");
}
}
else
{
globalAttributeJson[key] = jsonData[key];
}
}
if( jsonData['descr'] != null )
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+".descr";
var labelId = "Detail"+globalFormNo+"."+globalDomId+".descr_t";
if( document.getElementById(inputId) != null )
{
document.getElementById(inputId).value = jsonData['descr'];
globalAttributeJson[inputId] = document.getElementById(inputId).value;
window.parent.setFldData(inputId, jsonData['descr']);
var label = document.getElementById(labelId);
label.classList.add("labelflickerFixPosition");
}
}
for (var fieldKey of Object.keys(allFormValues))
{
var currentField = document.getElementById(fieldKey);
if( currentField != null )
{
console.log('inside allFormValues.............157', allFormValues[fieldKey])
currentField.value = allFormValues[fieldKey];
}
}
oldAttributeJson[fieldId] = oldAttributeArray;
}
catch (error)
{
console.log('Exception inside drawFields',error);
}
}
function drawAttributes( groupBoxId, fieldName, id, label, formNo ,domId, attributeKey, fieldValue )
{
try
{
var fieldId = "Detail"+formNo +"."+ domId +"."+fieldName;
var isPophelpField = window.parent.isPophelpField(fieldName);
var inputId = "Detail"+formNo+"."+domId+"."+fieldName+"_input";
var tableID = "AtributTable_"+fieldId;
oldAttributeArray.push(tableID);
if( attributeKey.includes("phy_attrib_") )
{
globalAttributeJson[label] = inputId;
}
else
{
globalAttributeJson[attributeKey] = inputId;
}
if( isPophelpField )
{
window.parent.getPopUpLabelForomJS(fieldId,formNo, label);
}
var html = "<table attricellspacing='0' cellpadding='0'";
html = html + "class='horWizardTextPnl responsiveHoriPnlWidth' id='"+tableID+"'>";
html = html + "<tbody>";
html = html + "<tr>";
html = html + "<td align='left' style='vertical-align: top;'>";
html = html + "<div class='e12CustomInputPanel' id='"+fieldName+"'";
html = html + "style='position: relative; overflow: hidden; padding-left: 8px;width: calc(100% - 8px);'>";
html = html + "<input onblur=onBlurAttributeFields(this); type='text' value='"+fieldValue+"'" ;
html = html + "class='textBox1 responsivePnlWidth gwtTextFieldEditor fontstylewidget gwt-field-groupbox'";
html = html + "fieldid='"+fieldId+"' id='"+fieldId+"_input' format='TextBox'";
html = html + "groupboxid='"+groupBoxId+"' maxlength='120' required=''/>";
html = html + "<div ";
html = html + "class='label1 fontstylewidget gwtLabelflickerEditor gwt-label-groupbox'";
html = html + "id='"+fieldId+"_t' required=''>"+label+"</div>";
if( isPophelpField )
{
html = html + "<div";
html = html + " class='wizTransPophelpImg icon-pophelp pophelpTransactionEffect gwtPopUpTxtLabel'";
html = html + " onclick=window.parent.openPophelp(this); id='"+fieldId+"'>"
html = html + "</div>";
}
html = html + "</div>";
html = html + "</td>";
html = html + "</tr>";
html = html + "</tbody>";
html = html + "</table>";
var id = "Detail"+globalFormNo+"."+""+globalDomId+"."+"item_code_flowPanel";
var flowPnl = document.getElementById(id);
if( flowPnl != null && flowPnl.parentElement != null )
{
console.log('inide drawOtherFields...........559');
flowPnl.parentElement.innerHTML += html;
console.log('inide drawOtherFields...........561',flowPnl);
}
window.parent.setFldData(fieldId, fieldValue);
return html;
}
catch (error)
{
console.log('Exception inside drawAttributeFields',error);
return "";
}
}
function onBlurAttributeFields(event)
{
window.parent.setFldData(event.getAttribute("fieldId"), event.value);
var JSONObj = {};
var isAttributeBlank = false;
for (var key of Object.keys(globalAttributeJson))
{
if( key == "no_of_attributes" )
{
JSONObj[key] = globalAttributeJson[key];
}
else
{
console.log("Title ItemCodeBlur.........208["+globalAttributeJson[key]+"]]");
var inputId = globalAttributeJson[key];
if( document.getElementById(inputId) != null )
{
var value = document.getElementById(inputId).value;
JSONObj[key] = value;
console.log("Title ItemCodeBlur.........value["+value+"]]");
console.log("Title ItemCodeBlur.........key["+key+"]]");
console.log("Title ItemCodeBlur.........key.includes["+key.includes("phy_attrib_")+"]]");
//if( key.includes("phy_attrib_") && value.trim() == "" )
if( key != "item_code" && key != "descr" && value.trim() == "" )
{
isAttributeBlank = true;
}
}
}
}
if( !isAttributeBlank )
{
$.ajax({
type: 'GET',
url: '/ibase/rest/ItemCodeService/getdataitemcode',
data: { "attributeitem" : JSON.stringify(JSONObj) },
dataType: 'text',
success: function (data) {
//alert("Success getdataitemcode");
console.log('inside getdataitemcode sucess.......271',data);
var jsonData = JSON.parse(data);
for (var fieldName of Object.keys(jsonData))
{
if( fieldName == "item_code" )
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+fieldName+"_input";
var currentFieldEle = document.getElementById(inputId);
if( currentFieldEle != null )
{
currentFieldEle.value = jsonData[fieldName];
}
}
else if( fieldName == "descr" )
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+fieldName;
var currentFieldEle = document.getElementById(inputId);
if( currentFieldEle != null )
{
currentFieldEle.value = jsonData[fieldName];
var label = document.getElementById(inputId+"_t");
label.classList.add("labelflickerFixPosition");
}
}
}
},
error: function (data) {
alert("Fail webservice");
}
});
}
}
function insertItemCode()
{
var JSONObj = {};
for (var key of Object.keys(globalAttributeJson))
{
if( key == "no_of_attributes" )
{
JSONObj[key] = globalAttributeJson[key];
}
else
{
var inputId = globalAttributeJson[key];
if( document.getElementById(inputId) != null )
{
var value = document.getElementById(inputId).value;
JSONObj[key] = value;
}
}
}
$.ajax({
type: 'GET',
url: '/ibase/rest/ItemCodeService/insertitemcode',
data: { "jsonitem" : JSON.stringify(JSONObj) },
dataType: 'text',
success: function (data) {
//alert("Success getdataitemcode");
console.log('inside insertItemCode sucess.......340',data);
var jsonData = JSON.parse(data);
for (var fieldName of Object.keys(jsonData))
{
if( fieldName == "item_code" )
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+fieldName+"_input";
var currentFieldEle = document.getElementById(inputId);
if( currentFieldEle != null )
{
currentFieldEle.value = jsonData[fieldName];
}
}
else if( fieldName == "descr" )
{
var inputId = "Detail"+globalFormNo+"."+globalDomId+"."+fieldName;
var currentFieldEle = document.getElementById(inputId);
if( currentFieldEle != null )
{
currentFieldEle.value = jsonData[fieldName];
var label = document.getElementById(inputId+"_t");
label.classList.add("labelflickerFixPosition");
}
}
}
},
error: function (data) {
alert("Fail insertItemCode webservice");
}
});
}
function drawOtherFields( groupBoxId, fieldName, id, label, formNo ,domId, isReadOnly )
{
var fieldId = "Detail"+formNo +"."+ domId +"."+fieldName;
var isPophelpField = window.parent.isPophelpField(fieldName);
var inputFieldId = "Detail"+formNo +"."+ domId +"."+fieldName +"_input";
globalAttributeJson[fieldName] = inputFieldId;
if( isPophelpField )
{
window.parent.getPopUpLabelForomJS(fieldId,formNo, label);
}
var flowPnlId = fieldId + "_flowPanel";
var html = "<div class='fieldFormFlowPanel' id='"+flowPnlId+"'>";
html = html + "<table cellspacing='0' cellpadding='0'";
html = html + "class='horWizardTextPnl responsiveHoriPnlWidth' id='"+groupBoxId+"'>";
html = html + "<tbody>";
html = html + "<tr>";
html = html + "<td align='left' style='vertical-align: top;'>";
html = html + "<div class='e12CustomInputPanel' id='"+fieldName+"'";
html = html + "style='position: relative; overflow: hidden; padding-left: 8px;width: calc(100% - 8px);'>";
if( isReadOnly )
{
html = html + "<input type='text' value=''" ;
html = html + " class='textReadOnly1 removeBorder textReadOnly1-readonly dsabled-field gwtTextFieldEditor gwt-field-groupbox' readonly ";
}
else
{
html = html + "<input onblur=onBlurItemCodeFields(this); fieldName='"+fieldName+"' type='text' value=''" ;
html = html + " class='textBox1 responsivePnlWidth gwtTextFieldEditor fontstylewidget gwt-field-groupbox'";
}
html = html + "fieldid='"+fieldId+"' id='"+fieldId+"_input' format='TextBox'";
html = html + "groupboxid='"+groupBoxId+"' maxlength='120' required=''/>";
html = html + "<div ";
html = html + "class='label1 fontstylewidget gwtLabelflickerEditor gwt-label-groupbox'";
html = html + "id='"+fieldId+"_t' required=''>"+label+"</div>";
if( isPophelpField )
{
html = html + "<div";
html = html + " class='wizTransPophelpImg icon-pophelp pophelpTransactionEffect gwtPopUpTxtLabel'";
html = html + " onclick=window.parent.openPophelp(this); id='"+fieldId+"'>"
html = html + "</div>";
}
if( fieldName == "item_code")
{
html = html + "<div id='inserItemCodeImgIdDiv' onclick=insertItemCode(); class='addItemCodeDiv' >";
html = html + " <img id='inserItemCodeImgId' src='images/addItem.svg' onclick=insertItemCode(); class='insertItemCodeIcon svg-red' >"
html = html + "</div>";
}
html = html + "</div>";
html = html + "</td>";
html = html + "</tr>";
html = html + "</tbody>";
html = html + "</table>";
html = html + "</div>";
var mainPanleId = "Detail"+formNo +"."+ domId +"."+"item_code_flowPanel";
var flowPnl = document.getElementById(mainPanleId);
if( flowPnl != null && flowPnl.parentElement != null )
{
flowPnl.parentElement.innerHTML += html;
}
}
function removeItemCodeFormatMap()
{
globalAttributeJson = {};
allFormValues = {};
oldAttributeJson = {};
oldAttributeArray = [];
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment