Page MenuHomePhabricator

D9876.diff
No OneTemporary

D9876.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -864,6 +864,7 @@
'LegalpadDocument' => 'applications/legalpad/storage/LegalpadDocument.php',
'LegalpadDocumentBody' => 'applications/legalpad/storage/LegalpadDocumentBody.php',
'LegalpadDocumentCommentController' => 'applications/legalpad/controller/LegalpadDocumentCommentController.php',
+ 'LegalpadDocumentDatasource' => 'applications/legalpad/typeahead/LegalpadDocumentDatasource.php',
'LegalpadDocumentDoneController' => 'applications/legalpad/controller/LegalpadDocumentDoneController.php',
'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php',
'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php',
@@ -3629,6 +3630,7 @@
1 => 'PhabricatorMarkupInterface',
),
'LegalpadDocumentCommentController' => 'LegalpadController',
+ 'LegalpadDocumentDatasource' => 'PhabricatorTypeaheadDatasource',
'LegalpadDocumentDoneController' => 'LegalpadController',
'LegalpadDocumentEditController' => 'LegalpadController',
'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor',
diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php
--- a/src/applications/herald/controller/HeraldRuleController.php
+++ b/src/applications/herald/controller/HeraldRuleController.php
@@ -588,20 +588,25 @@
$template = new AphrontTokenizerTemplateView();
$template = $template->render();
+ $sources = array(
+ 'repository' => new DiffusionRepositoryDatasource(),
+ 'legaldocuments' => new LegalpadDocumentDatasource(),
+ );
+
+ $sources = mpull($sources, 'getDatasourceURI');
+ $sources += array(
+ 'email' => '/typeahead/common/mailable/',
+ 'user' => '/typeahead/common/accounts/',
+ 'package' => '/typeahead/common/packages/',
+ 'project' => '/typeahead/common/projects/',
+ 'userorproject' => '/typeahead/common/accountsorprojects/',
+ 'buildplan' => '/typeahead/common/buildplans/',
+ 'taskpriority' => '/typeahead/common/taskpriority/',
+ 'arcanistprojects' => '/typeahead/common/arcanistprojects/',
+ );
+
return array(
- 'source' => array(
- 'email' => '/typeahead/common/mailable/',
- 'user' => '/typeahead/common/accounts/',
- 'repository' =>
- id(new DiffusionRepositoryDatasource())->getDatasourceURI(),
- 'package' => '/typeahead/common/packages/',
- 'project' => '/typeahead/common/projects/',
- 'userorproject' => '/typeahead/common/accountsorprojects/',
- 'buildplan' => '/typeahead/common/buildplans/',
- 'taskpriority' => '/typeahead/common/taskpriority/',
- 'arcanistprojects' => '/typeahead/common/arcanistprojects/',
- 'legaldocuments' => '/typeahead/common/legalpaddocuments/',
- ),
+ 'source' => $sources,
'username' => $this->getRequest()->getUser()->getUserName(),
'icons' => mpull($handles, 'getTypeIcon', 'getPHID'),
'markup' => $template,
diff --git a/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php b/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php
--- a/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php
+++ b/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php
@@ -12,6 +12,10 @@
return pht('Legalpad Document');
}
+ public function getTypeIcon() {
+ return 'fa-file-text-o';
+ }
+
public function newObject() {
return new LegalpadDocument();
}
@@ -33,8 +37,7 @@
foreach ($handles as $phid => $handle) {
$document = $objects[$phid];
$name = $document->getDocumentBody()->getTitle();
- $handle->setName($name);
- $handle->setFullName($document->getMonogram().' '.$name);
+ $handle->setName($document->getMonogram().' '.$name);
$handle->setURI('/'.$document->getMonogram());
}
}
diff --git a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
@@ -0,0 +1,33 @@
+<?php
+
+final class LegalpadDocumentDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type a document name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorApplicationLegalpad';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $results = array();
+
+ $documents = id(new LegalpadDocumentQuery())
+ ->setViewer($viewer)
+ ->execute();
+ foreach ($documents as $document) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setPHID($document->getPHID())
+ ->setIcon('fa-file-text-o')
+ ->setName($document->getMonogram().' '.$document->getTitle());
+ }
+
+ return $results;
+ }
+
+}
diff --git a/src/applications/policy/rule/PhabricatorPolicyRuleLegalpadSignature.php b/src/applications/policy/rule/PhabricatorPolicyRuleLegalpadSignature.php
--- a/src/applications/policy/rule/PhabricatorPolicyRuleLegalpadSignature.php
+++ b/src/applications/policy/rule/PhabricatorPolicyRuleLegalpadSignature.php
@@ -40,10 +40,12 @@
}
public function getValueControlTemplate() {
+ $datasource = new LegalpadDocumentDatasource();
+
return array(
'markup' => new AphrontTokenizerTemplateView(),
- 'uri' => '/typeahead/common/legalpaddocuments/',
- 'placeholder' => pht('Type a document title...'),
+ 'uri' => $datasource->getDatasourceURI(),
+ 'placeholder' => $datasource->getPlaceholderText(),
);
}
diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
--- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
+++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
@@ -34,7 +34,6 @@
$need_jump_objects = false;
$need_build_plans = false;
$need_task_priority = false;
- $need_legalpad_documents = false;
switch ($this->type) {
case 'mainsearch':
$need_users = true;
@@ -88,9 +87,6 @@
case 'taskpriority':
$need_task_priority = true;
break;
- case 'legalpaddocuments':
- $need_legalpad_documents = true;
- break;
}
$results = array();
@@ -239,18 +235,6 @@
}
}
- if ($need_legalpad_documents) {
- $documents = id(new LegalpadDocumentQuery())
- ->setViewer($viewer)
- ->execute();
- foreach ($documents as $document) {
- $results[] = id(new PhabricatorTypeaheadResult())
- ->setPHID($document->getPHID())
- ->setIcon('fa-file-text-o')
- ->setName($document->getMonogram().' '.$document->getTitle());
- }
- }
-
if ($need_projs) {
$projs = id(new PhabricatorProjectQuery())
->setViewer($viewer)

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 7:19 AM (1 d, 13 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746800
Default Alt Text
D9876.diff (7 KB)

Event Timeline