BUG 10054 Feature request: grid to support a suggest field SOLVED

- Add the possibility to insert Suggest fields in a grid.
- New Feature, was added Suggest option to the grid.
This commit is contained in:
Hector Cortez
2012-12-05 15:19:49 -04:00
parent c957de4ee8
commit 9924f254d0
6 changed files with 290 additions and 56 deletions

View File

@@ -340,6 +340,19 @@ var G_Grid = function(oForm, sGridName){
return newElem; return newElem;
}; };
function replaceHtml(el, html) {
var oldEl = typeof el === "string" ? document.getElementById(el) : el;
/*Pure innerHTML is slightly faster in IE
oldEl.innerHTML = html;
return oldEl;
*/
var newEl = oldEl.cloneNode(false);
newEl.innerHTML = html;
oldEl.parentNode.replaceChild(newEl, oldEl);
/* Since we just removed the old element from the DOM, return a reference
to the new element, which can be used to restore variable references. */
return newEl;
};
this.addGridRow = function() { this.addGridRow = function() {
this.oGrid = document.getElementById(this.sGridName); this.oGrid = document.getElementById(this.sGridName);
@@ -361,7 +374,7 @@ var G_Grid = function(oForm, sGridName){
// Clone Cells Loop // Clone Cells Loop
for (i = 0; i < aCells.length; i++) { for (i = 0; i < aCells.length; i++) {
oNewRow.appendChild(aCells[i].cloneNode(true)); //Clone First Cell exactly. oNewRow.appendChild(aCells[i].cloneNode(true)); //Clone First Cell exactly.
switch (i){ switch (i){
case 0: case 0:
oNewRow.getElementsByTagName('td')[i].innerHTML = currentRow; oNewRow.getElementsByTagName('td')[i].innerHTML = currentRow;
@@ -445,6 +458,14 @@ var G_Grid = function(oForm, sGridName){
} }
} }
} }
aObjectsScript = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');
sObjectType = this.aFields[i-1].sType;
if (aObjectsScript[0] != 'undefined' && sObjectType == 'suggest') {
sObjScript = aObjectsScript[0].innerHTML;
sNewObjScript = sObjScript.replace(/\[1\]/g, '\[' + currentRow + '\]');
replaceHtml(aObjectsScript[0], sNewObjScript);
eval(aObjectsScript[0].innerHTML);
}
break; break;
case 'checkbox': //CHECKBOX case 'checkbox': //CHECKBOX
var attributeCheckBox = elementAttributesNS(aObjects[n], ""); var attributeCheckBox = elementAttributesNS(aObjects[n], "");
@@ -456,8 +477,12 @@ var G_Grid = function(oForm, sGridName){
} }
break; break;
case 'hidden': //HIDDEN case 'hidden': //HIDDEN
if ((attributes.gridtype != 'yesno' && attributes.gridtype != 'dropdown') || typeof attributes.gridtype == 'undefined') if ((attributes.gridtype != 'yesno' && attributes.gridtype != 'dropdown') || typeof attributes.gridtype == 'undefined') {
aObjects[n].value = defaultValue; aObjects[n].value = defaultValue;
newID = aObjects[n].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
aObjects[n].id = newID;
aObjects[n].name = newID;
}
break; break;
case 'button': case 'button':
if (aObjects[n].onclick){ if (aObjects[n].onclick){
@@ -685,6 +710,9 @@ var G_Grid = function(oForm, sGridName){
//Set focus the first element in the grid //Set focus the first element in the grid
for (var i = 0; i < this.aFields.length; i++) { for (var i = 0; i < this.aFields.length; i++) {
var fieldName = 'form[' + sGridName + '][' + currentRow + '][' + this.aFields[i].sFieldName + ']'; var fieldName = 'form[' + sGridName + '][' + currentRow + '][' + this.aFields[i].sFieldName + ']';
if (this.aFields[i].sType == 'suggest' ) {
fieldName = 'form[' + sGridName + '][' + currentRow + '][' + this.aFields[i].sFieldName + '_label]';
}
if (this.aFields[i].sType != 'file' && this.aFields[i].sType != 'hidden' && document.getElementById(fieldName).focus) { if (this.aFields[i].sType != 'file' && this.aFields[i].sType != 'hidden' && document.getElementById(fieldName).focus) {
document.getElementById(fieldName).focus(); document.getElementById(fieldName).focus();
break; break;
@@ -770,6 +798,9 @@ var G_Grid = function(oForm, sGridName){
} }
aObjects1[0].value = aObjects2[0].value; aObjects1[0].value = aObjects2[0].value;
aObjects1[0].className = aObjects2[0].className; aObjects1[0].className = aObjects2[0].className;
if ( typeof(aObjects1[1]) != 'undefined' && typeof(aObjects2[1]) != 'undefined' ) {
aObjects1[1].value = aObjects2[1].value;
}
break; break;
} }
} }

View File

@@ -1169,7 +1169,7 @@ if(contracted)expandSubtitle(subTitleName);else contractSubtitle(subTitleName);}
function concat_collection(obj1,obj2){var i;var arr=new Array();var len1=obj1.length;var len2=obj2.length;for(i=0;i<len1;i++){arr.push(obj1[i]);} function concat_collection(obj1,obj2){var i;var arr=new Array();var len1=obj1.length;var len2=obj2.length;for(i=0;i<len1;i++){arr.push(obj1[i]);}
for(i=0;i<len2;i++){arr.push(obj2[i]);} for(i=0;i<len2;i++){arr.push(obj2[i]);}
return arr;} return arr;}
var getControlsInTheRow=function(oRow){var aAux1=[];if(oRow.cells){var i;var j;var sFieldName;for(i=0;i<oRow.cells.length;i++){var aAux2=oRow.cells[i].getElementsByTagName('input');aAux2=concat_collection(aAux2,oRow.cells[i].getElementsByTagName('a'));aAux2=concat_collection(aAux2,oRow.cells[i].getElementsByTagName('select'));aAux2=concat_collection(aAux2,oRow.cells[i].getElementsByTagName('textarea'));if(aAux2){for(j=0;j<aAux2.length;j++){sFieldName=aAux2[j].id.replace('form[','');console.info(sFieldName);sFieldName=sFieldName.replace(/]$/,'');if(sFieldName!=''){aAux1.push(sFieldName);}}}}} var getControlsInTheRow=function(oRow){var aAux1=[];if(oRow.cells){var i;var j;var sFieldName;for(i=0;i<oRow.cells.length;i++){var aAux2=oRow.cells[i].getElementsByTagName('input');aAux2=concat_collection(aAux2,oRow.cells[i].getElementsByTagName('a'));aAux2=concat_collection(aAux2,oRow.cells[i].getElementsByTagName('select'));aAux2=concat_collection(aAux2,oRow.cells[i].getElementsByTagName('textarea'));if(aAux2){for(j=0;j<aAux2.length;j++){sFieldName=aAux2[j].id.replace('form[','');sFieldName=sFieldName.replace(/]$/,'');if(sFieldName!=''){aAux1.push(sFieldName);}}}}}
return aAux1;};var notValidateThisFields=[];function getElementsByClassNameCrossBrowser(searchClass,node,tag){var classElements=new Array();if(node==null) return aAux1;};var notValidateThisFields=[];function getElementsByClassNameCrossBrowser(searchClass,node,tag){var classElements=new Array();if(node==null)
node=document;if(tag==null) node=document;if(tag==null)
tag='*';var els=node.getElementsByTagName(tag);var elsLen=els.length;var pattern=new RegExp("(^|\\s)"+searchClass+"(\\s|$)");for(i=0,j=0;i<elsLen;i++){if(pattern.test(els[i].className)){classElements[j]=els[i];j++;}} tag='*';var els=node.getElementsByTagName(tag);var elsLen=els.length;var pattern=new RegExp("(^|\\s)"+searchClass+"(\\s|$)");for(i=0,j=0;i<elsLen;i++){if(pattern.test(els[i].className)){classElements[j]=els[i];j++;}}
@@ -1333,14 +1333,15 @@ switch(tag.toLowerCase()){case"input":case"textarea":newElem.value=elem.value;br
newElem.options[i]=new Option(elem.options[i].text,elem.options[i].value,elem.options[i].defaultSelected);} newElem.options[i]=new Option(elem.options[i].text,elem.options[i].value,elem.options[i].defaultSelected);}
newElem.options[pos].selected=true;} newElem.options[pos].selected=true;}
break;} break;}
return newElem;};this.addGridRow=function(){this.oGrid=document.getElementById(this.sGridName);var i,aObjects;var defaultValue='';var n,a,x;var oRow=document.getElementById('firstRow_'+this.sGridName);var aCells=oRow.getElementsByTagName('td');var oNewRow=this.oGrid.insertRow(this.oGrid.rows.length-1);var currentRow=this.oGrid.rows.length-2;var newID,attributes,img2,gridType;oNewRow.onmouseover=function(){highlightRow(this,'#D9E8FF');};oNewRow.onmouseout=function(){highlightRow(this,'#fff');};for(i=0;i<aCells.length;i++){oNewRow.appendChild(aCells[i].cloneNode(true));switch(i){case 0:oNewRow.getElementsByTagName('td')[i].innerHTML=currentRow;break;case aCells.length-1:oNewRow.getElementsByTagName('td')[i].innerHTML=oNewRow.getElementsByTagName('td')[i].innerHTML.replace(/\[1\]/g,'\['+currentRow+'\]');break;default:var eNodeName=aCells[i].innerHTML.substring(aCells[i].innerHTML.indexOf('<')+1,aCells[i].innerHTML.indexOf(' '));eNodeName=eNodeName.toLowerCase();switch(eNodeName){case'input':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('input');if(aObjects){newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(typeof attributes.defaultvalue!="undefined"&&attributes.defaultvalue!=""){defaultValue=attributes.defaultvalue;}else{defaultValue="";} return newElem;};function replaceHtml(el,html){var oldEl=typeof el==="string"?document.getElementById(el):el;var newEl=oldEl.cloneNode(false);newEl.innerHTML=html;oldEl.parentNode.replaceChild(newEl,oldEl);return newEl;};this.addGridRow=function(){this.oGrid=document.getElementById(this.sGridName);var i,aObjects;var defaultValue='';var n,a,x;var oRow=document.getElementById('firstRow_'+this.sGridName);var aCells=oRow.getElementsByTagName('td');var oNewRow=this.oGrid.insertRow(this.oGrid.rows.length-1);var currentRow=this.oGrid.rows.length-2;var newID,attributes,img2,gridType;oNewRow.onmouseover=function(){highlightRow(this,'#D9E8FF');};oNewRow.onmouseout=function(){highlightRow(this,'#fff');};for(i=0;i<aCells.length;i++){oNewRow.appendChild(aCells[i].cloneNode(true));switch(i){case 0:oNewRow.getElementsByTagName('td')[i].innerHTML=currentRow;break;case aCells.length-1:oNewRow.getElementsByTagName('td')[i].innerHTML=oNewRow.getElementsByTagName('td')[i].innerHTML.replace(/\[1\]/g,'\['+currentRow+'\]');break;default:var eNodeName=aCells[i].innerHTML.substring(aCells[i].innerHTML.indexOf('<')+1,aCells[i].innerHTML.indexOf(' '));eNodeName=eNodeName.toLowerCase();switch(eNodeName){case'input':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('input');if(aObjects){newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(typeof attributes.defaultvalue!="undefined"&&attributes.defaultvalue!=""){defaultValue=attributes.defaultvalue;}else{defaultValue="";}
for(n=0;n<aObjects.length;n++){switch(aObjects[n].type){case'text':aObjects[n].className="module_app_input___gray";tags=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');if(tags.length==2){img2=tags[1].innerHTML;var datePickerTriggerId=tags[1].id.replace(/\[1\]/g,'\['+currentRow+'\]');oNewRow.getElementsByTagName('td')[i].removeChild(tags[1]);var scriptTags=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');oNewRow.getElementsByTagName('td')[i].removeChild(scriptTags[0]);if(tags[0].onclick){var onclickevn=new String(tags[0].onclick);eval('tags[0].onclick = '+onclickevn.replace(/\[1\]/g,'\['+currentRow+'\]')+';');} for(n=0;n<aObjects.length;n++){switch(aObjects[n].type){case'text':aObjects[n].className="module_app_input___gray";tags=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');if(tags.length==2){img2=tags[1].innerHTML;var datePickerTriggerId=tags[1].id.replace(/\[1\]/g,'\['+currentRow+'\]');oNewRow.getElementsByTagName('td')[i].removeChild(tags[1]);var scriptTags=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');oNewRow.getElementsByTagName('td')[i].removeChild(scriptTags[0]);if(tags[0].onclick){var onclickevn=new String(tags[0].onclick);eval('tags[0].onclick = '+onclickevn.replace(/\[1\]/g,'\['+currentRow+'\]')+';');}
var a2=document.createElement('a');if(a2.style.setAttribute){var styleText="position:relative;top:0px;left:-19px;";a2.style.setAttribute("cssText",styleText);} var a2=document.createElement('a');if(a2.style.setAttribute){var styleText="position:relative;top:0px;left:-19px;";a2.style.setAttribute("cssText",styleText);}
else{var styleText="position:relative;top:0px;left:-22px;";a2.setAttribute("style",styleText);} else{var styleText="position:relative;top:0px;left:-22px;";a2.setAttribute("style",styleText);}
a2.id=datePickerTriggerId;a2.innerHTML=img2;oNewRow.getElementsByTagName('td')[i].appendChild(a2);datePicker4("",newID,attributes.mask,attributes.start,attributes.end,attributes.time);aObjects[n].value=defaultValue;}else{if(_BROWSER.name=='msie'&&aObjects.length==1){var oNewOBJ=this.cloneElement(aObjects[n]);oNewOBJ.value=defaultValue;var parentGG=aObjects[n].parentNode;parentGG.removeChild(aObjects[n]);parentGG.appendChild(oNewOBJ);}else{if((attributes.gridtype)&&attributes.gridtype=="currency"){var attributesCurrency=elementAttributesNS(aObjects[n],"");aObjects[n].value=attributesCurrency.value.replace(/[.,0-9\s]/g,"");}else{aObjects[n].value=defaultValue;}}} a2.id=datePickerTriggerId;a2.innerHTML=img2;oNewRow.getElementsByTagName('td')[i].appendChild(a2);datePicker4("",newID,attributes.mask,attributes.start,attributes.end,attributes.time);aObjects[n].value=defaultValue;}else{if(_BROWSER.name=='msie'&&aObjects.length==1){var oNewOBJ=this.cloneElement(aObjects[n]);oNewOBJ.value=defaultValue;var parentGG=aObjects[n].parentNode;parentGG.removeChild(aObjects[n]);parentGG.appendChild(oNewOBJ);}else{if((attributes.gridtype)&&attributes.gridtype=="currency"){var attributesCurrency=elementAttributesNS(aObjects[n],"");aObjects[n].value=attributesCurrency.value.replace(/[.,0-9\s]/g,"");}else{aObjects[n].value=defaultValue;}}}
aObjectsScript=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');sObjectType=this.aFields[i-1].sType;if(aObjectsScript[0]!='undefined'&&sObjectType=='suggest'){sObjScript=aObjectsScript[0].innerHTML;sNewObjScript=sObjScript.replace(/\[1\]/g,'\['+currentRow+'\]');replaceHtml(aObjectsScript[0],sNewObjScript);eval(aObjectsScript[0].innerHTML);}
break;case'checkbox':var attributeCheckBox=elementAttributesNS(aObjects[n],"");if(defaultValue==""||(typeof attributeCheckBox.falseValue!="undefined"&&defaultValue==attributeCheckBox.falseValue)||(typeof attributeCheckBox.falsevalue!="undefined"&&defaultValue==attributeCheckBox.falsevalue)){aObjects[n].checked=false;}else{aObjects[n].checked=true;} break;case'checkbox':var attributeCheckBox=elementAttributesNS(aObjects[n],"");if(defaultValue==""||(typeof attributeCheckBox.falseValue!="undefined"&&defaultValue==attributeCheckBox.falseValue)||(typeof attributeCheckBox.falsevalue!="undefined"&&defaultValue==attributeCheckBox.falsevalue)){aObjects[n].checked=false;}else{aObjects[n].checked=true;}
break;case'hidden':if((attributes.gridtype!='yesno'&&attributes.gridtype!='dropdown')||typeof attributes.gridtype=='undefined') break;case'hidden':if((attributes.gridtype!='yesno'&&attributes.gridtype!='dropdown')||typeof attributes.gridtype=='undefined'){aObjects[n].value=defaultValue;newID=aObjects[n].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[n].id=newID;aObjects[n].name=newID;}
aObjects[n].value=defaultValue;break;case'button':if(aObjects[n].onclick){var onclickevn=new String(aObjects[n].onclick);eval('aObjects[n].onclick = '+onclickevn.replace(/\[1\]/g,'\['+currentRow+'\]')+';');} break;case'button':if(aObjects[n].onclick){var onclickevn=new String(aObjects[n].onclick);eval('aObjects[n].onclick = '+onclickevn.replace(/\[1\]/g,'\['+currentRow+'\]')+';');}
break;case"file":aObjects[n].value="";break;}}} break;case"file":aObjects[n].value="";break;}}}
aObjects=null;break;case'textarea':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');if(aObjects){aObjects[0].className="module_app_input___gray";newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(attributes.defaultvalue!=''&&typeof attributes.defaultvalue!='undefined'){defaultValue=attributes.defaultvalue;}else{defaultValue='';} aObjects=null;break;case'textarea':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');if(aObjects){aObjects[0].className="module_app_input___gray";newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(attributes.defaultvalue!=''&&typeof attributes.defaultvalue!='undefined'){defaultValue=attributes.defaultvalue;}else{defaultValue='';}
aObjects[0].innerHTML=defaultValue;} aObjects[0].innerHTML=defaultValue;}
@@ -1368,14 +1369,16 @@ var xIsDependentOf=[];var exist=false;var m;for(i=0;i<this.aFields.length;i++){v
if(typeof oAux.dependentFields!=='undefined'){if(oAux.dependentFields.length>0){exist=false;for(m=0;m<xIsDependentOf.length;m++) if(typeof oAux.dependentFields!=='undefined'){if(oAux.dependentFields.length>0){exist=false;for(m=0;m<xIsDependentOf.length;m++)
if(xIsDependentOf[m]==oAux.name)exist=true;for(j=0;j<oAux.dependentFields.length;j++){xIsDependentOf.push(oAux.dependentFields[j].name);} if(xIsDependentOf[m]==oAux.name)exist=true;for(j=0;j<oAux.dependentFields.length;j++){xIsDependentOf.push(oAux.dependentFields[j].name);}
if(!exist){oAux.updateDepententFields();}}}} if(!exist){oAux.updateDepententFields();}}}}
for(var i=0;i<this.aFields.length;i++){var fieldName='form['+sGridName+']['+currentRow+']['+this.aFields[i].sFieldName+']';if(this.aFields[i].sType!='file'&&this.aFields[i].sType!='hidden'&&document.getElementById(fieldName).focus){document.getElementById(fieldName).focus();break;}} for(var i=0;i<this.aFields.length;i++){var fieldName='form['+sGridName+']['+currentRow+']['+this.aFields[i].sFieldName+']';if(this.aFields[i].sType=='suggest'){fieldName='form['+sGridName+']['+currentRow+']['+this.aFields[i].sFieldName+'_label]';}
if(this.aFields[i].sType!='file'&&this.aFields[i].sType!='hidden'&&document.getElementById(fieldName).focus){document.getElementById(fieldName).focus();break;}}
if(this.onaddrow){this.onaddrow(currentRow);}};this.deleteGridRow=function(sRow,bWithoutConfirm) if(this.onaddrow){this.onaddrow(currentRow);}};this.deleteGridRow=function(sRow,bWithoutConfirm)
{if(typeof bWithoutConfirm=="undefined"){bWithoutConfirm=false;} {if(typeof bWithoutConfirm=="undefined"){bWithoutConfirm=false;}
if(this.oGrid.rows.length==3){new leimnud.module.app.alert().make({label:G_STRINGS.ID_MSG_NODELETE_GRID_ITEM});return false;} if(this.oGrid.rows.length==3){new leimnud.module.app.alert().make({label:G_STRINGS.ID_MSG_NODELETE_GRID_ITEM});return false;}
if(bWithoutConfirm){this.deleteRowWC(this,sRow);}else{new leimnud.module.app.confirm().make({label:G_STRINGS.ID_MSG_DELETE_GRID_ITEM,action:function() if(bWithoutConfirm){this.deleteRowWC(this,sRow);}else{new leimnud.module.app.confirm().make({label:G_STRINGS.ID_MSG_DELETE_GRID_ITEM,action:function()
{this.deleteRowWC(this,sRow);}.extend(this)});}};this.deleteRowWC=function(oObj,aRow) {this.deleteRowWC(this,sRow);}.extend(this)});}};this.deleteRowWC=function(oObj,aRow)
{var sRow=new String(aRow);sRow=sRow.replace("[","");sRow=sRow.replace("]","");var iRow=Number(sRow);var iRowAux=iRow+1;var lastItem=oObj.oGrid.rows.length-2;var elem2ParentNode;var elem2Id="";var elem2Name="";var elemAux;deleteRowOnDynaform(oObj,iRow);while(iRowAux<=(lastItem)){for(i=1;i<oObj.oGrid.rows[iRowAux-1].cells.length;i++){var oCell1=oObj.oGrid.rows[iRowAux-1].cells[i];var oCell2=oObj.oGrid.rows[iRowAux].cells[i];switch(oCell1.innerHTML.replace(/^\s+|\s+$/g,'').substr(0,6).toLowerCase()){case'<input':aObjects1=oCell1.getElementsByTagName('input');aObjects2=oCell2.getElementsByTagName('input');if(aObjects1&&aObjects2){switch(aObjects2[0].type){case"file":elem2ParentNode=aObjects2[0].parentNode;elem2Id=aObjects2[0].id;elem2Name=aObjects2[0].name;aObjects2[0].id=aObjects1[0].id;aObjects2[0].name=aObjects1[0].name;aObjects1[0].parentNode.replaceChild(aObjects2[0],aObjects1[0]);elemAux=document.createElement("input");elemAux.type="file";elemAux.setAttribute("id",elem2Id);elemAux.setAttribute("name",elem2Name);elem2ParentNode.insertBefore(elemAux,elem2ParentNode.firstChild);break;default:if(aObjects2[0].type=="checkbox"){aObjects1[0].checked=aObjects2[0].checked;} {var sRow=new String(aRow);sRow=sRow.replace("[","");sRow=sRow.replace("]","");var iRow=Number(sRow);var iRowAux=iRow+1;var lastItem=oObj.oGrid.rows.length-2;var elem2ParentNode;var elem2Id="";var elem2Name="";var elemAux;deleteRowOnDynaform(oObj,iRow);while(iRowAux<=(lastItem)){for(i=1;i<oObj.oGrid.rows[iRowAux-1].cells.length;i++){var oCell1=oObj.oGrid.rows[iRowAux-1].cells[i];var oCell2=oObj.oGrid.rows[iRowAux].cells[i];switch(oCell1.innerHTML.replace(/^\s+|\s+$/g,'').substr(0,6).toLowerCase()){case'<input':aObjects1=oCell1.getElementsByTagName('input');aObjects2=oCell2.getElementsByTagName('input');if(aObjects1&&aObjects2){switch(aObjects2[0].type){case"file":elem2ParentNode=aObjects2[0].parentNode;elem2Id=aObjects2[0].id;elem2Name=aObjects2[0].name;aObjects2[0].id=aObjects1[0].id;aObjects2[0].name=aObjects1[0].name;aObjects1[0].parentNode.replaceChild(aObjects2[0],aObjects1[0]);elemAux=document.createElement("input");elemAux.type="file";elemAux.setAttribute("id",elem2Id);elemAux.setAttribute("name",elem2Name);elem2ParentNode.insertBefore(elemAux,elem2ParentNode.firstChild);break;default:if(aObjects2[0].type=="checkbox"){aObjects1[0].checked=aObjects2[0].checked;}
aObjects1[0].value=aObjects2[0].value;aObjects1[0].className=aObjects2[0].className;break;}} aObjects1[0].value=aObjects2[0].value;aObjects1[0].className=aObjects2[0].className;if(typeof(aObjects1[1])!='undefined'&&typeof(aObjects2[1])!='undefined'){aObjects1[1].value=aObjects2[1].value;}
break;}}
aObjects=oCell1.getElementsByTagName('div');if(aObjects.length>0){if(aObjects[0]){aObjects[0].id=aObjects[0].id.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]');aObjects[0].name=aObjects[0].id.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]');if(aObjects[0].onclick){sAux=new String(aObjects[0].onclick);eval('aObjects[0].onclick = '+sAux.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]')+';');}} aObjects=oCell1.getElementsByTagName('div');if(aObjects.length>0){if(aObjects[0]){aObjects[0].id=aObjects[0].id.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]');aObjects[0].name=aObjects[0].id.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]');if(aObjects[0].onclick){sAux=new String(aObjects[0].onclick);eval('aObjects[0].onclick = '+sAux.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]')+';');}}
aObjects=oCell1.getElementsByTagName('a');if(aObjects){if(aObjects[0]){if(aObjects[0].onclick){sAux=new String(aObjects[0].onclick);eval('aObjects[0].onclick = '+sAux.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]')+';');}}}} aObjects=oCell1.getElementsByTagName('a');if(aObjects){if(aObjects[0]){if(aObjects[0].onclick){sAux=new String(aObjects[0].onclick);eval('aObjects[0].onclick = '+sAux.replace('/\['+(iRowAux-1)+'\]/g','\['+iRowAux+'\]')+';');}}}}
break;case'<selec':aObjects1=oCell1.getElementsByTagName('select');aObjects2=oCell2.getElementsByTagName('select');if(aObjects1&&aObjects2){var vValue=aObjects2[0].value;aObjects1[0].options.length=0;for(var j=0;j<aObjects2[0].options.length;j++){var optn=$dce("OPTION");optn.text=aObjects2[0].options[j].text;optn.value=aObjects2[0].options[j].value;aObjects1[0].options[j]=optn;} break;case'<selec':aObjects1=oCell1.getElementsByTagName('select');aObjects2=oCell2.getElementsByTagName('select');if(aObjects1&&aObjects2){var vValue=aObjects2[0].value;aObjects1[0].options.length=0;for(var j=0;j<aObjects2[0].options.length;j++){var optn=$dce("OPTION");optn.text=aObjects2[0].options[j].text;optn.value=aObjects2[0].options[j].value;aObjects1[0].options[j]=optn;}
@@ -3207,4 +3210,4 @@ newBlockName=newBlockName||'P';if(isCaretAtStartOrEndOfBlock()){if(/^(H[1-6]|PRE
if(settings.end_container_on_empty_block&&canSplitBlock(containerBlock)&&dom.isEmpty(parentBlock)){newBlock=dom.split(containerBlock,parentBlock);}else{dom.insertAfter(newBlock,parentBlock);} if(settings.end_container_on_empty_block&&canSplitBlock(containerBlock)&&dom.isEmpty(parentBlock)){newBlock=dom.split(containerBlock,parentBlock);}else{dom.insertAfter(newBlock,parentBlock);}
moveToCaretPosition(newBlock);}else if(isCaretAtStartOrEndOfBlock(true)){newBlock=parentBlock.parentNode.insertBefore(createNewBlock(),parentBlock);renderBlockOnIE(newBlock);}else{tmpRng=rng.cloneRange();tmpRng.setEndAfter(parentBlock);fragment=tmpRng.extractContents();trimLeadingLineBreaks(fragment);newBlock=fragment.firstChild;dom.insertAfter(fragment,parentBlock);trimInlineElementsOnLeftSideOfBlock(newBlock);addBrToBlockIfNeeded(parentBlock);moveToCaretPosition(newBlock);} moveToCaretPosition(newBlock);}else if(isCaretAtStartOrEndOfBlock(true)){newBlock=parentBlock.parentNode.insertBefore(createNewBlock(),parentBlock);renderBlockOnIE(newBlock);}else{tmpRng=rng.cloneRange();tmpRng.setEndAfter(parentBlock);fragment=tmpRng.extractContents();trimLeadingLineBreaks(fragment);newBlock=fragment.firstChild;dom.insertAfter(fragment,parentBlock);trimInlineElementsOnLeftSideOfBlock(newBlock);addBrToBlockIfNeeded(parentBlock);moveToCaretPosition(newBlock);}
dom.setAttrib(newBlock,'id','');undoManager.add();} dom.setAttrib(newBlock,'id','');undoManager.add();}
editor.onKeyDown.add(function(ed,evt){if(evt.keyCode==13){if(handleEnterKey(evt)!==false){evt.preventDefault();}}});};})(tinymce); editor.onKeyDown.add(function(ed,evt){if(evt.keyCode==13){if(handleEnterKey(evt)!==false){evt.preventDefault();}}});};})(tinymce);

View File

@@ -219,6 +219,8 @@ class Publisher
$G_FORM->setValues( $Part['Data'] ); $G_FORM->setValues( $Part['Data'] );
$G_FORM->setValues( array ('G_FORM_ID' => $G_FORM->id ) ); $G_FORM->setValues( array ('G_FORM_ID' => $G_FORM->id ) );
//G::LoadSystem('CVarDumper');
//CVarDumper::dump($Part,10, true);
//Asegurese de que no entre cuando $Part['Template']=="grid" //Asegurese de que no entre cuando $Part['Template']=="grid"
//de hecho soo deberia usarse cuando $Part['Template']=="xmlform" //de hecho soo deberia usarse cuando $Part['Template']=="xmlform"

View File

@@ -1462,6 +1462,207 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek
} }
} }
/**
* render Field Grid
*
* @param type $value
* @param type $owner
* @param type $rowId
* @param type $ownerName
* @param type $index
* @return string
*/
public function renderFieldGrid($value = null, $owner = null, $rowId = '', $ownerName = '', $index = 0)
{
if (! $this->sqlConnection) {
$this->sqlConnection = 'workflow';
}
if ($this->strTo === 'UPPER') {
$value = strtoupper( $value );
}
if ($this->strTo === 'LOWER') {
$value = strtolower( $value );
}
$onkeypress = G::replaceDataField( $this->onkeypress, $owner->values );
if ($this->replaceTags == 1) {
$value = G::replaceDataField( $value, $owner->values );
}
$storeEntry = null;
$storeEntryData = ", storeEntryData: [0]";
if ($this->store_new_entry) {
$storeEntry = ' title="' . G::LoadTranslation( "ID_FIELD_DYNAFORM_SUGGEST_INPUT_TITLE" ) . '"';
$storeEntryData = ", storeEntryData: [1, \"form" . $rowId . "[" . $this->name . "_label]\", \"" . $this->sqlConnection . "\", \"" . $this->table . "\", \"" . $this->primary_key . "\", \"" . $this->primary_key_type . "\", \"" . $this->field . "\"]";
}
$formVariableValue = '';
$formVariableKeyValue = '';
G::LoadClass( 'case' );
$oApp = new Cases();
if (isset( $_SESSION['APPLICATION'] ) && ($_SESSION['APPLICATION'] != null && $oApp->loadCase( $_SESSION['APPLICATION'] ) != null)) {
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
if (isset( $aFields['APP_DATA'][$ownerName][$index][$this->name . '_label'] )) {
$formVariableValue = $aFields['APP_DATA'][$ownerName][$index][$this->name . '_label'];
$formVariableKeyValue = $aFields['APP_DATA'][$ownerName][$index][$this->name];
}
}
if ($this->mode === 'edit') {
if ($this->readOnly) {
return '<input class="module_app_input___gray" id="form' . $rowId . '[' . $this->name . ']" name="form' . $rowId . '[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
} else {
if (strlen( trim( $formVariableValue ) ) > 0) {
$value = $formVariableValue;
}
$name = "'" . $this->name . "'";
$str = '<input type="text" ' . $storeEntry . ' class="module_app_input___gray" size="' . $this->size . '" id="form' . $rowId . '[' . $this->name . '_label]" name="form' . $rowId . '[' . $this->name . '_label]" value="' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '" onblur="idSet(' . $name . ');" ';
$str .= $this->NSDependentFields( true ) . ' ';
$str .= '/>';
$str .= '<input ';
$str .= 'id="form' . $rowId . '[' . $this->name . ']" ';
$str .= 'name="form' . $rowId . '[' . $this->name . ']" ';
$str .= 'value="' . $this->htmlentities( $formVariableKeyValue, ENT_COMPAT, 'utf-8' ) . '" ';
$str .= 'type="hidden" />';
$str .= $this->renderHint();
if (trim( $this->callback ) != '') {
$sCallBack = 'try{' . $this->callback . '}catch(e){alert("Suggest Widget call back error: "+e)}';
} else {
$sCallBack = '';
}
$hash = str_rot13( base64_encode( $this->sql . '@|' . $this->sqlConnection ) );
$sSQL = $this->sql;
$nCount = preg_match_all( '/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sSQL, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
$sResult = array ();
if ($nCount) {
for ($i = 0; $i < $nCount; $i ++) {
if (isset( $match[0][$i][0] ) && isset( $match[2][$i][0] )) {
$aResult[$match[0][$i][0]] = $match[2][$i][0];
}
}
}
$depValues = '';
$i = 1;
if (isset( $aResult ) && $aResult) {
$sResult = '"' . implode( '","', $aResult ) . '"';
$aResultKeys = array_keys( $aResult );
$sResultKeys = str_rot13( base64_encode( implode( '|', $aResultKeys ) ) );
foreach ($aResult as $key => $field) {
$depValues .= 'getField("' . $field . '").value';
if ($i ++ < count( $aResult )) {
$depValues .= '+"|"+';
}
}
$depValues = '+' . $depValues . '+';
} else {
$sResult = '';
$sResultKeys = '';
$depValues = '+';
}
$aDepFields = array ();
$count = 0;
if ($this->dependentFields !== '') {
$dependentFields = explode( ",", $this->dependentFields );
foreach ($dependentFields as $keyDependent => $valueDependent) {
$sqlDepField = $owner->fields[$valueDependent]->sql;
$count = preg_match_all( '/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sqlDepField, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
for ($cnt = 0; $cnt < $count; $cnt ++) {
$aDepFields[$cnt] = $match[2][$cnt][0];
}
}
}
$sOptions = 'script: function (input) { ';
$rowIdField = substr($rowId, 1);
$sOptions .= ' var inputValue = base64_encode(getField("' . $rowIdField . '[' . $this->name . '_label").value); ';
$sOptions .= ' return "' . $this->ajaxServer . '?request=suggest&json=true&limit=' . $this->maxresults;
$sOptions .= '&hash=' . $hash . '&dependentFieldsKeys=' . $sResultKeys . '&dependentFieldsValue="';
$sOptions .= $depValues . '"&input="+inputValue+"&inputEnconde64=enable"; ';
$sOptions .= '},';
$sOptions .= 'json: true,';
$sOptions .= 'limit: ' . $this->maxresults . ',';
$sOptions .= 'shownoresults: ' . ($this->shownoresults ? 'true' : 'false') . ',';
$sOptions .= 'maxresults: ' . $this->maxresults . ',';
$sOptions .= 'chache: true,';
$sOptions .= 'callback: function (obj) { ';
$sOptions .= 'if (typeof obj != "undefined") { ';
$sOptions .= ' var jField = { };';
$sOptions .= ' var sField = "[]"; ';
if ($count > 0) {
for ($cnt = 0; $cnt < $count; $cnt ++) {
$sOptions .= 'if ( "' . $this->name . '" == "' . $aDepFields[$cnt] . '" ) {';
$sOptions .= ' jField["' . $aDepFields[$cnt] . '"] = obj.id;';
$sOptions .= '} else { ';
$sOptions .= ' jField["' . $aDepFields[$cnt] . '\'] = getField("' . $aDepFields[$cnt] . '").value; ';
$sOptions .= '}';
}
}
$sOptions .= ' var sField = "["+ encodeURIComponent(jField.toJSONString()) + "]"; ';
$sOptions .= $sCallBack . '; getField("' . $rowIdField . '[' . $this->name . '").value = obj.id;';
$sOwnerId = (isset($owner->owner->id))? $owner->owner->id : $owner->id;
$sOptions .= 'var response = ajax_function("../gulliver/defaultAjaxDynaform", "reloadField", ';
$sOptions .= ' "form=' . $sOwnerId . '&fields=" + sField, "POST"); ';
$sOptions .= 'if (response.substr(0,1) === "[") { ';
$sOptions .= ' var newcont; ';
$sOptions .= ' eval("newcont=" + response + ";"); ';
$sOptions .= ' for(var i = 0; i<newcont.length; i++) { ';
$sOptions .= ' var j = getField(newcont[i].name); ';
$sOptions .= ' getField(newcont[i].name).value = newcont[i].value; ';
$sOptions .= ' if (newcont[i].content.type == "dropdown") { ';
$sOptions .= ' fieldLength = getField(newcont[i].name).options.length; ';
$sOptions .= ' for (ni = 0; ni < fieldLength; ni++ ){ ';
$sOptions .= ' getField(newcont[i].name).options.remove(ni); ';
$sOptions .= ' } ';
$sOptions .= ' getField(newcont[i].name).length = 0; ';
$sOptions .= ' for (ni = 0; ni < newcont[i].content.options.length; ni++ ){ ';
$sOptions .= ' var opt = document.createElement("OPTION"); ';
$sOptions .= ' opt.value = newcont[i].content.options[ni].key; ';
$sOptions .= ' opt.text = newcont[i].content.options[ni].value; ';
$sOptions .= ' getField(newcont[i].name).options.add(opt); ';
$sOptions .= ' } ';
$sOptions .= ' } ';
$sOptions .= ' } ';
$sOptions .= '} else { ';
$sOptions .= ' alert("Invalid response: " + response); ';
$sOptions .= '} ';
$sOptions .= '} ';
$sOptions .= 'return false; ';
$sOptions .= '}';
$str .= '<script type="text/javascript">';
$str .= 'var as_json = new bsn.AutoSuggest("form' . $rowId . '[' . $this->name . '_label]", {' . $sOptions . $storeEntryData . '}); ';
$str .= '</script>';
return $str;
}
} else {
return $this->htmlentities( $formVariableValue, ENT_COMPAT, 'utf-8' );
}
}
/** /**
* Function renderGrid * Function renderGrid
* *
@@ -1473,27 +1674,14 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek
*/ */
public function renderGrid ($values = array(), $owner = null) public function renderGrid ($values = array(), $owner = null)
{ {
$result = array (); $aResult = array();
$r = 1; $r = 1;
foreach ($values as $v) {
if ($this->replaceTags == 1) {
$v = G::replaceDataField( $v, $owner->values );
}
if ($this->mode === 'edit') {
if ($this->readOnly) {
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '" readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>';
} else {
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>';
}
} elseif ($this->mode === 'view') {
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
} else {
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
}
$r ++;
}
return $result;
foreach ($values as $v) {
$aResult[] = $this->renderFieldGrid( $v, $owner, '[' . $owner->name . '][' . $r . ']', $owner->name, $r );
$r++;
}
return $aResult;
} }
/** /**
@@ -4164,8 +4352,8 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
$mask = '%Y-%m-%d'; //set default $mask = '%Y-%m-%d'; //set default
} }
if ($this->defaultValue != "") { if ($this->defaultValue != "") {
$defaultValue = masktophp( $mask, $defaultValue); $defaultValue = masktophp( $mask, $defaultValue);
} }
if (strpos( $mask, '%' ) === false) { if (strpos( $mask, '%' ) === false) {
@@ -5461,38 +5649,38 @@ function masktophp ($mask, $value)
if (preg_match('/S/',$tmp)) { if (preg_match('/S/',$tmp)) {
$tmp = str_replace("S", "s", $tmp); $tmp = str_replace("S", "s", $tmp);
} }
if (preg_match('/o/',$tmp)) { if (preg_match('/o/',$tmp)) {
$tmp = str_replace("o", "n", $tmp); $tmp = str_replace("o", "n", $tmp);
} }
if (preg_match('/a/',$tmp)) { if (preg_match('/a/',$tmp)) {
$tmp = str_replace("a", "D", $tmp); $tmp = str_replace("a", "D", $tmp);
} }
if (preg_match('/l/',$tmp)) { if (preg_match('/l/',$tmp)) {
$tmp = str_replace("l", "g", $tmp); $tmp = str_replace("l", "g", $tmp);
} }
if (preg_match('/A/',$tmp)) { if (preg_match('/A/',$tmp)) {
$tmp = str_replace("A", "l", $tmp); $tmp = str_replace("A", "l", $tmp);
} }
if (preg_match('/I/',$tmp)) { if (preg_match('/I/',$tmp)) {
$tmp = str_replace("I", "h", $tmp); $tmp = str_replace("I", "h", $tmp);
} }
if (preg_match('/j/',$tmp)) { if (preg_match('/j/',$tmp)) {
$tmp = str_replace("j", "z", $tmp); $tmp = str_replace("j", "z", $tmp);
} }
if (preg_match('/k/',$tmp)) { if (preg_match('/k/',$tmp)) {
$tmp = str_replace("k", "G", $tmp); $tmp = str_replace("k", "G", $tmp);
} }
if (preg_match('/e/',$tmp)) { if (preg_match('/e/',$tmp)) {
$tmp = str_replace("e", "j", $tmp); $tmp = str_replace("e", "j", $tmp);
} }
if (preg_match('/u/',$tmp)) { if (preg_match('/u/',$tmp)) {
$tmp = str_replace("u", "N", $tmp); $tmp = str_replace("u", "N", $tmp);
} }
if (preg_match('/p/',$tmp)) { if (preg_match('/p/',$tmp)) {
$tmp = str_replace("p", "A", $tmp); $tmp = str_replace("p", "A", $tmp);
} }
if (preg_match('/P/',$tmp)) { if (preg_match('/P/',$tmp)) {
$tmp = str_replace("P", "a", $tmp); $tmp = str_replace("P", "a", $tmp);
} }
if ($value == 'today') { if ($value == 'today') {

View File

@@ -47,9 +47,16 @@ switch (basename( $form->template, '.html' )) {
default: default:
$template = 'xmlform'; $template = 'xmlform';
} }
$G_PUBLISH->AddContent( 'dynaform', $template, $file, '', array ('__DYNAFORM_OPTIONS' => array ('PREVIOUS_STEP' => '#','NEXT_STEP' => '#','PREVIOUS_ACTION' => 'return false;','NEXT_ACTION' => 'return false;' $G_PUBLISH->AddContent(
) 'dynaform',
), '' ); $template,
$file,
'',
array ('__DYNAFORM_OPTIONS' =>
array ('PREVIOUS_STEP' => '#','NEXT_STEP' => '#','PREVIOUS_ACTION' => 'return false;','NEXT_ACTION' => 'return false;')
),
''
);
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );
/* $toolbar = new ToolBar( '/dynaforms/dynaforms_Toolbar' , PATH_XMLFORM, SYS_LANG, false ); /* $toolbar = new ToolBar( '/dynaforms/dynaforms_Toolbar' , PATH_XMLFORM, SYS_LANG, false );

View File

@@ -23,6 +23,9 @@
<!--<password type="toolButton" onclick="fieldsAdd('password')" file="images/dynamicForm/password.gif" fileAlt="images/dynamicForm/hover.gif" home="public_html" style="height:18px;width:18px;" buttonType="html"> <!--<password type="toolButton" onclick="fieldsAdd('password')" file="images/dynamicForm/password.gif" fileAlt="images/dynamicForm/hover.gif" home="public_html" style="height:18px;width:18px;" buttonType="html">
<en><![CDATA[<div class="ss_sprite button_toolbar ss_textfield_key" title="Password"></div>]]></en> <en><![CDATA[<div class="ss_sprite button_toolbar ss_textfield_key" title="Password"></div>]]></en>
</password>--> </password>-->
<suggest type="toolButton" class="ss_sprite button_toolbar ss_lightbulb" onclick="fieldsAdd('suggest')" buttonType="class">
<en>Suggest</en>
</suggest>
<textarea type="toolButton" class="ss_sprite button_toolbar ss_textarea" onclick="fieldsAdd('textarea')" buttonType="class"> <textarea type="toolButton" class="ss_sprite button_toolbar ss_textarea" onclick="fieldsAdd('textarea')" buttonType="class">
<en>TextArea</en> <en>TextArea</en>
</textarea> </textarea>