From eb28a7caeff539f1a6c15bd4e6040977a92c9408 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 4 Jul 2014 09:41:27 -0700 Subject: [PATCH] Add an optional preamble to Legalpad documents Summary: Fixes T5532. Allow documents to have a preamble in the header which can be used to explain who should sign a document and why. Particularly, I plan to use this to navigate the corporate vs individual stuff more sensibly. Test Plan: {F174228} Reviewers: chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T5532 Differential Revision: https://secure.phabricator.com/D9819 --- resources/celerity/map.php | 4 ++-- .../sql/autopatches/20140704.legalpreamble.1.sql | 2 ++ .../constants/LegalpadTransactionType.php | 1 + .../LegalpadDocumentEditController.php | 16 +++++++++++++++- .../LegalpadDocumentSignController.php | 14 ++++++++++++++ .../legalpad/editor/LegalpadDocumentEditor.php | 9 +++++++++ .../legalpad/storage/LegalpadDocument.php | 2 ++ .../legalpad/storage/LegalpadTransaction.php | 9 +++++++-- webroot/rsrc/css/phui/phui-fontkit.css | 5 +++++ 9 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 resources/sql/autopatches/20140704.legalpreamble.1.sql diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 9fd62867bb..b57104b888 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -126,7 +126,7 @@ return array( 'rsrc/css/phui/phui-button.css' => 'c7412aa1', 'rsrc/css/phui/phui-document.css' => 'a5615198', 'rsrc/css/phui/phui-feed-story.css' => 'e2c9bc83', - 'rsrc/css/phui/phui-fontkit.css' => '5d40a16b', + 'rsrc/css/phui/phui-fontkit.css' => 'abeb59f0', 'rsrc/css/phui/phui-form-view.css' => 'ebac1b1d', 'rsrc/css/phui/phui-form.css' => 'b78ec020', 'rsrc/css/phui/phui-header-view.css' => '39594ac0', @@ -772,7 +772,7 @@ return array( 'phui-document-view-css' => 'a5615198', 'phui-feed-story-css' => 'e2c9bc83', 'phui-font-icon-base-css' => 'eb84f033', - 'phui-fontkit-css' => '5d40a16b', + 'phui-fontkit-css' => 'abeb59f0', 'phui-form-css' => 'b78ec020', 'phui-form-view-css' => 'ebac1b1d', 'phui-header-view-css' => '39594ac0', diff --git a/resources/sql/autopatches/20140704.legalpreamble.1.sql b/resources/sql/autopatches/20140704.legalpreamble.1.sql new file mode 100644 index 0000000000..4ba1cde0e1 --- /dev/null +++ b/resources/sql/autopatches/20140704.legalpreamble.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_legalpad.legalpad_document + ADD preamble LONGTEXT NOT NULL COLLATE utf8_general_ci; diff --git a/src/applications/legalpad/constants/LegalpadTransactionType.php b/src/applications/legalpad/constants/LegalpadTransactionType.php index 92452ba0e1..1ad854b199 100644 --- a/src/applications/legalpad/constants/LegalpadTransactionType.php +++ b/src/applications/legalpad/constants/LegalpadTransactionType.php @@ -5,5 +5,6 @@ final class LegalpadTransactionType extends LegalpadConstants { const TYPE_TITLE = 'title'; const TYPE_TEXT = 'text'; const TYPE_SIGNATURE_TYPE = 'legalpad:signature-type'; + const TYPE_PREAMBLE = 'legalpad:premable'; } diff --git a/src/applications/legalpad/controller/LegalpadDocumentEditController.php b/src/applications/legalpad/controller/LegalpadDocumentEditController.php index 5482f1b9cb..ba88901df1 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentEditController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentEditController.php @@ -47,6 +47,7 @@ final class LegalpadDocumentEditController extends LegalpadController { $title = $document->getDocumentBody()->getTitle(); $text = $document->getDocumentBody()->getText(); $v_signature_type = $document->getSignatureType(); + $v_preamble = $document->getPreamble(); $errors = array(); $can_view = null; @@ -91,6 +92,11 @@ final class LegalpadDocumentEditController extends LegalpadController { ->setNewValue($v_signature_type); } + $v_preamble = $request->getStr('preamble'); + $xactions[] = id(new LegalpadTransaction()) + ->setTransactionType(LegalpadTransactionType::TYPE_PREAMBLE) + ->setNewValue($v_preamble); + if (!$errors) { $editor = id(new LegalpadDocumentEditor()) ->setContentSourceFromRequest($request) @@ -135,10 +141,18 @@ final class LegalpadDocumentEditController extends LegalpadController { } $form + ->appendChild( + id(new PhabricatorRemarkupControl()) + ->setID('preamble') + ->setLabel(pht('Preamble')) + ->setValue($v_preamble) + ->setName('preamble') + ->setCaption( + pht('Optional help text for users signing this document.'))) ->appendChild( id(new PhabricatorRemarkupControl()) ->setID('document-text') - ->setLabel(pht('Text')) + ->setLabel(pht('Document Body')) ->setError($e_text) ->setValue($text) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignController.php b/src/applications/legalpad/controller/LegalpadDocumentSignController.php index e2522b52e5..31e64ba225 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentSignController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignController.php @@ -227,6 +227,19 @@ final class LegalpadDocumentSignController extends LegalpadController { ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); + $preamble = null; + if (strlen($document->getPreamble())) { + $preamble_text = PhabricatorMarkupEngine::renderOneObject( + id(new PhabricatorMarkupOneOff())->setContent( + $document->getPreamble()), + 'default', + $viewer); + + $preamble = id(new PHUIPropertyListView()) + ->addSectionHeader(pht('Preamble')) + ->addTextContent($preamble_text); + } + $content = id(new PHUIDocumentView()) ->addClass('legalpad') ->setHeader($header) @@ -234,6 +247,7 @@ final class LegalpadDocumentSignController extends LegalpadController { ->appendChild( array( $signed_status, + $preamble, $document_markup, )); diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php index 98205c46b9..909b72f3f0 100644 --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -26,6 +26,7 @@ final class LegalpadDocumentEditor $types[] = LegalpadTransactionType::TYPE_TITLE; $types[] = LegalpadTransactionType::TYPE_TEXT; $types[] = LegalpadTransactionType::TYPE_SIGNATURE_TYPE; + $types[] = LegalpadTransactionType::TYPE_PREAMBLE; return $types; } @@ -41,6 +42,8 @@ final class LegalpadDocumentEditor return $object->getDocumentBody()->getText(); case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: return $object->getSignatureType(); + case LegalpadTransactionType::TYPE_PREAMBLE: + return $object->getPreamble(); } } @@ -52,6 +55,7 @@ final class LegalpadDocumentEditor case LegalpadTransactionType::TYPE_TITLE: case LegalpadTransactionType::TYPE_TEXT: case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: + case LegalpadTransactionType::TYPE_PREAMBLE: return $xaction->getNewValue(); } } @@ -75,6 +79,9 @@ final class LegalpadDocumentEditor case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: $object->setSignatureType($xaction->getNewValue()); break; + case LegalpadTransactionType::TYPE_PREAMBLE: + $object->setPreamble($xaction->getNewValue()); + break; } } @@ -126,6 +133,7 @@ final class LegalpadDocumentEditor case LegalpadTransactionType::TYPE_TITLE: case LegalpadTransactionType::TYPE_TEXT: case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: + case LegalpadTransactionType::TYPE_PREAMBLE: return $v; } @@ -169,6 +177,7 @@ final class LegalpadDocumentEditor switch ($xaction->getTransactionType()) { case LegalpadTransactionType::TYPE_TEXT: case LegalpadTransactionType::TYPE_TITLE: + case LegalpadTransactionType::TYPE_PREAMBLE: return true; } diff --git a/src/applications/legalpad/storage/LegalpadDocument.php b/src/applications/legalpad/storage/LegalpadDocument.php index 7cc4864438..2adaa42263 100644 --- a/src/applications/legalpad/storage/LegalpadDocument.php +++ b/src/applications/legalpad/storage/LegalpadDocument.php @@ -17,6 +17,7 @@ final class LegalpadDocument extends LegalpadDAO protected $editPolicy; protected $mailKey; protected $signatureType; + protected $preamble; const SIGNATURE_TYPE_INDIVIDUAL = 'user'; const SIGNATURE_TYPE_CORPORATION = 'corp'; @@ -42,6 +43,7 @@ final class LegalpadDocument extends LegalpadDAO ->setRecentContributorPHIDs(array()) ->attachSignatures(array()) ->setSignatureType(self::SIGNATURE_TYPE_INDIVIDUAL) + ->setPreamble('') ->setViewPolicy($view_policy) ->setEditPolicy($edit_policy); } diff --git a/src/applications/legalpad/storage/LegalpadTransaction.php b/src/applications/legalpad/storage/LegalpadTransaction.php index 26cb8b1572..164e9e31dc 100644 --- a/src/applications/legalpad/storage/LegalpadTransaction.php +++ b/src/applications/legalpad/storage/LegalpadTransaction.php @@ -28,6 +28,8 @@ final class LegalpadTransaction extends PhabricatorApplicationTransaction { case LegalpadTransactionType::TYPE_TITLE: case LegalpadTransactionType::TYPE_TEXT: return ($old === null); + case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: + return true; } return parent::shouldHide(); @@ -47,12 +49,14 @@ final class LegalpadTransaction extends PhabricatorApplicationTransaction { $this->renderHandleLink($author_phid), $old, $new); - break; case LegalpadTransactionType::TYPE_TEXT: return pht( "%s updated the document's text.", $this->renderHandleLink($author_phid)); - break; + case LegalpadTransactionType::TYPE_PREAMBLE: + return pht( + '%s updated the preamble.', + $this->renderHandleLink($author_phid)); } return parent::getTitle(); @@ -62,6 +66,7 @@ final class LegalpadTransaction extends PhabricatorApplicationTransaction { switch ($this->getTransactionType()) { case LegalpadTransactionType::TYPE_TITLE: case LegalpadTransactionType::TYPE_TEXT: + case LegalpadTransactionType::TYPE_PREAMBLE: return true; } return parent::hasChangeDetails(); diff --git a/webroot/rsrc/css/phui/phui-fontkit.css b/webroot/rsrc/css/phui/phui-fontkit.css index 546bf15756..cfccc01399 100644 --- a/webroot/rsrc/css/phui/phui-fontkit.css +++ b/webroot/rsrc/css/phui/phui-fontkit.css @@ -34,6 +34,11 @@ background: {$lightgreybackground}; } +.phui-font-source-sans .phui-property-list-text-content { + background: {$lightgreybackground}; + padding: 0; +} + .phui-font-source-sans .phui-property-list-container { padding-bottom: 6px; }