Append new index with auto index selection (bug #3282127)
This commit is contained in:
parent
ba357a553e
commit
d3d6a9ae60
|
@ -299,11 +299,8 @@ function foreignAddRow(field) {
|
||||||
*/
|
*/
|
||||||
function indexesAddRow(field) {
|
function indexesAddRow(field) {
|
||||||
field.onchange = function () { };
|
field.onchange = function () { };
|
||||||
var row = field.parentNode.parentNode.cloneNode(true);
|
var parent = field.parentNode.parentNode;
|
||||||
var spans = row.getElementsByTagName('span');
|
var row = parent.cloneNode(true);
|
||||||
for (var i=0; i < spans.length - 1; i++) {
|
|
||||||
row.removeChild(spans[i]);
|
|
||||||
}
|
|
||||||
var selects = row.getElementsByTagName('select');
|
var selects = row.getElementsByTagName('select');
|
||||||
for (var i=0; i < selects.length; i++) {
|
for (var i=0; i < selects.length; i++) {
|
||||||
selects[i].name = selects[i].name.replace(/indexes\[\d+/, '$&1');
|
selects[i].name = selects[i].name.replace(/indexes\[\d+/, '$&1');
|
||||||
|
@ -312,7 +309,7 @@ function indexesAddRow(field) {
|
||||||
var input = row.getElementsByTagName('input')[0];
|
var input = row.getElementsByTagName('input')[0];
|
||||||
input.name = input.name.replace(/indexes\[\d+/, '$&1');
|
input.name = input.name.replace(/indexes\[\d+/, '$&1');
|
||||||
input.value = '';
|
input.value = '';
|
||||||
field.parentNode.parentNode.parentNode.appendChild(row);
|
parent.parentNode.appendChild(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add column for index
|
/** Add column for index
|
||||||
|
@ -320,18 +317,19 @@ function indexesAddRow(field) {
|
||||||
*/
|
*/
|
||||||
function indexesAddColumn(field) {
|
function indexesAddColumn(field) {
|
||||||
field.onchange = function () { };
|
field.onchange = function () { };
|
||||||
|
var select = field.form[field.name.replace(/\].*/, '][type]')];
|
||||||
|
if (!select.selectedIndex) {
|
||||||
|
select.selectedIndex = 3;
|
||||||
|
select.onchange();
|
||||||
|
}
|
||||||
var column = field.parentNode.cloneNode(true);
|
var column = field.parentNode.cloneNode(true);
|
||||||
var select = column.getElementsByTagName('select')[0];
|
select = column.getElementsByTagName('select')[0];
|
||||||
select.name = select.name.replace(/\]\[\d+/, '$&1');
|
select.name = select.name.replace(/\]\[\d+/, '$&1');
|
||||||
select.selectedIndex = 0;
|
select.selectedIndex = 0;
|
||||||
var input = column.getElementsByTagName('input')[0];
|
var input = column.getElementsByTagName('input')[0];
|
||||||
input.name = input.name.replace(/\]\[\d+/, '$&1');
|
input.name = input.name.replace(/\]\[\d+/, '$&1');
|
||||||
input.value = '';
|
input.value = '';
|
||||||
field.parentNode.parentNode.appendChild(column);
|
field.parentNode.parentNode.appendChild(column);
|
||||||
select = field.form[field.name.replace(/\].*/, '][type]')];
|
|
||||||
if (!select.selectedIndex) {
|
|
||||||
select.selectedIndex = 3;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue