Use a checkbox for the extra column
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
parent
80fad9010c
commit
536a9fd0e6
@ -22,7 +22,7 @@ if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) {
|
||||
if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
|
||||
$col_default = "";
|
||||
}
|
||||
$col_extra = $_POST['col_extra'];
|
||||
$col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : '';
|
||||
$col_isNull = isset($_POST['col_isNull'])?1:0;
|
||||
$col_length = $_POST['col_length'];
|
||||
$col_attribute = $_POST['col_attribute'];
|
||||
|
||||
@ -104,10 +104,8 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
$(this).hide();
|
||||
$('#f_' + rownum + ' td span').hide();
|
||||
$('#f_' + rownum + ' input, #f_' + rownum + ' select, #f_' + rownum + ' .open_enum_editor').show();
|
||||
var extra_val = $('#f_' + rownum + ' td[name=col_extra] span').html();
|
||||
var attribute_val = $('#f_' + rownum + ' td[name=col_attribute] span').html();
|
||||
$('#f_' + rownum + ' select[name=field_attribute\\['+ rownum +'\\] ] option[value="' + attribute_val + '"]').attr("selected","selected");
|
||||
$('#f_' + rownum + ' select[name=col_extra] option[value="' + extra_val + '"]').attr("selected","selected");
|
||||
if($('#f_' + rownum + ' .default_type').val() === 'USER_DEFINED') {
|
||||
$('#f_' + rownum + ' .default_type').siblings('.default_value').show();
|
||||
} else {
|
||||
@ -174,7 +172,7 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
$('#f_' + rownum + ' td[name=collation] span').text($('#f_' + rownum + ' select[name=collation]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_attribute] span').text($('#f_' + rownum + ' select[name=col_attribute]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_isNull] span').text($('#f_' + rownum +' input[name=col_isNull]').is(":checked")?"Yes":"No").html();
|
||||
$('#f_' + rownum + ' td[name=col_extra] span').text($('#f_' + rownum + ' select[name=col_extra]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_extra] span').text($('#f_' + rownum + ' input[name=col_extra]').is(":checked") ? "auto_increment" : "").html();
|
||||
$('#f_' + rownum + ' td[name=col_default] span').text($('#f_' + rownum + ' :input[name=col_default]').val()).html();
|
||||
}
|
||||
$('#save_' + rownum).hide();
|
||||
|
||||
@ -579,6 +579,9 @@ function PMA_updateMultipleColumn()
|
||||
} else if ($col_default[$i] == 'USER_DEFINED') {
|
||||
$col_default[$i] = $_POST['field_default_value'][$i];
|
||||
}
|
||||
if (! isset($_POST['col_extra'][$i])) {
|
||||
$col_extra[$i] = '';
|
||||
}
|
||||
$message = PMA_updateOneColumn(
|
||||
$db, $orig_col_name[$i], $col_name[$i], $col_type[$i],
|
||||
$col_attribute[$i], $col_length[$i], $col_isNull[$i], $collation[$i],
|
||||
@ -702,7 +705,7 @@ function PMA_getCentralColumnsTableHeader($class='', $title='', $actionCount=0)
|
||||
. '<th class="' . $class . '" title="' . $title . '" data-column="isnull">'
|
||||
. __('Null') . '<div class="sorticon"></div></th>'
|
||||
. '<th class="' . $class . '" title="' . $title . '" data-column="extra">'
|
||||
. __('Extra') . '<div class="sorticon"></div></th>'
|
||||
. __('A_I') . '<div class="sorticon"></div></th>'
|
||||
. '</tr>';
|
||||
$tableheader .= '</thead>';
|
||||
return $tableheader;
|
||||
@ -893,7 +896,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
|
||||
? htmlspecialchars($row['col_default']) : 'None')
|
||||
. '</span>'
|
||||
. PMA_getHtmlForColumnDefault(
|
||||
$row_num, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta
|
||||
$row_num, 3, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta
|
||||
)
|
||||
. '</td>';
|
||||
|
||||
@ -901,7 +904,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
|
||||
'<td name="collation" class="nowrap">'
|
||||
. '<span>' . htmlspecialchars($row['col_collation']) . '</span>'
|
||||
. PMA_getHtmlForColumnCollation(
|
||||
$row_num, 3, 0, array('Collation'=>$row['col_collation'])
|
||||
$row_num, 4, 0, array('Collation'=>$row['col_collation'])
|
||||
)
|
||||
. '</td>';
|
||||
$tableHtml .=
|
||||
@ -911,22 +914,22 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
|
||||
? htmlspecialchars($row['col_attribute']) : "" )
|
||||
. '</span>'
|
||||
. PMA_getHtmlForColumnAttribute(
|
||||
$row_num, 4, 0, array(), $row['col_attribute'], false, null
|
||||
$row_num, 5, 0, array(), $row['col_attribute'], false, null
|
||||
)
|
||||
. '</td>';
|
||||
$tableHtml .=
|
||||
'<td class="nowrap" name="col_isNull">'
|
||||
. '<span>' . ($row['col_isNull'] ? __('Yes') : __('No'))
|
||||
. '</span>'
|
||||
. PMA_getHtmlForColumnNull($row_num, 5, 0, array('Null'=>$row['col_isNull']))
|
||||
. PMA_getHtmlForColumnNull($row_num, 6, 0, array('Null'=>$row['col_isNull']))
|
||||
. '</td>';
|
||||
|
||||
$tableHtml .=
|
||||
'<td class="nowrap" name="col_extra"><span>'
|
||||
. htmlspecialchars($row['col_extra']) . '</span>'
|
||||
. '<select name="col_extra"><option value=""></option>'
|
||||
. '<option value="auto_increment">' . __('auto_increment') . '</option>'
|
||||
. '</select>'
|
||||
. PMA_getHtmlForColumnExtra(
|
||||
$row_num, 7, 0, array('Extra'=>$row['col_extra'])
|
||||
)
|
||||
. '</td>';
|
||||
|
||||
$tableHtml .= '</tr>';
|
||||
@ -981,35 +984,32 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
|
||||
$tableHtml .=
|
||||
'<td class="nowrap" name="col_default">'
|
||||
. PMA_getHtmlForColumnDefault(
|
||||
$row_num, 6, 0, /*overload*/mb_strtoupper($row['col_default']), '', $meta
|
||||
$row_num, 3, 0, /*overload*/mb_strtoupper($row['col_default']), '', $meta
|
||||
)
|
||||
. '</td>';
|
||||
$tableHtml .=
|
||||
'<td name="collation" class="nowrap">'
|
||||
. PMA_getHtmlForColumnCollation(
|
||||
$row_num, 3, 0, array('Collation'=>$row['col_collation'])
|
||||
$row_num, 4, 0, array('Collation'=>$row['col_collation'])
|
||||
)
|
||||
. '</td>';
|
||||
$tableHtml .=
|
||||
'<td class="nowrap" name="col_attribute">'
|
||||
. PMA_getHtmlForColumnAttribute(
|
||||
$row_num, 4, 0, array("attribute"=>$row['col_attribute']),
|
||||
$row_num, 5, 0, array("attribute"=>$row['col_attribute']),
|
||||
array(), false, null
|
||||
)
|
||||
. '</td>';
|
||||
$tableHtml .=
|
||||
'<td class="nowrap" name="col_isNull">'
|
||||
. PMA_getHtmlForColumnNull($row_num, 5, 0, array('Null'=>$row['col_isNull']))
|
||||
. PMA_getHtmlForColumnNull($row_num, 6, 0, array('Null'=>$row['col_isNull']))
|
||||
. '</td>';
|
||||
$extra_val = $row['col_extra'];
|
||||
$tableHtml .=
|
||||
'<td class="nowrap" name="col_extra">'
|
||||
. '<select name="col_extra[' . $row_num . ']">'
|
||||
. '<option value="" ' . ($extra_val==""?'selected="selected"':'')
|
||||
. '></option>'
|
||||
. '<option ' . ($extra_val=="auto_increment"?'selected="selected"':'') . ''
|
||||
. ' value="auto_increment">' . __('auto_increment') . '</option>'
|
||||
. '</select>'
|
||||
. PMA_getHtmlForColumnExtra(
|
||||
$row_num, 7, 0, array('Extra' => $row['col_extra'])
|
||||
)
|
||||
. '</td>';
|
||||
$tableHtml .= '</tr>';
|
||||
return $tableHtml;
|
||||
@ -1167,23 +1167,21 @@ function PMA_getHTMLforAddNewColumn($db)
|
||||
. PMA_getHtmlForColumnLength(0, 2, 0, 8, '')
|
||||
. '</td>'
|
||||
. '<td class="nowrap" name="col_default">'
|
||||
. PMA_getHtmlForColumnDefault(0, 6, 0, '', '', array())
|
||||
. PMA_getHtmlForColumnDefault(0, 3, 0, '', '', array())
|
||||
. '</td>'
|
||||
. '<td name="collation" class="nowrap">'
|
||||
. PMA_getHtmlForColumnCollation(
|
||||
0, 3, 0, array()
|
||||
0, 4, 0, array()
|
||||
)
|
||||
. '</td>'
|
||||
. '<td class="nowrap" name="col_attribute">'
|
||||
. PMA_getHtmlForColumnAttribute(0, 4, 0, array(), array(), false, null)
|
||||
. PMA_getHtmlForColumnAttribute(0, 5, 0, array(), array(), false, null)
|
||||
. '</td>'
|
||||
. '<td class="nowrap" name="col_isNull">'
|
||||
. PMA_getHtmlForColumnNull(0, 5, 0, array())
|
||||
. PMA_getHtmlForColumnNull(0, 6, 0, array())
|
||||
. '</td>'
|
||||
. '<td class="nowrap" name="col_extra">'
|
||||
. '<select name="col_extra"><option value="">'
|
||||
. '<option value="auto_increment">' . __('auto_increment') . '</option>'
|
||||
. '</select>'
|
||||
. PMA_getHtmlForColumnExtra(0, 7, 0, array())
|
||||
. '</td>'
|
||||
. ' <td>'
|
||||
. '<input id="add_column_save" type="submit" '
|
||||
@ -1206,7 +1204,7 @@ function PMA_getHTMLforEditingPage($selected_fld,$selected_db)
|
||||
$html = '<form id="multi_edit_central_columns">';
|
||||
$header_cells = array(
|
||||
__('Name'), __('Type'), __('Length/Values'), __('Default'),
|
||||
__('Collation'), __('Attributes'), __('Null'), __('Extra')
|
||||
__('Collation'), __('Attributes'), __('Null'), __('A_I')
|
||||
);
|
||||
$html .= PMA_getCentralColumnsEditTableHeader($header_cells);
|
||||
$selected_fld_safe = array();
|
||||
|
||||
@ -981,6 +981,31 @@ function PMA_getHtmlForColumnNull($columnNumber, $ci, $ci_offset, $columnMeta)
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for column A_I
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnExtra($columnNumber, $ci, $ci_offset, $columnMeta)
|
||||
{
|
||||
$html = '<input name="col_extra[' . $columnNumber . ']"'
|
||||
. ' id="field_' . $columnNumber . '_' . ($ci - $ci_offset) . '"';
|
||||
if (! empty($columnMeta['Extra'])
|
||||
&& $columnMeta['Extra'] == 'auto_increment'
|
||||
) {
|
||||
$html .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$html .= ' type="checkbox" value="auto_increment" />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for column attribute
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user