mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Legalpad - a few rough edges smoothed...
Summary: does a few smallish things... Ref T3116 - adds an action to "sign document", thus improving visiblity of this feature from 0 to some value more than 0 - adds a crumb on the edit page to get back to the view page - warns the user on the edit page IFF signatures exist for the current version that their edits could invalidate those signatures - adds a "needSignatures" option to the Document Query class Test Plan: click the new UI elements and they worked. edited a document with signatures, noted warning UI, edited anyway, noted warning UI correctly disappeared on new edit. also verified a single signature had the correct translation Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T3116 Differential Revision: https://secure.phabricator.com/D7983
This commit is contained in:
parent
2ec45d42a6
commit
c40420eb74
5 changed files with 76 additions and 4 deletions
|
@ -23,6 +23,7 @@ final class LegalpadDocumentEditController extends LegalpadController {
|
||||||
->setCreatorPHID($user->getPHID())
|
->setCreatorPHID($user->getPHID())
|
||||||
->setContributorCount(0)
|
->setContributorCount(0)
|
||||||
->setRecentContributorPHIDs(array())
|
->setRecentContributorPHIDs(array())
|
||||||
|
->attachSignatures(array())
|
||||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
||||||
->setEditPolicy(PhabricatorPolicies::POLICY_USER);
|
->setEditPolicy(PhabricatorPolicies::POLICY_USER);
|
||||||
$body = id(new LegalpadDocumentBody())
|
$body = id(new LegalpadDocumentBody())
|
||||||
|
@ -37,6 +38,7 @@ final class LegalpadDocumentEditController extends LegalpadController {
|
||||||
$document = id(new LegalpadDocumentQuery())
|
$document = id(new LegalpadDocumentQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->needDocumentBodies(true)
|
->needDocumentBodies(true)
|
||||||
|
->needSignatures(true)
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
@ -147,6 +149,7 @@ final class LegalpadDocumentEditController extends LegalpadController {
|
||||||
->setPolicies($policies)
|
->setPolicies($policies)
|
||||||
->setName('can_edit'));
|
->setName('can_edit'));
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
|
||||||
$submit = new AphrontFormSubmitControl();
|
$submit = new AphrontFormSubmitControl();
|
||||||
if ($is_create) {
|
if ($is_create) {
|
||||||
$submit->setValue(pht('Create Document'));
|
$submit->setValue(pht('Create Document'));
|
||||||
|
@ -158,6 +161,17 @@ final class LegalpadDocumentEditController extends LegalpadController {
|
||||||
$this->getApplicationURI('view/'.$document->getID()));
|
$this->getApplicationURI('view/'.$document->getID()));
|
||||||
$title = pht('Update Document');
|
$title = pht('Update Document');
|
||||||
$short = pht('Update');
|
$short = pht('Update');
|
||||||
|
$signatures = $document->getSignatures();
|
||||||
|
if ($signatures) {
|
||||||
|
$form->appendInstructions(pht(
|
||||||
|
'Warning: there are %d signature(s) already for this document. '.
|
||||||
|
'Updating the title or text will invalidate these signatures and '.
|
||||||
|
'users will need to sign again. Proceed carefully.',
|
||||||
|
count($signatures)));
|
||||||
|
}
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
$document->getMonogram(),
|
||||||
|
$this->getApplicationURI('view/'.$document->getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$form
|
$form
|
||||||
|
@ -168,10 +182,8 @@ final class LegalpadDocumentEditController extends LegalpadController {
|
||||||
->setFormErrors($errors)
|
->setFormErrors($errors)
|
||||||
->setForm($form);
|
->setForm($form);
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
|
|
||||||
$crumbs->addTextCrumb($short);
|
$crumbs->addTextCrumb($short);
|
||||||
|
|
||||||
|
|
||||||
$preview = id(new PHUIRemarkupPreviewPanel())
|
$preview = id(new PHUIRemarkupPreviewPanel())
|
||||||
->setHeader(pht('Document Preview'))
|
->setHeader(pht('Document Preview'))
|
||||||
->setPreviewURI($this->getApplicationURI('document/preview/'))
|
->setPreviewURI($this->getApplicationURI('document/preview/'))
|
||||||
|
|
|
@ -82,7 +82,7 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
||||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
|
$crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
|
||||||
$crumbs->setActionList($actions);
|
$crumbs->setActionList($actions);
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
'L'.$document->getID(),
|
$document->getMonogram(),
|
||||||
$this->getApplicationURI('view/'.$document->getID()));
|
$this->getApplicationURI('view/'.$document->getID()));
|
||||||
|
|
||||||
$object_box = id(new PHUIObjectBoxView())
|
$object_box = id(new PHUIObjectBoxView())
|
||||||
|
@ -140,6 +140,12 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(!$can_edit));
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
$actions->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setIcon('like')
|
||||||
|
->setName(pht('Sign Document'))
|
||||||
|
->setHref('/'.$document->getMonogram()));
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ final class LegalpadDocumentQuery
|
||||||
|
|
||||||
private $needDocumentBodies;
|
private $needDocumentBodies;
|
||||||
private $needContributors;
|
private $needContributors;
|
||||||
|
private $needSignatures;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
|
@ -52,6 +53,11 @@ final class LegalpadDocumentQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function needSignatures($need_signatures) {
|
||||||
|
$this->needSignatures = $need_signatures;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function withDateCreatedBefore($date_created_before) {
|
public function withDateCreatedBefore($date_created_before) {
|
||||||
$this->dateCreatedBefore = $date_created_before;
|
$this->dateCreatedBefore = $date_created_before;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -102,6 +108,7 @@ final class LegalpadDocumentQuery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->needDocumentBodies) {
|
if ($this->needDocumentBodies) {
|
||||||
$documents = $this->loadDocumentBodies($documents);
|
$documents = $this->loadDocumentBodies($documents);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +117,10 @@ final class LegalpadDocumentQuery
|
||||||
$documents = $this->loadContributors($documents);
|
$documents = $this->loadContributors($documents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->needSignatures) {
|
||||||
|
$documents = $this->loadSignatures($documents);
|
||||||
|
}
|
||||||
|
|
||||||
return $documents;
|
return $documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +219,28 @@ final class LegalpadDocumentQuery
|
||||||
return $documents;
|
return $documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function loadSignatures(array $documents) {
|
||||||
|
$document_map = mpull($documents, null, 'getPHID');
|
||||||
|
|
||||||
|
$signatures = id(new LegalpadDocumentSignature())
|
||||||
|
->loadAllWhere(
|
||||||
|
'documentPHID IN (%Ls)',
|
||||||
|
array_keys($document_map));
|
||||||
|
$signatures = mgroup($signatures, 'getDocumentPHID');
|
||||||
|
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
$sigs = idx($signatures, $document->getPHID());
|
||||||
|
foreach ($sigs as $index => $sig) {
|
||||||
|
if ($sig->getDocumentVersion() != $document->getVersions()) {
|
||||||
|
unset($sigs[$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$document->attachSignatures($sigs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $documents;
|
||||||
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
return 'PhabricatorApplicationLegalpad';
|
return 'PhabricatorApplicationLegalpad';
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ final class LegalpadDocument extends LegalpadDAO
|
||||||
|
|
||||||
private $documentBody = self::ATTACHABLE;
|
private $documentBody = self::ATTACHABLE;
|
||||||
private $contributors = self::ATTACHABLE;
|
private $contributors = self::ATTACHABLE;
|
||||||
|
private $signatures = self::ATTACHABLE;
|
||||||
|
|
||||||
public function getConfiguration() {
|
public function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -54,6 +55,15 @@ final class LegalpadDocument extends LegalpadDAO
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSignatures() {
|
||||||
|
return $this->assertAttached($this->signatures);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attachSignatures(array $signatures) {
|
||||||
|
$this->signatures = $signatures;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
if (!$this->getMailKey()) {
|
if (!$this->getMailKey()) {
|
||||||
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
||||||
|
|
|
@ -815,7 +815,18 @@ abstract class PhabricatorBaseEnglishTranslation
|
||||||
'%d Users Need Approval',
|
'%d Users Need Approval',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'Warning: there are %d signature(s) already for this document. '.
|
||||||
|
'Updating the title or text will invalidate these signatures and users '.
|
||||||
|
'will need to sign again. Proceed carefully.' => array(
|
||||||
|
'Warning: there is %d signature already for this document. '.
|
||||||
|
'Updating the title or text will invalidate this signature and the '.
|
||||||
|
'user will need to sign again. Proceed carefully.',
|
||||||
|
'Warning: there are %d signatures already for this document. '.
|
||||||
|
'Updating the title or text will invalidate these signatures and '.
|
||||||
|
'users will need to sign again. Proceed carefully.',
|
||||||
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue