Skip to content

Commit

Permalink
Fix alignment of action and fixed tests #12167
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Jain <ankitjain28may77@gmail.com>
  • Loading branch information
ankitjain28may committed Sep 25, 2017
1 parent f4c6738 commit 9b56aca
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 120 deletions.
74 changes: 42 additions & 32 deletions libraries/classes/Display/Results.php
Expand Up @@ -1329,21 +1329,16 @@ private function _getTableHeaders(
$displayParts['del_lnk']
);

// 1. Set $colspan and generate html with full/partial
// text button or link
list($colspan, $button_html)
= $this->_getFieldVisibilityParams(
$displayParts, $full_or_partial_text_link
);
$table_headers_html .= '<thead><tr>' . "\n";

$table_headers_html .= $button_html;

// 2. Displays the fields' name
// 2.0 If sorting links should be used, checks if the query is a "JOIN"
// 1. Displays the fields' name
// 1.0 If sorting links should be used, checks if the query is a "JOIN"
// statement (see 2.1.3)

// See if we have to highlight any header fields of a WHERE query.
// Uses SQL-Parser results.

$this->_setHighlightedColumnGlobalField($analyzed_sql_results);

// Get the headers for all of the columns
Expand All @@ -1353,6 +1348,17 @@ private function _getTableHeaders(
$is_limited_display, $unsorted_sql_query
);

// 2. Set $colspan and generate html with full/partial
// text button or link
list($colspan, $button_html)
= $this->_getFieldVisibilityParams(
$displayParts, $full_or_partial_text_link
);

$table_headers_html .= $button_html;



// Display column at rightside - checkboxes or empty column
if (! $printview) {
$table_headers_html .= $this->_getColumnAtRightSide(
Expand Down Expand Up @@ -1524,7 +1530,7 @@ private function _getFieldVisibilityParams(
$display_params = $this->__get('display_params');

// 1. Displays the full/partial text button (part 1)...
$button_html .= '<thead><tr>' . "\n";
// $button_html .= '<thead><tr>' . "\n";

$colspan = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE)
&& ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE))
Expand Down Expand Up @@ -2770,7 +2776,25 @@ private function _getTableBody(
$del_url = $del_str = $edit_anchor_class
= $edit_str = $js_conf = $copy_url = $copy_str = $edit_url = null;

// 1.2 Defines the URLs for the modify/delete link(s)
// 1.2 Displays the rows' values
if (is_null($this->__get('mime_map'))) {
$this->_setMimeMap();
}
$table_body_html .= $this->_getRowValues(
$dt_result,
$row,
$row_no,
$col_order,
$map,
$grid_edit_class,
$col_visib,
$url_sql_query,
$analyzed_sql_results
); // end (1)

// 2 Defines the Action

// 2.1 Defines the URLs for the modify/delete link(s)

if (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE)
|| ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)
Expand Down Expand Up @@ -2798,7 +2822,7 @@ private function _getTableBody(

$where_clause_html = htmlspecialchars($where_clause);

// 1.2.1 Modify link(s) - update row case
// 2.1.1 Modify link(s) - update row case
if ($displayParts['edit_lnk'] == self::UPDATE_ROW) {

list($edit_url, $copy_url, $edit_str, $copy_str,
Expand All @@ -2808,17 +2832,17 @@ private function _getTableBody(
$clause_is_unique, $url_sql_query
);

} // end if (1.2.1)
} // end if (2.1.1)

// 1.2.2 Delete/Kill link(s)
// 2.1.2 Delete/Kill link(s)
list($del_url, $del_str, $js_conf)
= $this->_getDeleteAndKillLinks(
$where_clause, $clause_is_unique,
$url_sql_query, $displayParts['del_lnk'],
$row
);

// 1.3 Displays the links at left if required
// 2.1.3 Displays the links at left if required
if (($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT)
|| ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH)
) {
Expand All @@ -2839,24 +2863,10 @@ private function _getTableBody(
$edit_str, $copy_str, $del_str, $js_conf
);

} // end if (1.3)
} // end if (1)
} // end if (2.1.3)
} // end if (2)


// 2. Displays the rows' values
if (is_null($this->__get('mime_map'))) {
$this->_setMimeMap();
}
$table_body_html .= $this->_getRowValues(
$dt_result,
$row,
$row_no,
$col_order,
$map,
$grid_edit_class,
$col_visib,
$url_sql_query,
$analyzed_sql_results
);

// 3. Displays the modify/delete links on the right if required
if (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE)
Expand Down
20 changes: 11 additions & 9 deletions templates/database/structure/body_for_table_summary.phtml
Expand Up @@ -6,15 +6,7 @@
printf(_ngettext('%s table', '%s tables', $num_tables),
PhpMyAdmin\Util::formatNumber($num_tables, 0)); ?>
</th>
<?php if ($server_slave_status): ?>
<th> <?= __('Replication'); ?> </th>
<?php endif; ?>
<?php
$sum_colspan = ($db_is_system_schema ? 4 : 7);
if ($GLOBALS['cfg']['NumFavoriteTables'] == 0) {
$sum_colspan--;
} ?>
<th colspan="<?= $sum_colspan; ?>" class="print_ignore" ><?= __('Sum'); ?></th>

<?php
$row_count_sum = PhpMyAdmin\Util::formatNumber($sum_entries, 0);
// If a table shows approximate rows count, display update-all-real-count anchor.
Expand Down Expand Up @@ -71,6 +63,16 @@ $cell_text = ($approx_rows)
<th class="value tbl_overhead"><?= $overhead_formatted , ' ' , $overhead_unit; ?></th>
<?php endif; ?>
<?php if ($server_slave_status): ?>
<th> <?= __('Replication'); ?> </th>
<?php endif; ?>
<?php
$sum_colspan = ($db_is_system_schema ? 4 : 7);
if ($GLOBALS['cfg']['NumFavoriteTables'] == 0) {
$sum_colspan--;
} ?>
<th colspan="<?= $sum_colspan; ?>" class="print_ignore" ><?= __('Sum'); ?></th>

<?php if ($GLOBALS['cfg']['ShowDbStructureCharset']): ?>
<th>
<?= $db_charset; ?>
Expand Down
80 changes: 41 additions & 39 deletions templates/database/structure/structure_table_row.phtml
Expand Up @@ -17,46 +17,7 @@
</td>
<?php endif; ?>

<?php
//Favorite table anchor.
?>
<?php if ($GLOBALS['cfg']['NumFavoriteTables'] > 0): ?>
<td class="center print_ignore">
<?= PhpMyAdmin\Template::get('database/structure/favorite_anchor')->render(
array(
'db' => $db,
'current_table' => $current_table,
'titles' => $titles,
'already_favorite' => $already_favorite
)
); ?>
</td>
<?php endif; ?>

<td class="center print_ignore">
<?= $browse_table; ?>
</td>
<td class="center print_ignore">
<a href="tbl_structure.php<?= $tbl_url_query; ?>">
<?= $titles['Structure']; ?>
</a>
</td>
<td class="center print_ignore">
<?= $search_table; ?>
</td>

<?php if (!$db_is_system_schema): ?>
<td class="insert_table center print_ignore">
<a href="tbl_change.php<?= $tbl_url_query; ?>"><?= $titles['Insert']; ?></a>
</td>
<td class="center print_ignore"><?= $empty_table; ?></td>
<td class="center print_ignore">
<a class="ajax drop_table_anchor <?= ($table_is_view || $current_table['ENGINE'] == null) ? ' view' : '' ?>"
href="sql.php<?= $tbl_url_query; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?= urlencode($drop_query); ?>&amp;message_to_show=<?= urlencode($drop_message); ?>" >
<?= $titles['Drop']; ?>
</a>
</td>
<?php endif; ?>

<?php if (isset($current_table['TABLE_ROWS']) &&
($current_table['ENGINE'] != null || $table_is_view)): ?>
Expand Down Expand Up @@ -116,6 +77,47 @@
</td>
<?php endif; ?>

<?php
//Favorite table anchor.
?>
<?php if ($GLOBALS['cfg']['NumFavoriteTables'] > 0): ?>
<td class="center print_ignore">
<?= PhpMyAdmin\Template::get('database/structure/favorite_anchor')->render(
array(
'db' => $db,
'current_table' => $current_table,
'titles' => $titles,
'already_favorite' => $already_favorite
)
); ?>
</td>
<?php endif; ?>

<td class="center print_ignore">
<?= $browse_table; ?>
</td>
<td class="center print_ignore">
<a href="tbl_structure.php<?= $tbl_url_query; ?>">
<?= $titles['Structure']; ?>
</a>
</td>
<td class="center print_ignore">
<?= $search_table; ?>
</td>

<?php if (!$db_is_system_schema): ?>
<td class="insert_table center print_ignore">
<a href="tbl_change.php<?= $tbl_url_query; ?>"><?= $titles['Insert']; ?></a>
</td>
<td class="center print_ignore"><?= $empty_table; ?></td>
<td class="center print_ignore">
<a class="ajax drop_table_anchor <?= ($table_is_view || $current_table['ENGINE'] == null) ? ' view' : '' ?>"
href="sql.php<?= $tbl_url_query; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?= urlencode($drop_query); ?>&amp;message_to_show=<?= urlencode($drop_message); ?>" >
<?= $titles['Drop']; ?>
</a>
</td>
<?php endif; ?>

<?php if (!($GLOBALS['cfg']['ShowDbStructureCharset'] > 1)): ?>
<?php if (strlen($charset)): ?>
<td class="nowrap">
Expand Down
6 changes: 3 additions & 3 deletions templates/database/structure/table_header.phtml
Expand Up @@ -27,9 +27,6 @@ if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) {
<?php if ($replication): ?>
<th><?= __('Replication'); ?></th>
<?php endif; ?>
<th colspan="<?= $action_colspan; ?>" class="print_ignore">
<?= __('Action'); ?>
</th>
<!-- larger values are more interesting so default sort order is DESC-->
<th>
<?= PhpMyAdmin\Template::get('database/structure/sortable_header')->render(
Expand Down Expand Up @@ -78,6 +75,9 @@ if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) {
)
); $cnt++; ?></th>
<?php endif; ?>
<th colspan="<?= $action_colspan; ?>" class="print_ignore">
<?= __('Action'); ?>
</th>

<?php if ($GLOBALS['cfg']['ShowDbStructureCharset']): ?>
<th><?= PhpMyAdmin\Template::get('database/structure/sortable_header')->render(
Expand Down
8 changes: 4 additions & 4 deletions test/selenium/PmaSeleniumSqlQueryTest.php
Expand Up @@ -148,19 +148,19 @@ public function testTableSqlQuery()
$this->waitForElement('byCssSelector', 'table.table_results');
$this->assertEquals(
3,
$this->getCellByTableClass('table_results', 1, 5)
$this->getCellByTableClass('table_results', 1, 1)
);
$this->assertEquals(
4,
$this->getCellByTableClass('table_results', 2, 5)
$this->getCellByTableClass('table_results', 2, 1)
);
$this->assertEquals(
4,
$this->getCellByTableClass('table_results', 1, 6)
$this->getCellByTableClass('table_results', 1, 2)
);
$this->assertEquals(
5,
$this->getCellByTableClass('table_results', 2, 6)
$this->getCellByTableClass('table_results', 2, 2)
);

// test inline edit button
Expand Down

0 comments on commit 9b56aca

Please sign in to comment.