diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -126,7 +126,7 @@ '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 @@ '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 --- /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 --- a/src/applications/legalpad/constants/LegalpadTransactionType.php +++ b/src/applications/legalpad/constants/LegalpadTransactionType.php @@ -5,5 +5,6 @@ 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 --- a/src/applications/legalpad/controller/LegalpadDocumentEditController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentEditController.php @@ -47,6 +47,7 @@ $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 @@ ->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) @@ -137,8 +143,16 @@ $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 --- a/src/applications/legalpad/controller/LegalpadDocumentSignController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignController.php @@ -227,6 +227,19 @@ ->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 @@ ->appendChild( array( $signed_status, + $preamble, $document_markup, )); diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -26,6 +26,7 @@ $types[] = LegalpadTransactionType::TYPE_TITLE; $types[] = LegalpadTransactionType::TYPE_TEXT; $types[] = LegalpadTransactionType::TYPE_SIGNATURE_TYPE; + $types[] = LegalpadTransactionType::TYPE_PREAMBLE; return $types; } @@ -41,6 +42,8 @@ return $object->getDocumentBody()->getText(); case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: return $object->getSignatureType(); + case LegalpadTransactionType::TYPE_PREAMBLE: + return $object->getPreamble(); } } @@ -52,6 +55,7 @@ case LegalpadTransactionType::TYPE_TITLE: case LegalpadTransactionType::TYPE_TEXT: case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: + case LegalpadTransactionType::TYPE_PREAMBLE: return $xaction->getNewValue(); } } @@ -75,6 +79,9 @@ case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: $object->setSignatureType($xaction->getNewValue()); break; + case LegalpadTransactionType::TYPE_PREAMBLE: + $object->setPreamble($xaction->getNewValue()); + break; } } @@ -126,6 +133,7 @@ case LegalpadTransactionType::TYPE_TITLE: case LegalpadTransactionType::TYPE_TEXT: case LegalpadTransactionType::TYPE_SIGNATURE_TYPE: + case LegalpadTransactionType::TYPE_PREAMBLE: return $v; } @@ -169,6 +177,7 @@ 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 --- a/src/applications/legalpad/storage/LegalpadDocument.php +++ b/src/applications/legalpad/storage/LegalpadDocument.php @@ -17,6 +17,7 @@ protected $editPolicy; protected $mailKey; protected $signatureType; + protected $preamble; const SIGNATURE_TYPE_INDIVIDUAL = 'user'; const SIGNATURE_TYPE_CORPORATION = 'corp'; @@ -42,6 +43,7 @@ ->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 --- a/src/applications/legalpad/storage/LegalpadTransaction.php +++ b/src/applications/legalpad/storage/LegalpadTransaction.php @@ -28,6 +28,8 @@ 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 @@ $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 @@ 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 --- 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; }