Skip to content

Commit eb28a7c

Browse files
author
epriestley
committedJul 4, 2014
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
1 parent a3d5011 commit eb28a7c

File tree

9 files changed

+57
-5
lines changed

9 files changed

+57
-5
lines changed
 

‎resources/celerity/map.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
'rsrc/css/phui/phui-button.css' => 'c7412aa1',
127127
'rsrc/css/phui/phui-document.css' => 'a5615198',
128128
'rsrc/css/phui/phui-feed-story.css' => 'e2c9bc83',
129-
'rsrc/css/phui/phui-fontkit.css' => '5d40a16b',
129+
'rsrc/css/phui/phui-fontkit.css' => 'abeb59f0',
130130
'rsrc/css/phui/phui-form-view.css' => 'ebac1b1d',
131131
'rsrc/css/phui/phui-form.css' => 'b78ec020',
132132
'rsrc/css/phui/phui-header-view.css' => '39594ac0',
@@ -772,7 +772,7 @@
772772
'phui-document-view-css' => 'a5615198',
773773
'phui-feed-story-css' => 'e2c9bc83',
774774
'phui-font-icon-base-css' => 'eb84f033',
775-
'phui-fontkit-css' => '5d40a16b',
775+
'phui-fontkit-css' => 'abeb59f0',
776776
'phui-form-css' => 'b78ec020',
777777
'phui-form-view-css' => 'ebac1b1d',
778778
'phui-header-view-css' => '39594ac0',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_legalpad.legalpad_document
2+
ADD preamble LONGTEXT NOT NULL COLLATE utf8_general_ci;

‎src/applications/legalpad/constants/LegalpadTransactionType.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ final class LegalpadTransactionType extends LegalpadConstants {
55
const TYPE_TITLE = 'title';
66
const TYPE_TEXT = 'text';
77
const TYPE_SIGNATURE_TYPE = 'legalpad:signature-type';
8+
const TYPE_PREAMBLE = 'legalpad:premable';
89

910
}

‎src/applications/legalpad/controller/LegalpadDocumentEditController.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function processRequest() {
4747
$title = $document->getDocumentBody()->getTitle();
4848
$text = $document->getDocumentBody()->getText();
4949
$v_signature_type = $document->getSignatureType();
50+
$v_preamble = $document->getPreamble();
5051

5152
$errors = array();
5253
$can_view = null;
@@ -91,6 +92,11 @@ public function processRequest() {
9192
->setNewValue($v_signature_type);
9293
}
9394

95+
$v_preamble = $request->getStr('preamble');
96+
$xactions[] = id(new LegalpadTransaction())
97+
->setTransactionType(LegalpadTransactionType::TYPE_PREAMBLE)
98+
->setNewValue($v_preamble);
99+
94100
if (!$errors) {
95101
$editor = id(new LegalpadDocumentEditor())
96102
->setContentSourceFromRequest($request)
@@ -135,10 +141,18 @@ public function processRequest() {
135141
}
136142

137143
$form
144+
->appendChild(
145+
id(new PhabricatorRemarkupControl())
146+
->setID('preamble')
147+
->setLabel(pht('Preamble'))
148+
->setValue($v_preamble)
149+
->setName('preamble')
150+
->setCaption(
151+
pht('Optional help text for users signing this document.')))
138152
->appendChild(
139153
id(new PhabricatorRemarkupControl())
140154
->setID('document-text')
141-
->setLabel(pht('Text'))
155+
->setLabel(pht('Document Body'))
142156
->setError($e_text)
143157
->setValue($text)
144158
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)

‎src/applications/legalpad/controller/LegalpadDocumentSignController.php

+14
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,27 @@ public function processRequest() {
227227
->setDisabled(!$can_edit)
228228
->setWorkflow(!$can_edit));
229229

230+
$preamble = null;
231+
if (strlen($document->getPreamble())) {
232+
$preamble_text = PhabricatorMarkupEngine::renderOneObject(
233+
id(new PhabricatorMarkupOneOff())->setContent(
234+
$document->getPreamble()),
235+
'default',
236+
$viewer);
237+
238+
$preamble = id(new PHUIPropertyListView())
239+
->addSectionHeader(pht('Preamble'))
240+
->addTextContent($preamble_text);
241+
}
242+
230243
$content = id(new PHUIDocumentView())
231244
->addClass('legalpad')
232245
->setHeader($header)
233246
->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS)
234247
->appendChild(
235248
array(
236249
$signed_status,
250+
$preamble,
237251
$document_markup,
238252
));
239253

‎src/applications/legalpad/editor/LegalpadDocumentEditor.php

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function getTransactionTypes() {
2626
$types[] = LegalpadTransactionType::TYPE_TITLE;
2727
$types[] = LegalpadTransactionType::TYPE_TEXT;
2828
$types[] = LegalpadTransactionType::TYPE_SIGNATURE_TYPE;
29+
$types[] = LegalpadTransactionType::TYPE_PREAMBLE;
2930

3031
return $types;
3132
}
@@ -41,6 +42,8 @@ protected function getCustomTransactionOldValue(
4142
return $object->getDocumentBody()->getText();
4243
case LegalpadTransactionType::TYPE_SIGNATURE_TYPE:
4344
return $object->getSignatureType();
45+
case LegalpadTransactionType::TYPE_PREAMBLE:
46+
return $object->getPreamble();
4447
}
4548
}
4649

@@ -52,6 +55,7 @@ protected function getCustomTransactionNewValue(
5255
case LegalpadTransactionType::TYPE_TITLE:
5356
case LegalpadTransactionType::TYPE_TEXT:
5457
case LegalpadTransactionType::TYPE_SIGNATURE_TYPE:
58+
case LegalpadTransactionType::TYPE_PREAMBLE:
5559
return $xaction->getNewValue();
5660
}
5761
}
@@ -75,6 +79,9 @@ protected function applyCustomInternalTransaction(
7579
case LegalpadTransactionType::TYPE_SIGNATURE_TYPE:
7680
$object->setSignatureType($xaction->getNewValue());
7781
break;
82+
case LegalpadTransactionType::TYPE_PREAMBLE:
83+
$object->setPreamble($xaction->getNewValue());
84+
break;
7885
}
7986
}
8087

@@ -126,6 +133,7 @@ protected function mergeTransactions(
126133
case LegalpadTransactionType::TYPE_TITLE:
127134
case LegalpadTransactionType::TYPE_TEXT:
128135
case LegalpadTransactionType::TYPE_SIGNATURE_TYPE:
136+
case LegalpadTransactionType::TYPE_PREAMBLE:
129137
return $v;
130138
}
131139

@@ -169,6 +177,7 @@ protected function shouldImplyCC(
169177
switch ($xaction->getTransactionType()) {
170178
case LegalpadTransactionType::TYPE_TEXT:
171179
case LegalpadTransactionType::TYPE_TITLE:
180+
case LegalpadTransactionType::TYPE_PREAMBLE:
172181
return true;
173182
}
174183

‎src/applications/legalpad/storage/LegalpadDocument.php

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class LegalpadDocument extends LegalpadDAO
1717
protected $editPolicy;
1818
protected $mailKey;
1919
protected $signatureType;
20+
protected $preamble;
2021

2122
const SIGNATURE_TYPE_INDIVIDUAL = 'user';
2223
const SIGNATURE_TYPE_CORPORATION = 'corp';
@@ -42,6 +43,7 @@ public static function initializeNewDocument(PhabricatorUser $actor) {
4243
->setRecentContributorPHIDs(array())
4344
->attachSignatures(array())
4445
->setSignatureType(self::SIGNATURE_TYPE_INDIVIDUAL)
46+
->setPreamble('')
4547
->setViewPolicy($view_policy)
4648
->setEditPolicy($edit_policy);
4749
}

‎src/applications/legalpad/storage/LegalpadTransaction.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public function shouldHide() {
2828
case LegalpadTransactionType::TYPE_TITLE:
2929
case LegalpadTransactionType::TYPE_TEXT:
3030
return ($old === null);
31+
case LegalpadTransactionType::TYPE_SIGNATURE_TYPE:
32+
return true;
3133
}
3234

3335
return parent::shouldHide();
@@ -47,12 +49,14 @@ public function getTitle() {
4749
$this->renderHandleLink($author_phid),
4850
$old,
4951
$new);
50-
break;
5152
case LegalpadTransactionType::TYPE_TEXT:
5253
return pht(
5354
"%s updated the document's text.",
5455
$this->renderHandleLink($author_phid));
55-
break;
56+
case LegalpadTransactionType::TYPE_PREAMBLE:
57+
return pht(
58+
'%s updated the preamble.',
59+
$this->renderHandleLink($author_phid));
5660
}
5761

5862
return parent::getTitle();
@@ -62,6 +66,7 @@ public function hasChangeDetails() {
6266
switch ($this->getTransactionType()) {
6367
case LegalpadTransactionType::TYPE_TITLE:
6468
case LegalpadTransactionType::TYPE_TEXT:
69+
case LegalpadTransactionType::TYPE_PREAMBLE:
6570
return true;
6671
}
6772
return parent::hasChangeDetails();

‎webroot/rsrc/css/phui/phui-fontkit.css

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
background: {$lightgreybackground};
3535
}
3636

37+
.phui-font-source-sans .phui-property-list-text-content {
38+
background: {$lightgreybackground};
39+
padding: 0;
40+
}
41+
3742
.phui-font-source-sans .phui-property-list-container {
3843
padding-bottom: 6px;
3944
}

0 commit comments

Comments
 (0)
Failed to load comments.