1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-09 21:38:29 +01:00
phorge-phorge/src/applications/differential/view/DifferentialResultsTableView.php
epriestley 31b6f69ff7 Allow CelerityResourceResponse to hold resources from multiple maps
Summary:
Ref T4222. Currently, CelerityResourceResponse holds response resources in flat maps. Instead, specify which map resources appear in.

Also, provide `requireResource()` and `initBehavior()` APIs on the Controller and View base classes. These provide a cleaner abstraction over `require_celerity_resource()` and `Javelin::initBehavior()`, but are otherwise the same. Move a few callsites over.

Test Plan:
  - Reloaded pages.
  - Browsed around Differential.

Reviewers: btrahan, hach-que

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4222

Differential Revision: https://secure.phabricator.com/D7876
2014-01-02 11:59:35 -08:00

115 lines
2.5 KiB
PHP

<?php
final class DifferentialResultsTableView extends AphrontView {
private $rows;
private $showMoreString;
public function setRows(array $rows) {
$this->rows = $rows;
return $this;
}
public function setShowMoreString($show_more_string) {
$this->showMoreString = $show_more_string;
return $this;
}
public function render() {
$rows = array();
$any_hidden = false;
foreach ($this->rows as $row) {
$style = idx($row, 'style');
switch ($style) {
case 'section':
$cells = phutil_tag(
'th',
array(
'colspan' => 2,
),
idx($row, 'name'));
break;
default:
$name = phutil_tag(
'th',
array(
),
idx($row, 'name'));
$value = phutil_tag(
'td',
array(
),
idx($row, 'value'));
$cells = array($name, $value);
break;
}
$show = idx($row, 'show');
$rows[] = javelin_tag(
'tr',
array(
'style' => $show ? null : 'display: none',
'sigil' => $show ? null : 'differential-results-row-toggle',
'class' => 'differential-results-row-'.$style,
),
$cells);
if (!$show) {
$any_hidden = true;
}
}
if ($any_hidden) {
$show_more = javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
),
$this->showMoreString);
$hide_more = javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
),
'Hide');
$rows[] = javelin_tag(
'tr',
array(
'class' => 'differential-results-row-show',
'sigil' => 'differential-results-row-show',
),
phutil_tag('th', array('colspan' => 2), $show_more));
$rows[] = javelin_tag(
'tr',
array(
'class' => 'differential-results-row-show',
'sigil' => 'differential-results-row-hide',
'style' => 'display: none',
),
phutil_tag('th', array('colspan' => 2), $hide_more));
$this->initBehavior('differential-show-field-details');
}
$this->requireResource('differential-results-table-css');
return javelin_tag(
'table',
array(
'class' => 'differential-results-table',
'sigil' => 'differential-results-table',
),
$rows);
}
}