mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Modernize "legalpad" typeahead datasource
Summary: Ref T4420. Modernize legalpad. Test Plan: - Used typeahead in Herald rules. - Used typeahead in Policy dialog. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9876
This commit is contained in:
parent
a2caea13d6
commit
4e77984644
6 changed files with 62 additions and 33 deletions
|
@ -864,6 +864,7 @@ phutil_register_library_map(array(
|
|||
'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 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorMarkupInterface',
|
||||
),
|
||||
'LegalpadDocumentCommentController' => 'LegalpadController',
|
||||
'LegalpadDocumentDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'LegalpadDocumentDoneController' => 'LegalpadController',
|
||||
'LegalpadDocumentEditController' => 'LegalpadController',
|
||||
'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
|
|
|
@ -588,20 +588,25 @@ final class HeraldRuleController extends HeraldController {
|
|||
$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,
|
||||
|
|
|
@ -12,6 +12,10 @@ final class PhabricatorLegalpadPHIDTypeDocument extends PhabricatorPHIDType {
|
|||
return pht('Legalpad Document');
|
||||
}
|
||||
|
||||
public function getTypeIcon() {
|
||||
return 'fa-file-text-o';
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new LegalpadDocument();
|
||||
}
|
||||
|
@ -33,8 +37,7 @@ final class PhabricatorLegalpadPHIDTypeDocument extends PhabricatorPHIDType {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -40,10 +40,12 @@ final class PhabricatorPolicyRuleLegalpadSignature
|
|||
}
|
||||
|
||||
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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$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 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
case 'taskpriority':
|
||||
$need_task_priority = true;
|
||||
break;
|
||||
case 'legalpaddocuments':
|
||||
$need_legalpad_documents = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
@ -239,18 +235,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue