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