@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+76 -4
+14 -2
src/applications/legalpad/controller/LegalpadDocumentEditController.php
··· 23 23 ->setCreatorPHID($user->getPHID()) 24 24 ->setContributorCount(0) 25 25 ->setRecentContributorPHIDs(array()) 26 + ->attachSignatures(array()) 26 27 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 27 28 ->setEditPolicy(PhabricatorPolicies::POLICY_USER); 28 29 $body = id(new LegalpadDocumentBody()) ··· 37 38 $document = id(new LegalpadDocumentQuery()) 38 39 ->setViewer($user) 39 40 ->needDocumentBodies(true) 41 + ->needSignatures(true) 40 42 ->requireCapabilities( 41 43 array( 42 44 PhabricatorPolicyCapability::CAN_VIEW, ··· 147 149 ->setPolicies($policies) 148 150 ->setName('can_edit')); 149 151 152 + $crumbs = $this->buildApplicationCrumbs($this->buildSideNav()); 150 153 $submit = new AphrontFormSubmitControl(); 151 154 if ($is_create) { 152 155 $submit->setValue(pht('Create Document')); ··· 158 161 $this->getApplicationURI('view/'.$document->getID())); 159 162 $title = pht('Update Document'); 160 163 $short = pht('Update'); 164 + $signatures = $document->getSignatures(); 165 + if ($signatures) { 166 + $form->appendInstructions(pht( 167 + 'Warning: there are %d signature(s) already for this document. '. 168 + 'Updating the title or text will invalidate these signatures and '. 169 + 'users will need to sign again. Proceed carefully.', 170 + count($signatures))); 171 + } 172 + $crumbs->addTextCrumb( 173 + $document->getMonogram(), 174 + $this->getApplicationURI('view/'.$document->getID())); 161 175 } 162 176 163 177 $form ··· 168 182 ->setFormErrors($errors) 169 183 ->setForm($form); 170 184 171 - $crumbs = $this->buildApplicationCrumbs($this->buildSideNav()); 172 185 $crumbs->addTextCrumb($short); 173 - 174 186 175 187 $preview = id(new PHUIRemarkupPreviewPanel()) 176 188 ->setHeader(pht('Document Preview'))
+7 -1
src/applications/legalpad/controller/LegalpadDocumentViewController.php
··· 82 82 $crumbs = $this->buildApplicationCrumbs($this->buildSideNav()); 83 83 $crumbs->setActionList($actions); 84 84 $crumbs->addTextCrumb( 85 - 'L'.$document->getID(), 85 + $document->getMonogram(), 86 86 $this->getApplicationURI('view/'.$document->getID())); 87 87 88 88 $object_box = id(new PHUIObjectBoxView()) ··· 139 139 ->setHref($this->getApplicationURI('/edit/'.$document->getID().'/')) 140 140 ->setDisabled(!$can_edit) 141 141 ->setWorkflow(!$can_edit)); 142 + 143 + $actions->addAction( 144 + id(new PhabricatorActionView()) 145 + ->setIcon('like') 146 + ->setName(pht('Sign Document')) 147 + ->setHref('/'.$document->getMonogram())); 142 148 143 149 return $actions; 144 150 }
+33
src/applications/legalpad/query/LegalpadDocumentQuery.php
··· 16 16 17 17 private $needDocumentBodies; 18 18 private $needContributors; 19 + private $needSignatures; 19 20 20 21 public function withIDs(array $ids) { 21 22 $this->ids = $ids; ··· 49 50 50 51 public function needContributors($need_contributors) { 51 52 $this->needContributors = $need_contributors; 53 + return $this; 54 + } 55 + 56 + public function needSignatures($need_signatures) { 57 + $this->needSignatures = $need_signatures; 52 58 return $this; 53 59 } 54 60 ··· 102 108 } 103 109 } 104 110 } 111 + 105 112 if ($this->needDocumentBodies) { 106 113 $documents = $this->loadDocumentBodies($documents); 107 114 } ··· 110 117 $documents = $this->loadContributors($documents); 111 118 } 112 119 120 + if ($this->needSignatures) { 121 + $documents = $this->loadSignatures($documents); 122 + } 123 + 113 124 return $documents; 114 125 } 115 126 ··· 203 214 $data = $contributor_data[$document_phid]; 204 215 $contributors = array_keys(idx($data, $edge_type, array())); 205 216 $document->attachContributors($contributors); 217 + } 218 + 219 + return $documents; 220 + } 221 + 222 + private function loadSignatures(array $documents) { 223 + $document_map = mpull($documents, null, 'getPHID'); 224 + 225 + $signatures = id(new LegalpadDocumentSignature()) 226 + ->loadAllWhere( 227 + 'documentPHID IN (%Ls)', 228 + array_keys($document_map)); 229 + $signatures = mgroup($signatures, 'getDocumentPHID'); 230 + 231 + foreach ($documents as $document) { 232 + $sigs = idx($signatures, $document->getPHID()); 233 + foreach ($sigs as $index => $sig) { 234 + if ($sig->getDocumentVersion() != $document->getVersions()) { 235 + unset($sigs[$index]); 236 + } 237 + } 238 + $document->attachSignatures($sigs); 206 239 } 207 240 208 241 return $documents;
+10
src/applications/legalpad/storage/LegalpadDocument.php
··· 21 21 22 22 private $documentBody = self::ATTACHABLE; 23 23 private $contributors = self::ATTACHABLE; 24 + private $signatures = self::ATTACHABLE; 24 25 25 26 public function getConfiguration() { 26 27 return array( ··· 51 52 52 53 public function attachContributors(array $contributors) { 53 54 $this->contributors = $contributors; 55 + return $this; 56 + } 57 + 58 + public function getSignatures() { 59 + return $this->assertAttached($this->signatures); 60 + } 61 + 62 + public function attachSignatures(array $signatures) { 63 + $this->signatures = $signatures; 54 64 return $this; 55 65 } 56 66
+12 -1
src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
··· 815 815 '%d Users Need Approval', 816 816 ), 817 817 818 + 'Warning: there are %d signature(s) already for this document. '. 819 + 'Updating the title or text will invalidate these signatures and users '. 820 + 'will need to sign again. Proceed carefully.' => array( 821 + 'Warning: there is %d signature already for this document. '. 822 + 'Updating the title or text will invalidate this signature and the '. 823 + 'user will need to sign again. Proceed carefully.', 824 + 'Warning: there are %d signatures already for this document. '. 825 + 'Updating the title or text will invalidate these signatures and '. 826 + 'users will need to sign again. Proceed carefully.', 827 + ), 828 + 818 829 ); 819 830 } 820 831 821 - } 832 + }