1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Give PHUITwoColumnView an addPropertySection method

Summary: Simplifies building pages a little more, adds a helper method to just add a property section to the main column automatically above other content.

Test Plan: Review Ponder, Herald, Passphrase, Countdown.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15377
This commit is contained in:
Chad Little 2016-03-01 12:14:28 -08:00
parent 2c43cccddf
commit caadd1025a
4 changed files with 46 additions and 33 deletions

View file

@ -34,7 +34,7 @@ final class HeraldRuleViewController extends HeraldController {
$actions = $this->buildActionView($rule);
$properties = $this->buildPropertyView($rule);
$details = $this->buildDetailsView($rule);
$details = $this->buildPropertySectionView($rule);
$id = $rule->getID();
@ -55,10 +55,8 @@ final class HeraldRuleViewController extends HeraldController {
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setMainColumn(array(
$details,
$timeline,
))
->setMainColumn($timeline)
->addPropertySection(pht('DETAILS'), $details)
->setPropertyList($properties)
->setActionList($actions);
@ -127,7 +125,7 @@ final class HeraldRuleViewController extends HeraldController {
return $view;
}
private function buildDetailsView(
private function buildPropertySectionView(
HeraldRule $rule) {
$viewer = $this->getRequest()->getUser();
@ -167,10 +165,7 @@ final class HeraldRuleViewController extends HeraldController {
$view->addTextContent($rule_text);
}
return id(new PHUIObjectBoxView())
->setHeaderText(pht('DETAILS'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($view);
return $view;
}
}

View file

@ -34,12 +34,13 @@ final class PassphraseCredentialViewController extends PassphraseController {
$actions = $this->buildActionView($credential, $type);
$properties = $this->buildPropertyView($credential, $type);
$subheader = $this->buildSubheaderView($credential);
$content = $this->buildDetailsView($credential, $type);
$content = $this->buildPropertySectionView($credential, $type);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setSubheader($subheader)
->setMainColumn(array($content, $timeline))
->setMainColumn($timeline)
->addPropertySection(pht('PROPERTIES'), $content)
->setPropertyList($properties)
->setActionList($actions);
@ -186,7 +187,7 @@ final class PassphraseCredentialViewController extends PassphraseController {
return $actions;
}
private function buildDetailsView(
private function buildPropertySectionView(
PassphraseCredential $credential,
PassphraseCredentialType $type) {
$viewer = $this->getRequest()->getUser();
@ -231,10 +232,7 @@ final class PassphraseCredentialViewController extends PassphraseController {
new PHUIRemarkupView($viewer, $description));
}
return id(new PHUIObjectBoxView())
->setHeaderText(pht('PROPERTIES'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($properties);
return $properties;
}
private function buildPropertyView(

View file

@ -44,7 +44,7 @@ final class PonderQuestionViewController extends PonderController {
$properties = $this->buildPropertyListView($question);
$actions = $this->buildActionListView($question);
$details = $this->buildDetailsPropertyView($question);
$details = $this->buildPropertySectionView($question);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
@ -107,7 +107,6 @@ final class PonderQuestionViewController extends PonderController {
'class' => 'ponder-question-content',
),
array(
$details,
$footer,
$comment_view,
$answer_wiki,
@ -120,6 +119,7 @@ final class PonderQuestionViewController extends PonderController {
->setSubheader($subheader)
->setMainColumn($ponder_content)
->setPropertyList($properties)
->addPropertySection(pht('DETAILS'), $details)
->setActionList($actions)
->addClass('ponder-question-view');
@ -222,7 +222,7 @@ final class PonderQuestionViewController extends PonderController {
->setContent($content);
}
private function buildDetailsPropertyView(
private function buildPropertySectionView(
PonderQuestion $question) {
$viewer = $this->getViewer();
@ -241,11 +241,7 @@ final class PonderQuestionViewController extends PonderController {
$question_details = phutil_tag_div(
'phabricator-remarkup ml', $question_details);
return id(new PHUIObjectBoxView())
->setHeaderText(pht('DETAILS'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setFlush(true)
->appendChild($question_details);
return $question_details;
}
/**
@ -274,7 +270,6 @@ final class PonderQuestionViewController extends PonderController {
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)));
$xactions = $timeline->getTransactions();
$view[] = id(new PonderAnswerView())
->setUser($viewer)
->setAnswer($answer)

View file

@ -8,6 +8,7 @@ final class PHUITwoColumnView extends AphrontTagView {
private $fluid;
private $header;
private $subheader;
private $propertySection = array();
private $actionList;
private $propertyList;
@ -34,6 +35,11 @@ final class PHUITwoColumnView extends AphrontTagView {
return $this;
}
public function addPropertySection($title, $section) {
$this->propertySection[] = array($title, $section);
return $this;
}
public function setActionList(PhabricatorActionListView $list) {
$this->actionList = $list;
return $this;
@ -83,13 +89,7 @@ final class PHUITwoColumnView extends AphrontTagView {
protected function getTagContent() {
require_celerity_resource('phui-two-column-view-css');
$main = phutil_tag(
'div',
array(
'class' => 'phui-main-column',
),
$this->mainColumn);
$main = $this->buildMainColumn();
$side = $this->buildSideColumn();
$order = array($side, $main);
@ -123,6 +123,31 @@ final class PHUITwoColumnView extends AphrontTagView {
));
}
private function buildMainColumn() {
$view = array();
$sections = $this->propertySection;
if ($sections) {
foreach ($sections as $content) {
$view[] = id(new PHUIObjectBoxView())
->setHeaderText($content[0])
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($content[1]);
}
}
return phutil_tag(
'div',
array(
'class' => 'phui-main-column',
),
array(
$view,
$this->mainColumn,
));
}
private function buildSideColumn() {
$property_list = $this->propertyList;
$action_list = $this->actionList;