1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01: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); $actions = $this->buildActionView($rule);
$properties = $this->buildPropertyView($rule); $properties = $this->buildPropertyView($rule);
$details = $this->buildDetailsView($rule); $details = $this->buildPropertySectionView($rule);
$id = $rule->getID(); $id = $rule->getID();
@ -55,10 +55,8 @@ final class HeraldRuleViewController extends HeraldController {
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setMainColumn(array( ->setMainColumn($timeline)
$details, ->addPropertySection(pht('DETAILS'), $details)
$timeline,
))
->setPropertyList($properties) ->setPropertyList($properties)
->setActionList($actions); ->setActionList($actions);
@ -127,7 +125,7 @@ final class HeraldRuleViewController extends HeraldController {
return $view; return $view;
} }
private function buildDetailsView( private function buildPropertySectionView(
HeraldRule $rule) { HeraldRule $rule) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
@ -167,10 +165,7 @@ final class HeraldRuleViewController extends HeraldController {
$view->addTextContent($rule_text); $view->addTextContent($rule_text);
} }
return id(new PHUIObjectBoxView()) return $view;
->setHeaderText(pht('DETAILS'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($view);
} }
} }

View file

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

View file

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

View file

@ -8,6 +8,7 @@ final class PHUITwoColumnView extends AphrontTagView {
private $fluid; private $fluid;
private $header; private $header;
private $subheader; private $subheader;
private $propertySection = array();
private $actionList; private $actionList;
private $propertyList; private $propertyList;
@ -34,6 +35,11 @@ final class PHUITwoColumnView extends AphrontTagView {
return $this; return $this;
} }
public function addPropertySection($title, $section) {
$this->propertySection[] = array($title, $section);
return $this;
}
public function setActionList(PhabricatorActionListView $list) { public function setActionList(PhabricatorActionListView $list) {
$this->actionList = $list; $this->actionList = $list;
return $this; return $this;
@ -83,13 +89,7 @@ final class PHUITwoColumnView extends AphrontTagView {
protected function getTagContent() { protected function getTagContent() {
require_celerity_resource('phui-two-column-view-css'); require_celerity_resource('phui-two-column-view-css');
$main = phutil_tag( $main = $this->buildMainColumn();
'div',
array(
'class' => 'phui-main-column',
),
$this->mainColumn);
$side = $this->buildSideColumn(); $side = $this->buildSideColumn();
$order = array($side, $main); $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() { private function buildSideColumn() {
$property_list = $this->propertyList; $property_list = $this->propertyList;
$action_list = $this->actionList; $action_list = $this->actionList;