1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 05:42:40 +01:00

Update Legalpad with modern UI

Summary: Updates Legalpad Manage/Edit with new UI layouts.

Test Plan: Wrote a new document with and without a preamble, edit document, sign document

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15576
This commit is contained in:
Chad Little 2016-04-03 00:25:03 +00:00 committed by chad
parent bdeb5cf141
commit 72d12be850
2 changed files with 79 additions and 59 deletions

View file

@ -220,27 +220,30 @@ final class LegalpadDocumentEditController extends LegalpadController {
$submit->addCancelButton($this->getApplicationURI()); $submit->addCancelButton($this->getApplicationURI());
$title = pht('Create Document'); $title = pht('Create Document');
$short = pht('Create'); $short = pht('Create');
$header_icon = 'fa-plus-square';
} else { } else {
$submit->setValue(pht('Save Document')); $submit->setValue(pht('Save Document'));
$submit->addCancelButton( $submit->addCancelButton(
$this->getApplicationURI('view/'.$document->getID())); $this->getApplicationURI('view/'.$document->getID()));
$title = pht('Edit Document'); $title = pht('Edit Document: %s', $document->getTitle());
$short = pht('Edit'); $short = pht('Edit');
$header_icon = 'fa-pencil';
$crumbs->addTextCrumb( $crumbs->addTextCrumb(
$document->getMonogram(), $document->getMonogram(),
$this->getApplicationURI('view/'.$document->getID())); $this->getApplicationURI('view/'.$document->getID()));
} }
$form $form->appendChild($submit);
->appendChild($submit);
$form_box = id(new PHUIObjectBoxView()) $form_box = id(new PHUIObjectBoxView())
->setHeaderText($title) ->setHeaderText(pht('Document'))
->setFormErrors($errors) ->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form); ->setForm($form);
$crumbs->addTextCrumb($short); $crumbs->addTextCrumb($short);
$crumbs->setBorder(true);
$preview = id(new PHUIRemarkupPreviewPanel()) $preview = id(new PHUIRemarkupPreviewPanel())
->setHeader($document->getTitle()) ->setHeader($document->getTitle())
@ -248,15 +251,22 @@ final class LegalpadDocumentEditController extends LegalpadController {
->setControlID('document-text') ->setControlID('document-text')
->setPreviewType(PHUIRemarkupPreviewPanel::DOCUMENT); ->setPreviewType(PHUIRemarkupPreviewPanel::DOCUMENT);
return $this->buildApplicationPage( $header = id(new PHUIHeaderView())
array( ->setHeader($title)
$crumbs, ->setHeaderIcon($header_icon);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$form_box, $form_box,
$preview, $preview,
),
array(
'title' => $title,
)); ));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
} }
} }

View file

@ -43,10 +43,12 @@ final class LegalpadDocumentManageController extends LegalpadController {
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader($title) ->setHeader($title)
->setUser($viewer) ->setUser($viewer)
->setPolicyObject($document); ->setPolicyObject($document)
->setHeaderIcon('fa-gavel');
$actions = $this->buildActionView($document); $curtain = $this->buildCurtainView($document);
$properties = $this->buildPropertyView($document, $engine, $actions); $properties = $this->buildPropertyView($document, $engine);
$document_view = $this->buildDocumentView($document, $engine);
$comment_form_id = celerity_generate_unique_node_id(); $comment_form_id = celerity_generate_unique_node_id();
@ -57,48 +59,58 @@ final class LegalpadDocumentManageController extends LegalpadController {
$document->getMonogram(), $document->getMonogram(),
'/'.$document->getMonogram()); '/'.$document->getMonogram());
$crumbs->addTextCrumb(pht('Manage')); $crumbs->addTextCrumb(pht('Manage'));
$crumbs->setBorder(true);
$object_box = id(new PHUIObjectBoxView())
$view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->addPropertyList($properties) ->setCurtain($curtain)
->addPropertyList($this->buildDocument($engine, $document_body)); ->setMainColumn(array(
$properties,
$content = array( $document_view,
$crumbs,
$object_box,
$timeline, $timeline,
$add_comment, $add_comment,
);
return $this->buildApplicationPage(
$content,
array(
'title' => $title,
'pageObjects' => array($document->getPHID()),
)); ));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(array($document->getPHID()))
->appendChild($view);
} }
private function buildDocument( private function buildDocumentView(
PhabricatorMarkupEngine LegalpadDocument $document,
$engine, LegalpadDocumentBody $body) { PhabricatorMarkupEngine $engine) {
$view = new PHUIPropertyListView();
$view->addClass('legalpad');
$view->addSectionHeader(
pht('Document'), 'fa-file-text-o');
$view->addTextContent(
$engine->getOutput($body, LegalpadDocumentBody::MARKUP_FIELD_TEXT));
return $view;
}
private function buildActionView(LegalpadDocument $document) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$actions = id(new PhabricatorActionListView()) $view = id(new PHUIPropertyListView())
->setUser($viewer) ->setUser($viewer);
->setObject($document); $document_body = $document->getDocumentBody();
$document_text = $engine->getOutput(
$document_body, LegalpadDocumentBody::MARKUP_FIELD_TEXT);
$preamble_box = null;
if (strlen($document->getPreamble())) {
$preamble_text = new PHUIRemarkupView($viewer, $document->getPreamble());
$view->addTextContent($preamble_text);
$view->addSectionHeader('');
$view->addTextContent($document_text);
} else {
$view->addTextContent($document_text);
}
return id(new PHUIObjectBoxView())
->setHeaderText(pht('DOCUMENT'))
->addPropertyList($view)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
}
private function buildCurtainView(LegalpadDocument $document) {
$viewer = $this->getViewer();
$curtain = $this->newCurtainView($document);
$can_edit = PhabricatorPolicyFilter::hasCapability( $can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer, $viewer,
@ -107,13 +119,13 @@ final class LegalpadDocumentManageController extends LegalpadController {
$doc_id = $document->getID(); $doc_id = $document->getID();
$actions->addAction( $curtain->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon('fa-pencil-square') ->setIcon('fa-pencil-square')
->setName(pht('View/Sign Document')) ->setName(pht('View/Sign Document'))
->setHref('/'.$document->getMonogram())); ->setHref('/'.$document->getMonogram()));
$actions->addAction( $curtain->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon('fa-pencil') ->setIcon('fa-pencil')
->setName(pht('Edit Document')) ->setName(pht('Edit Document'))
@ -121,26 +133,23 @@ final class LegalpadDocumentManageController extends LegalpadController {
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)); ->setWorkflow(!$can_edit));
$actions->addAction( $curtain->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon('fa-terminal') ->setIcon('fa-terminal')
->setName(pht('View Signatures')) ->setName(pht('View Signatures'))
->setHref($this->getApplicationURI('/signatures/'.$doc_id.'/'))); ->setHref($this->getApplicationURI('/signatures/'.$doc_id.'/')));
return $actions; return $curtain;
} }
private function buildPropertyView( private function buildPropertyView(
LegalpadDocument $document, LegalpadDocument $document,
PhabricatorMarkupEngine $engine, PhabricatorMarkupEngine $engine) {
PhabricatorActionListView $actions) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView()) $properties = id(new PHUIPropertyListView())
->setUser($viewer) ->setUser($viewer);
->setObject($document)
->setActionList($actions);
$properties->addProperty( $properties->addProperty(
pht('Signature Type'), pht('Signature Type'),
@ -166,9 +175,10 @@ final class LegalpadDocumentManageController extends LegalpadController {
->setAsInline(true)); ->setAsInline(true));
} }
$properties->invokeWillRenderEvent(); return id(new PHUIObjectBoxView())
->setHeaderText(pht('PROPERTIES'))
return $properties; ->addPropertyList($properties)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
} }
private function buildAddCommentView( private function buildAddCommentView(