mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Make view/sign page the primary Legalpad page
Summary: - Makes the "legal document" page the main page. - Links to the "manage" page. - The "manage" operation now requires CAN_EDIT. - Modernize some crumbs and such. Test Plan: {F170213} Reviewers: chad Reviewed By: chad Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9733
This commit is contained in:
parent
e14003497e
commit
1abd74459f
7 changed files with 71 additions and 43 deletions
|
@ -863,6 +863,7 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php',
|
||||
'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php',
|
||||
'LegalpadDocumentListController' => 'applications/legalpad/controller/LegalpadDocumentListController.php',
|
||||
'LegalpadDocumentManageController' => 'applications/legalpad/controller/LegalpadDocumentManageController.php',
|
||||
'LegalpadDocumentQuery' => 'applications/legalpad/query/LegalpadDocumentQuery.php',
|
||||
'LegalpadDocumentRemarkupRule' => 'applications/legalpad/remarkup/LegalpadDocumentRemarkupRule.php',
|
||||
'LegalpadDocumentSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSearchEngine.php',
|
||||
|
@ -871,7 +872,6 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentSignatureListController' => 'applications/legalpad/controller/LegalpadDocumentSignatureListController.php',
|
||||
'LegalpadDocumentSignatureQuery' => 'applications/legalpad/query/LegalpadDocumentSignatureQuery.php',
|
||||
'LegalpadDocumentSignatureVerificationController' => 'applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php',
|
||||
'LegalpadDocumentViewController' => 'applications/legalpad/controller/LegalpadDocumentViewController.php',
|
||||
'LegalpadMockMailReceiver' => 'applications/legalpad/mail/LegalpadMockMailReceiver.php',
|
||||
'LegalpadReplyHandler' => 'applications/legalpad/mail/LegalpadReplyHandler.php',
|
||||
'LegalpadTransaction' => 'applications/legalpad/storage/LegalpadTransaction.php',
|
||||
|
@ -3616,6 +3616,7 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentEditController' => 'LegalpadController',
|
||||
'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'LegalpadDocumentListController' => 'LegalpadController',
|
||||
'LegalpadDocumentManageController' => 'LegalpadController',
|
||||
'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'LegalpadDocumentRemarkupRule' => 'PhabricatorRemarkupRuleObject',
|
||||
'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
@ -3628,7 +3629,6 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentSignatureListController' => 'LegalpadController',
|
||||
'LegalpadDocumentSignatureQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'LegalpadDocumentSignatureVerificationController' => 'LegalpadController',
|
||||
'LegalpadDocumentViewController' => 'LegalpadController',
|
||||
'LegalpadMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'LegalpadReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'LegalpadTransaction' => 'PhabricatorApplicationTransaction',
|
||||
|
|
|
@ -45,7 +45,7 @@ final class PhabricatorApplicationLegalpad extends PhabricatorApplication {
|
|||
'create/' => 'LegalpadDocumentEditController',
|
||||
'edit/(?P<id>\d+)/' => 'LegalpadDocumentEditController',
|
||||
'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController',
|
||||
'view/(?P<id>\d+)/' => 'LegalpadDocumentViewController',
|
||||
'view/(?P<id>\d+)/' => 'LegalpadDocumentManageController',
|
||||
'verify/(?P<code>[^/]+)/' =>
|
||||
'LegalpadDocumentSignatureVerificationController',
|
||||
'signatures/(?P<id>\d+)/' => 'LegalpadDocumentSignatureListController',
|
||||
|
|
|
@ -22,18 +22,6 @@ abstract class LegalpadController extends PhabricatorController {
|
|||
return $nav;
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setName(pht('Create Document'))
|
||||
->setHref($this->getApplicationURI('create/'))
|
||||
->setIcon('fa-plus-square'));
|
||||
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->buildSideNav(true)->getMenu();
|
||||
}
|
||||
|
|
|
@ -18,4 +18,16 @@ final class LegalpadDocumentListController extends LegalpadController {
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setName(pht('Create Document'))
|
||||
->setHref($this->getApplicationURI('create/'))
|
||||
->setIcon('fa-plus-square'));
|
||||
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group legalpad
|
||||
*/
|
||||
final class LegalpadDocumentViewController extends LegalpadController {
|
||||
final class LegalpadDocumentManageController extends LegalpadController {
|
||||
|
||||
private $id;
|
||||
|
||||
|
@ -15,13 +12,19 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
|||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
// NOTE: We require CAN_EDIT to view this page.
|
||||
|
||||
$document = id(new LegalpadDocumentQuery())
|
||||
->setViewer($user)
|
||||
->withIDs(array($this->id))
|
||||
->needDocumentBodies(true)
|
||||
->needContributors(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
|
||||
if (!$document) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
@ -83,7 +86,8 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
|||
$crumbs->setActionList($actions);
|
||||
$crumbs->addTextCrumb(
|
||||
$document->getMonogram(),
|
||||
$this->getApplicationURI('view/'.$document->getID()));
|
||||
'/'.$document->getMonogram());
|
||||
$crumbs->addTextCrumb(pht('Manage'));
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
->setHeader($header)
|
||||
|
@ -134,6 +138,12 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
|||
|
||||
$doc_id = $document->getID();
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil-square')
|
||||
->setName(pht('View/Sign Document'))
|
||||
->setHref('/'.$document->getMonogram()));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil')
|
||||
|
@ -142,12 +152,6 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
|||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil-square')
|
||||
->setName(pht('Sign Document'))
|
||||
->setHref('/'.$document->getMonogram()));
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-terminal')
|
|
@ -14,10 +14,10 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$document = id(new LegalpadDocumentQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->id))
|
||||
->needDocumentBodies(true)
|
||||
->executeOne();
|
||||
|
@ -29,10 +29,10 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
$signer_phid = null;
|
||||
$signature = null;
|
||||
$signature_data = array();
|
||||
if ($user->isLoggedIn()) {
|
||||
$signer_phid = $user->getPHID();
|
||||
if ($viewer->isLoggedIn()) {
|
||||
$signer_phid = $viewer->getPHID();
|
||||
$signature_data = array(
|
||||
'email' => $user->loadPrimaryEmailAddress());
|
||||
'email' => $viewer->loadPrimaryEmailAddress());
|
||||
} else if ($request->isFormPost()) {
|
||||
$email = new PhutilEmailAddress($request->getStr('email'));
|
||||
$email_obj = id(new PhabricatorUserEmail())
|
||||
|
@ -41,7 +41,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
return $this->signInResponse();
|
||||
}
|
||||
$external_account = id(new PhabricatorExternalAccountQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withAccountTypes(array('email'))
|
||||
->withAccountDomains(array($email->getDomainName()))
|
||||
->withAccountIDs(array($email->getAddress()))
|
||||
|
@ -54,7 +54,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
|
||||
if ($signer_phid) {
|
||||
$signature = id(new LegalpadDocumentSignatureQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withDocumentPHIDs(array($document->getPHID()))
|
||||
->withSignerPHIDs(array($signer_phid))
|
||||
->withDocumentVersions(array($document->getVersions()))
|
||||
|
@ -132,10 +132,10 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
}
|
||||
|
||||
$verified = LegalpadDocumentSignature::UNVERIFIED;
|
||||
if ($user->isLoggedIn() && $addr_obj) {
|
||||
if ($viewer->isLoggedIn() && $addr_obj) {
|
||||
$email_obj = id(new PhabricatorUserEmail())
|
||||
->loadOneWhere('address = %s', $addr_obj->getAddress());
|
||||
if ($email_obj && $email_obj->getUserPHID() == $user->getPHID()) {
|
||||
if ($email_obj && $email_obj->getUserPHID() == $viewer->getPHID()) {
|
||||
$verified = LegalpadDocumentSignature::VERIFIED;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
|
||||
$document_body = $document->getDocumentBody();
|
||||
$engine = id(new PhabricatorMarkupEngine())
|
||||
->setViewer($user);
|
||||
->setViewer($viewer);
|
||||
$engine->addObject(
|
||||
$document_body,
|
||||
LegalpadDocumentBody::MARKUP_FIELD_TEXT);
|
||||
|
@ -173,8 +173,25 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
|
||||
$title = $document_body->getTitle();
|
||||
|
||||
$manage_uri = $this->getApplicationURI('view/'.$document->getID().'/');
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$document,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($title);
|
||||
->setHeader($title)
|
||||
->addActionLink(
|
||||
id(new PHUIButtonView())
|
||||
->setTag('a')
|
||||
->setIcon(
|
||||
id(new PHUIIconView())
|
||||
->setIconFont('fa-pencil'))
|
||||
->setText(pht('Manage Document'))
|
||||
->setHref($manage_uri)
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$content = array(
|
||||
$this->buildDocument(
|
||||
|
@ -190,8 +207,14 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
$e_address_1,
|
||||
$error_view));
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($document->getMonogram());
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$content,
|
||||
array(
|
||||
$crumbs,
|
||||
$content,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
'pageObjects' => array($document->getPHID()),
|
||||
|
@ -220,7 +243,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
$e_address_1 = true,
|
||||
$error_view = null) {
|
||||
|
||||
$user = $this->getRequest()->getUser();
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
if ($has_signed) {
|
||||
$instructions = pht('Thank you for signing and agreeing.');
|
||||
} else {
|
||||
|
@ -229,7 +252,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
|
||||
$data = $signature->getSignatureData();
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Name'))
|
||||
|
@ -282,6 +305,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
if ($error_view) {
|
||||
$view->setErrorView($error_view);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,9 +132,9 @@ final class LegalpadDocumentSearchEngine
|
|||
$title = $document->getTitle();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName('L'.$document->getID())
|
||||
->setObjectName($document->getMonogram())
|
||||
->setHeader($title)
|
||||
->setHref($this->getApplicationURI('view/'.$document->getID()))
|
||||
->setHref('/'.$document->getMonogram())
|
||||
->setObject($document)
|
||||
->addIcon('none', pht('Last updated: %s', $last_updated))
|
||||
->addByline(pht('Updated by: %s', $updater))
|
||||
|
|
Loading…
Reference in a new issue