Add Pholio mock view basics
Summary:
Just laying more groundwork out of ready-made UI.
{F22349}
Test Plan: Looked at a mock.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3832
This commit is contained in:
@@ -40,28 +40,136 @@ final class PholioMockViewController extends PholioController {
|
|||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$phids = array();
|
||||||
|
$phids[] = $mock->getAuthorPHID();
|
||||||
|
$this->loadHandles($phids);
|
||||||
|
|
||||||
|
|
||||||
|
$engine = id(new PhabricatorMarkupEngine())
|
||||||
|
->setViewer($user);
|
||||||
|
$engine->addObject($mock, PholioMock::MARKUP_FIELD_DESCRIPTION);
|
||||||
|
$engine->process();
|
||||||
|
|
||||||
$title = 'M'.$mock->getID().' '.$mock->getName();
|
$title = 'M'.$mock->getID().' '.$mock->getName();
|
||||||
|
|
||||||
$header = id(new PhabricatorHeaderView())
|
$header = id(new PhabricatorHeaderView())
|
||||||
->setHeader($title);
|
->setHeader($title);
|
||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = $this->buildActionView($mock);
|
||||||
->setUser($user)
|
$properties = $this->buildPropertyView($mock, $engine);
|
||||||
->setObject($mock);
|
|
||||||
|
|
||||||
$properties = new PhabricatorPropertyListView();
|
$carousel =
|
||||||
|
'<h1 style="margin: 2em; padding: 1em; border: 1px dashed grey;">'.
|
||||||
|
'Carousel Goes Here</h1>';
|
||||||
|
$comments =
|
||||||
|
'<h1 style="margin: 2em; padding: 1em; border: 1px dashed grey;">'.
|
||||||
|
'Comments/Transactions Go Here</h1>';
|
||||||
|
|
||||||
|
$add_comment = $this->buildAddCommentView($mock);
|
||||||
|
|
||||||
$content = array(
|
$content = array(
|
||||||
$header,
|
$header,
|
||||||
$actions,
|
$actions,
|
||||||
$properties
|
$properties,
|
||||||
|
$carousel,
|
||||||
|
$comments,
|
||||||
|
$add_comment,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$content,
|
$content,
|
||||||
array(
|
array(
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
|
'device' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildActionView(PholioMock $mock) {
|
||||||
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
$actions = id(new PhabricatorActionListView())
|
||||||
|
->setUser($user)
|
||||||
|
->setObject($mock);
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$user,
|
||||||
|
$mock,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$actions->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setIcon('edit')
|
||||||
|
->setName(pht('Edit Mock'))
|
||||||
|
->setHref($this->getApplicationURI('/edit/'.$mock->getID()))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildPropertyView(
|
||||||
|
PholioMock $mock,
|
||||||
|
PhabricatorMarkupEngine $engine) {
|
||||||
|
|
||||||
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
$properties = new PhabricatorPropertyListView();
|
||||||
|
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('Author'),
|
||||||
|
$this->getHandle($mock->getAuthorPHID())->renderLink());
|
||||||
|
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('Created'),
|
||||||
|
phabricator_datetime($mock->getDateCreated(), $user));
|
||||||
|
|
||||||
|
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
|
||||||
|
$user,
|
||||||
|
$mock);
|
||||||
|
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('Visible To'),
|
||||||
|
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
|
||||||
|
|
||||||
|
$properties->addTextContent(
|
||||||
|
$engine->getOutput($mock, PholioMock::MARKUP_FIELD_DESCRIPTION));
|
||||||
|
|
||||||
|
return $properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildAddCommentView(PholioMock $mock) {
|
||||||
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
||||||
|
|
||||||
|
$title = $is_serious
|
||||||
|
? pht('Add Comment')
|
||||||
|
: pht('History Beckons');
|
||||||
|
|
||||||
|
$header = id(new PhabricatorHeaderView())
|
||||||
|
->setHeader($title);
|
||||||
|
|
||||||
|
$action = $is_serious
|
||||||
|
? pht('Add Comment')
|
||||||
|
: pht('Answer The Call');
|
||||||
|
|
||||||
|
$form = id(new AphrontFormView())
|
||||||
|
->setUser($user)
|
||||||
|
->setAction($this->getApplicationURI('/addcomment/'.$mock->getID().'/'))
|
||||||
|
->setWorkflow(true)
|
||||||
|
->setFlexible(true)
|
||||||
|
->appendChild(
|
||||||
|
id(new PhabricatorRemarkupControl())
|
||||||
|
->setName('comment')
|
||||||
|
->setLabel(pht('Comment')))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue($action));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$header,
|
||||||
|
$form,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ final class PhabricatorMarkupEngine {
|
|||||||
/**
|
/**
|
||||||
* @task engine
|
* @task engine
|
||||||
*/
|
*/
|
||||||
private static function newMarkupEngine(array $options) {
|
public static function newMarkupEngine(array $options) {
|
||||||
|
|
||||||
$options += self::getMarkupEngineDefaultConfiguration();
|
$options += self::getMarkupEngineDefaultConfiguration();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user