mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Add Label MenuItem
Summary: Ref T12174, lets you set labels as well for dividing content. Test Plan: Add a label, review on homepage. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12174 Differential Revision: https://secure.phabricator.com/D17278
This commit is contained in:
parent
a3417ccd78
commit
f7c3813586
2 changed files with 77 additions and 0 deletions
|
@ -2882,6 +2882,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorKeyring' => 'applications/files/keyring/PhabricatorKeyring.php',
|
'PhabricatorKeyring' => 'applications/files/keyring/PhabricatorKeyring.php',
|
||||||
'PhabricatorKeyringConfigOptionType' => 'applications/files/keyring/PhabricatorKeyringConfigOptionType.php',
|
'PhabricatorKeyringConfigOptionType' => 'applications/files/keyring/PhabricatorKeyringConfigOptionType.php',
|
||||||
'PhabricatorLDAPAuthProvider' => 'applications/auth/provider/PhabricatorLDAPAuthProvider.php',
|
'PhabricatorLDAPAuthProvider' => 'applications/auth/provider/PhabricatorLDAPAuthProvider.php',
|
||||||
|
'PhabricatorLabelProfileMenuItem' => 'applications/search/menuitem/PhabricatorLabelProfileMenuItem.php',
|
||||||
'PhabricatorLegalpadApplication' => 'applications/legalpad/application/PhabricatorLegalpadApplication.php',
|
'PhabricatorLegalpadApplication' => 'applications/legalpad/application/PhabricatorLegalpadApplication.php',
|
||||||
'PhabricatorLegalpadConfigOptions' => 'applications/legalpad/config/PhabricatorLegalpadConfigOptions.php',
|
'PhabricatorLegalpadConfigOptions' => 'applications/legalpad/config/PhabricatorLegalpadConfigOptions.php',
|
||||||
'PhabricatorLegalpadDocumentPHIDType' => 'applications/legalpad/phid/PhabricatorLegalpadDocumentPHIDType.php',
|
'PhabricatorLegalpadDocumentPHIDType' => 'applications/legalpad/phid/PhabricatorLegalpadDocumentPHIDType.php',
|
||||||
|
@ -7938,6 +7939,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorKeyring' => 'Phobject',
|
'PhabricatorKeyring' => 'Phobject',
|
||||||
'PhabricatorKeyringConfigOptionType' => 'PhabricatorConfigJSONOptionType',
|
'PhabricatorKeyringConfigOptionType' => 'PhabricatorConfigJSONOptionType',
|
||||||
'PhabricatorLDAPAuthProvider' => 'PhabricatorAuthProvider',
|
'PhabricatorLDAPAuthProvider' => 'PhabricatorAuthProvider',
|
||||||
|
'PhabricatorLabelProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorLegalpadApplication' => 'PhabricatorApplication',
|
'PhabricatorLegalpadApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorLegalpadConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorLegalpadConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorLegalpadDocumentPHIDType' => 'PhabricatorPHIDType',
|
'PhabricatorLegalpadDocumentPHIDType' => 'PhabricatorPHIDType',
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorLabelProfileMenuItem
|
||||||
|
extends PhabricatorProfileMenuItem {
|
||||||
|
|
||||||
|
const MENUITEMKEY = 'label';
|
||||||
|
const FIELD_NAME = 'name';
|
||||||
|
|
||||||
|
public function getMenuItemTypeIcon() {
|
||||||
|
return 'fa-map-signs';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMenuItemTypeName() {
|
||||||
|
return pht('Label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canAddToObject($object) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDisplayName(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
return $this->getLabelName($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildEditEngineFields(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorTextEditField())
|
||||||
|
->setKey(self::FIELD_NAME)
|
||||||
|
->setLabel(pht('Name'))
|
||||||
|
->setIsRequired(true)
|
||||||
|
->setValue($this->getLabelName($config)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getLabelName(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
return $config->getMenuItemProperty('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newNavigationMenuItems(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
|
||||||
|
$name = $this->getLabelName($config);
|
||||||
|
|
||||||
|
$item = $this->newItem()
|
||||||
|
->setName($name)
|
||||||
|
->setType(PHUIListItemView::TYPE_LABEL);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateTransactions(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config,
|
||||||
|
$field_key,
|
||||||
|
$value,
|
||||||
|
array $xactions) {
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$errors = array();
|
||||||
|
|
||||||
|
if ($field_key == self::FIELD_NAME) {
|
||||||
|
if ($this->isEmptyTransaction($value, $xactions)) {
|
||||||
|
$errors[] = $this->newRequiredError(
|
||||||
|
pht('You must choose a label name.'),
|
||||||
|
$field_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue