1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

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
This commit is contained in:
epriestley 2014-07-04 09:41:27 -07:00
parent a3d50118e1
commit eb28a7caef
9 changed files with 57 additions and 5 deletions

View file

@ -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',

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_legalpad.legalpad_document
ADD preamble LONGTEXT NOT NULL COLLATE utf8_general_ci;

View file

@ -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';
}

View file

@ -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)

View file

@ -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,
));

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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();

View file

@ -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;
}