Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13995718
D9876.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D9876.id.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 24, 2:58 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746800
Default Alt Text
D9876.id.diff (7 KB)
Attached To
Mode
D9876: Modernize "legalpad" typeahead datasource
Attached
Detach File
Event Timeline
Log In to Comment