BUG 6757 Request for IDs to Add Link into Grids solved.
- html ids have been added to template - function deleteGridRow has an optional parameter to ask or not about deleting confirmation. - improve in event ondeleterow, now it returns last row deleted.
This commit is contained in:
@@ -448,7 +448,8 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
this.deleteGridRow = function(sRow) {
|
this.deleteGridRow = function(sRow, bWithoutConfirm){
|
||||||
|
if (typeof bWithoutConfirm == 'undefined') bWithoutConfirm = false;
|
||||||
var i, iRow, iRowAux, oAux, ooAux;
|
var i, iRow, iRowAux, oAux, ooAux;
|
||||||
if (this.oGrid.rows.length == 3) {
|
if (this.oGrid.rows.length == 3) {
|
||||||
new leimnud.module.app.alert().make( {
|
new leimnud.module.app.alert().make( {
|
||||||
@@ -456,10 +457,20 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (bWithoutConfirm){
|
||||||
|
this.deleteRowWC(this,sRow).extend(this);
|
||||||
|
}else{
|
||||||
new leimnud.module.app.confirm().make( {
|
new leimnud.module.app.confirm().make( {
|
||||||
label : G_STRINGS.ID_MSG_DELETE_GRID_ITEM,
|
label : G_STRINGS.ID_MSG_DELETE_GRID_ITEM,
|
||||||
action : function() {
|
action : function() {
|
||||||
//this.aElements = [];
|
this.deleteRowWC(this,sRow);
|
||||||
|
}.extend(this)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.deleteRowWC = function(oObj, aRow){
|
||||||
|
sRow = new String(aRow);
|
||||||
sRow = sRow.replace('[', '');
|
sRow = sRow.replace('[', '');
|
||||||
sRow = sRow.replace(']', '');
|
sRow = sRow.replace(']', '');
|
||||||
iRow = Number(sRow);
|
iRow = Number(sRow);
|
||||||
@@ -469,13 +480,13 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
* Dynaform - by Nyeke <erik@colosa.com
|
* Dynaform - by Nyeke <erik@colosa.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
deleteRowOnDynaform(this, iRow);
|
deleteRowOnDynaform(oObj, iRow);
|
||||||
|
|
||||||
iRowAux = iRow + 1;
|
iRowAux = iRow + 1;
|
||||||
while (iRowAux <= (this.oGrid.rows.length - 2)) {
|
while (iRowAux <= (oObj.oGrid.rows.length - 2)) {
|
||||||
for (i = 1; i < this.oGrid.rows[iRowAux - 1].cells.length; i++) {
|
for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) {
|
||||||
var oCell1 = this.oGrid.rows[iRowAux - 1].cells[i];
|
var oCell1 = oObj.oGrid.rows[iRowAux - 1].cells[i];
|
||||||
var oCell2 = this.oGrid.rows[iRowAux].cells[i];
|
var oCell2 = oObj.oGrid.rows[iRowAux].cells[i];
|
||||||
switch (oCell1.innerHTML.replace(/^\s+|\s+$/g, '').substr(0, 6).toLowerCase()){
|
switch (oCell1.innerHTML.replace(/^\s+|\s+$/g, '').substr(0, 6).toLowerCase()){
|
||||||
case '<input':
|
case '<input':
|
||||||
aObjects1 = oCell1.getElementsByTagName('input');
|
aObjects1 = oCell1.getElementsByTagName('input');
|
||||||
@@ -495,11 +506,11 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
if (aObjects.length > 0) {
|
if (aObjects.length > 0) {
|
||||||
|
|
||||||
if (aObjects[0]) {
|
if (aObjects[0]) {
|
||||||
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]');
|
||||||
aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]');
|
||||||
if (aObjects[0].onclick) {
|
if (aObjects[0].onclick) {
|
||||||
sAux = new String(aObjects[0].onclick);
|
sAux = new String(aObjects[0].onclick);
|
||||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]') + ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aObjects = oCell1.getElementsByTagName('a');
|
aObjects = oCell1.getElementsByTagName('a');
|
||||||
@@ -507,7 +518,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
if (aObjects[0]) {
|
if (aObjects[0]) {
|
||||||
if (aObjects[0].onclick) {
|
if (aObjects[0].onclick) {
|
||||||
sAux = new String(aObjects[0].onclick);
|
sAux = new String(aObjects[0].onclick);
|
||||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]') + ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -553,7 +564,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
}
|
}
|
||||||
iRowAux++;
|
iRowAux++;
|
||||||
}
|
}
|
||||||
this.oGrid.deleteRow(this.oGrid.rows.length - 2);
|
this.oGrid.deleteRow(oObj.oGrid.rows.length - 2);
|
||||||
if (this.sAJAXPage != '') {
|
if (this.sAJAXPage != '') {
|
||||||
}
|
}
|
||||||
/* this slice of code was comented because it could be the problem to do that sum function is working wrong
|
/* this slice of code was comented because it could be the problem to do that sum function is working wrong
|
||||||
@@ -562,53 +573,50 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
}*/
|
}*/
|
||||||
//this slice of code was added to fill the grid after to delete some row
|
//this slice of code was added to fill the grid after to delete some row
|
||||||
this.aElements = [];
|
this.aElements = [];
|
||||||
for (var k=1;k<= this.oGrid.rows.length-2;k++){
|
for (var k=1;k<= oObj.oGrid.rows.length-2;k++){
|
||||||
for (var i = 0; i < this.aFields.length; i++) {
|
for (var i = 0; i < oObj.aFields.length; i++) {
|
||||||
var j = k;
|
var j = k;
|
||||||
switch (this.aFields[i].sType) {
|
switch (oObj.aFields[i].sType) {
|
||||||
case 'text':
|
case 'text':
|
||||||
this.aElements.push(new G_Text(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName));
|
oObj.aElements.push(new G_Text(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName));
|
||||||
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
|
oObj.aElements[oObj.aElements.length - 1].validate = oObj.aFields[i].oProperties.validate;
|
||||||
if(this.aFields[i].oProperties.strTo) {
|
if(oObj.aFields[i].oProperties.strTo) {
|
||||||
this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
|
oObj.aElements[oObj.aElements.length - 1].strTo = oObj.aFields[i].oProperties.strTo;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'currency':
|
case 'currency':
|
||||||
this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
|
oObj.aElements.push(new G_Currency(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j + ']['+ oObj.aFields[i].sFieldName));
|
||||||
break;
|
break;
|
||||||
case 'percentage':
|
case 'percentage':
|
||||||
this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j+ '][' + this.aFields[i].sFieldName));
|
oObj.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j+ '][' + oObj.aFields[i].sFieldName));
|
||||||
break;
|
break;
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
|
oObj.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j + ']['+ oObj.aFields[i].sFieldName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.aFunctions.length > 0) {
|
if (oObj.aFunctions.length > 0) {
|
||||||
for (i = 0; i < this.aFunctions.length; i++) {
|
for (i = 0; i < oObj.aFunctions.length; i++) {
|
||||||
oAux = document.getElementById('form[' + this.sGridName + '][1][' + this.aFunctions[i].sFieldName + ']');
|
oAux = document.getElementById('form[' + oObj.sGridName + '][1][' + oObj.aFunctions[i].sFieldName + ']');
|
||||||
if (oAux) {
|
if (oAux) {
|
||||||
switch (this.aFunctions[i].sFunction) {
|
switch (oObj.aFunctions[i].sFunction) {
|
||||||
case 'sum':
|
case 'sum':
|
||||||
this.sum(false, oAux);
|
oObj.sum(false, oAux);
|
||||||
break;
|
break;
|
||||||
case 'avg':
|
case 'avg':
|
||||||
this.avg(false, oAux);
|
oObj.avg(false, oAux);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Fires OnAddRow Event
|
//Fires OnAddRow Event
|
||||||
if (this.ondeleterow) {
|
if (oObj.ondeleterow) {
|
||||||
this.ondeleterow();
|
oObj.ondeleterow(iRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.extend(this)
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
{if ($form->addRow) }
|
{if ($form->addRow) }
|
||||||
<table class='Record'>
|
<table class='Record'>
|
||||||
<tr><td></td>
|
<tr><td></td>
|
||||||
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" /> <a class="GridLink" href="#" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow();return false;">{$form->NewLabel}</a></td>
|
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" /> <a id="form[{$form->name}][addLink]" class="GridLink" href="#" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow();return false;">{$form->NewLabel}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user