mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Provide a "PHUIFormIconSetControl"
Summary: Ref T9992. This is a step on the path to getting EditEngine working in Badges, Projects and Calendar. This doesn't add a new `EditField` for icons yet, just standardizes the old stuff. New stuff is more general and I saved 150 lines of code. I put the endpoint in Files because the similar "choose a profile picture" endpoint will definitely go there, and this endpoint might eventually feature, like, "draw your own icon~~" or something. Test Plan: - Created events, projects and badges with custom icons. - Edited events, projects and badges, changing their icons. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9992 Differential Revision: https://secure.phabricator.com/D14799
This commit is contained in:
parent
57cc30d0c4
commit
5e182180a9
32 changed files with 437 additions and 582 deletions
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
return array(
|
||||
'names' => array(
|
||||
'core.pkg.css' => '6d8c526d',
|
||||
'core.pkg.css' => '8378907a',
|
||||
'core.pkg.js' => 'c60f35d8',
|
||||
'darkconsole.pkg.js' => 'e7393ebb',
|
||||
'differential.pkg.css' => '2de124c9',
|
||||
|
@ -131,7 +131,7 @@ return array(
|
|||
'rsrc/css/phui/phui-document.css' => 'a4a1c3b9',
|
||||
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
|
||||
'rsrc/css/phui/phui-fontkit.css' => '9cda225e',
|
||||
'rsrc/css/phui/phui-form-view.css' => 'c1d2ef29',
|
||||
'rsrc/css/phui/phui-form-view.css' => 'cf7da606',
|
||||
'rsrc/css/phui/phui-form.css' => 'afdb2c6e',
|
||||
'rsrc/css/phui/phui-header-view.css' => '55bb32dd',
|
||||
'rsrc/css/phui/phui-icon.css' => 'b0a6b1b6',
|
||||
|
@ -464,7 +464,7 @@ return array(
|
|||
'rsrc/js/core/behavior-active-nav.js' => 'e379b58e',
|
||||
'rsrc/js/core/behavior-audio-source.js' => '59b251eb',
|
||||
'rsrc/js/core/behavior-autofocus.js' => '7319e029',
|
||||
'rsrc/js/core/behavior-choose-control.js' => '6153c708',
|
||||
'rsrc/js/core/behavior-choose-control.js' => 'dfaafb14',
|
||||
'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2',
|
||||
'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae',
|
||||
'rsrc/js/core/behavior-device.js' => 'a205cf28',
|
||||
|
@ -570,7 +570,7 @@ return array(
|
|||
'javelin-behavior-audio-source' => '59b251eb',
|
||||
'javelin-behavior-audit-preview' => 'd835b03a',
|
||||
'javelin-behavior-bulk-job-reload' => 'edf8a145',
|
||||
'javelin-behavior-choose-control' => '6153c708',
|
||||
'javelin-behavior-choose-control' => 'dfaafb14',
|
||||
'javelin-behavior-comment-actions' => 'bb0d2d0c',
|
||||
'javelin-behavior-config-reorder-fields' => 'b6993408',
|
||||
'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a',
|
||||
|
@ -805,7 +805,7 @@ return array(
|
|||
'phui-font-icon-base-css' => 'ecbbb4c2',
|
||||
'phui-fontkit-css' => '9cda225e',
|
||||
'phui-form-css' => 'afdb2c6e',
|
||||
'phui-form-view-css' => 'c1d2ef29',
|
||||
'phui-form-view-css' => 'cf7da606',
|
||||
'phui-header-view-css' => '55bb32dd',
|
||||
'phui-icon-view-css' => 'b0a6b1b6',
|
||||
'phui-image-mask-css' => '5a8b09c8',
|
||||
|
@ -1266,12 +1266,6 @@ return array(
|
|||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'6153c708' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'javelin-workflow',
|
||||
),
|
||||
'61cbc29a' => array(
|
||||
'javelin-magical-init',
|
||||
'javelin-util',
|
||||
|
@ -1890,6 +1884,12 @@ return array(
|
|||
'df5e11d2' => array(
|
||||
'javelin-install',
|
||||
),
|
||||
'dfaafb14' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'javelin-workflow',
|
||||
),
|
||||
'e10f8e18' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
|
|
|
@ -114,7 +114,6 @@ phutil_register_library_map(array(
|
|||
'AphrontException' => 'aphront/exception/AphrontException.php',
|
||||
'AphrontFileResponse' => 'aphront/response/AphrontFileResponse.php',
|
||||
'AphrontFormCheckboxControl' => 'view/form/control/AphrontFormCheckboxControl.php',
|
||||
'AphrontFormChooseButtonControl' => 'view/form/control/AphrontFormChooseButtonControl.php',
|
||||
'AphrontFormControl' => 'view/form/control/AphrontFormControl.php',
|
||||
'AphrontFormDateControl' => 'view/form/control/AphrontFormDateControl.php',
|
||||
'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php',
|
||||
|
@ -1474,6 +1473,7 @@ phutil_register_library_map(array(
|
|||
'PHUIFeedStoryView' => 'view/phui/PHUIFeedStoryView.php',
|
||||
'PHUIFormDividerControl' => 'view/form/control/PHUIFormDividerControl.php',
|
||||
'PHUIFormFreeformDateControl' => 'view/form/control/PHUIFormFreeformDateControl.php',
|
||||
'PHUIFormIconSetControl' => 'view/form/control/PHUIFormIconSetControl.php',
|
||||
'PHUIFormInsetView' => 'view/form/PHUIFormInsetView.php',
|
||||
'PHUIFormLayoutView' => 'view/form/PHUIFormLayoutView.php',
|
||||
'PHUIFormMultiSubmitControl' => 'view/form/control/PHUIFormMultiSubmitControl.php',
|
||||
|
@ -1774,10 +1774,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
|
||||
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
|
||||
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
|
||||
'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php',
|
||||
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
|
||||
'PhabricatorBadgesEditor' => 'applications/badges/editor/PhabricatorBadgesEditor.php',
|
||||
'PhabricatorBadgesIcon' => 'applications/badges/icon/PhabricatorBadgesIcon.php',
|
||||
'PhabricatorBadgesIconSet' => 'applications/badges/icon/PhabricatorBadgesIconSet.php',
|
||||
'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php',
|
||||
'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php',
|
||||
'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php',
|
||||
|
@ -1833,7 +1832,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCalendarEventCommentController' => 'applications/calendar/controller/PhabricatorCalendarEventCommentController.php',
|
||||
'PhabricatorCalendarEventDragController' => 'applications/calendar/controller/PhabricatorCalendarEventDragController.php',
|
||||
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
|
||||
'PhabricatorCalendarEventEditIconController' => 'applications/calendar/controller/PhabricatorCalendarEventEditIconController.php',
|
||||
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
|
||||
'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php',
|
||||
'PhabricatorCalendarEventInvitee' => 'applications/calendar/storage/PhabricatorCalendarEventInvitee.php',
|
||||
|
@ -1852,7 +1850,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
|
||||
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
|
||||
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
|
||||
'PhabricatorCalendarIcon' => 'applications/calendar/icon/PhabricatorCalendarIcon.php',
|
||||
'PhabricatorCalendarIconSet' => 'applications/calendar/icon/PhabricatorCalendarIconSet.php',
|
||||
'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php',
|
||||
'PhabricatorCalendarReplyHandler' => 'applications/calendar/mail/PhabricatorCalendarReplyHandler.php',
|
||||
'PhabricatorCalendarSchemaSpec' => 'applications/calendar/storage/PhabricatorCalendarSchemaSpec.php',
|
||||
|
@ -2263,6 +2261,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFileEditor' => 'applications/files/editor/PhabricatorFileEditor.php',
|
||||
'PhabricatorFileFilePHIDType' => 'applications/files/phid/PhabricatorFileFilePHIDType.php',
|
||||
'PhabricatorFileHasObjectEdgeType' => 'applications/files/edge/PhabricatorFileHasObjectEdgeType.php',
|
||||
'PhabricatorFileIconSetSelectController' => 'applications/files/controller/PhabricatorFileIconSetSelectController.php',
|
||||
'PhabricatorFileImageMacro' => 'applications/macro/storage/PhabricatorFileImageMacro.php',
|
||||
'PhabricatorFileImageTransform' => 'applications/files/transform/PhabricatorFileImageTransform.php',
|
||||
'PhabricatorFileInfoController' => 'applications/files/controller/PhabricatorFileInfoController.php',
|
||||
|
@ -2359,6 +2358,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php',
|
||||
'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php',
|
||||
'PhabricatorIconRemarkupRule' => 'applications/macro/markup/PhabricatorIconRemarkupRule.php',
|
||||
'PhabricatorIconSet' => 'applications/files/iconset/PhabricatorIconSet.php',
|
||||
'PhabricatorIconSetIcon' => 'applications/files/iconset/PhabricatorIconSetIcon.php',
|
||||
'PhabricatorImageMacroRemarkupRule' => 'applications/macro/markup/PhabricatorImageMacroRemarkupRule.php',
|
||||
'PhabricatorImageTransformer' => 'applications/files/PhabricatorImageTransformer.php',
|
||||
'PhabricatorImagemagickSetupCheck' => 'applications/config/check/PhabricatorImagemagickSetupCheck.php',
|
||||
|
@ -2809,12 +2810,11 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectDatasource' => 'applications/project/typeahead/PhabricatorProjectDatasource.php',
|
||||
'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php',
|
||||
'PhabricatorProjectEditDetailsController' => 'applications/project/controller/PhabricatorProjectEditDetailsController.php',
|
||||
'PhabricatorProjectEditIconController' => 'applications/project/controller/PhabricatorProjectEditIconController.php',
|
||||
'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php',
|
||||
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
|
||||
'PhabricatorProjectFeedController' => 'applications/project/controller/PhabricatorProjectFeedController.php',
|
||||
'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php',
|
||||
'PhabricatorProjectIcon' => 'applications/project/icon/PhabricatorProjectIcon.php',
|
||||
'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
|
||||
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
|
||||
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
|
||||
'PhabricatorProjectLogicalAndDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalAndDatasource.php',
|
||||
|
@ -3973,7 +3973,6 @@ phutil_register_library_map(array(
|
|||
'AphrontException' => 'Exception',
|
||||
'AphrontFileResponse' => 'AphrontResponse',
|
||||
'AphrontFormCheckboxControl' => 'AphrontFormControl',
|
||||
'AphrontFormChooseButtonControl' => 'AphrontFormControl',
|
||||
'AphrontFormControl' => 'AphrontView',
|
||||
'AphrontFormDateControl' => 'AphrontFormControl',
|
||||
'AphrontFormDateControlValue' => 'Phobject',
|
||||
|
@ -5527,6 +5526,7 @@ phutil_register_library_map(array(
|
|||
'PHUIFeedStoryView' => 'AphrontView',
|
||||
'PHUIFormDividerControl' => 'AphrontFormControl',
|
||||
'PHUIFormFreeformDateControl' => 'AphrontFormControl',
|
||||
'PHUIFormIconSetControl' => 'AphrontFormControl',
|
||||
'PHUIFormInsetView' => 'AphrontView',
|
||||
'PHUIFormLayoutView' => 'AphrontView',
|
||||
'PHUIFormMultiSubmitControl' => 'AphrontFormControl',
|
||||
|
@ -5873,10 +5873,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
|
||||
'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController',
|
||||
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
|
||||
'PhabricatorBadgesEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorBadgesIcon' => 'Phobject',
|
||||
'PhabricatorBadgesIconSet' => 'PhabricatorIconSet',
|
||||
'PhabricatorBadgesListController' => 'PhabricatorBadgesController',
|
||||
'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType',
|
||||
|
@ -5944,7 +5943,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventDragController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventEditIconController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand',
|
||||
'PhabricatorCalendarEventInvitee' => array(
|
||||
|
@ -5966,7 +5964,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
|
||||
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorCalendarIcon' => 'Phobject',
|
||||
'PhabricatorCalendarIconSet' => 'PhabricatorIconSet',
|
||||
'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'PhabricatorCalendarReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||
'PhabricatorCalendarSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||
|
@ -6452,6 +6450,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFileEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorFileFilePHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorFileHasObjectEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorFileIconSetSelectController' => 'PhabricatorFileController',
|
||||
'PhabricatorFileImageMacro' => array(
|
||||
'PhabricatorFileDAO',
|
||||
'PhabricatorSubscribableInterface',
|
||||
|
@ -6563,6 +6562,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorIDsSearchField' => 'PhabricatorSearchField',
|
||||
'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter',
|
||||
'PhabricatorIconRemarkupRule' => 'PhutilRemarkupRule',
|
||||
'PhabricatorIconSet' => 'Phobject',
|
||||
'PhabricatorIconSetIcon' => 'Phobject',
|
||||
'PhabricatorImageMacroRemarkupRule' => 'PhutilRemarkupRule',
|
||||
'PhabricatorImageTransformer' => 'Phobject',
|
||||
'PhabricatorImagemagickSetupCheck' => 'PhabricatorSetupCheck',
|
||||
|
@ -7095,12 +7096,11 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField',
|
||||
'PhabricatorProjectEditDetailsController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditIconController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorProjectFeedController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectHeraldAction' => 'HeraldAction',
|
||||
'PhabricatorProjectIcon' => 'Phobject',
|
||||
'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
|
||||
'PhabricatorProjectListController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectLogicalAndDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'PhabricatorProjectLogicalDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
|
|
|
@ -49,10 +49,6 @@ final class PhabricatorBadgesApplication extends PhabricatorApplication {
|
|||
=> 'PhabricatorBadgesArchiveController',
|
||||
'view/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhabricatorBadgesViewController',
|
||||
'icon/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorBadgesEditIconController',
|
||||
'icon/'
|
||||
=> 'PhabricatorBadgesEditIconController',
|
||||
'recipients/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorBadgesEditRecipientsController',
|
||||
'recipients/(?P<id>[1-9]\d*)/remove/'
|
||||
|
|
|
@ -111,13 +111,6 @@ final class PhabricatorBadgesEditController
|
|||
}
|
||||
}
|
||||
|
||||
if ($is_new) {
|
||||
$icon_uri = $this->getApplicationURI('icon/');
|
||||
} else {
|
||||
$icon_uri = $this->getApplicationURI('icon/'.$badge->getID().'/');
|
||||
}
|
||||
$icon_display = PhabricatorBadgesIcon::renderIconForChooser($v_icon);
|
||||
|
||||
$policies = id(new PhabricatorPolicyQuery())
|
||||
->setViewer($viewer)
|
||||
->setObject($badge)
|
||||
|
@ -137,12 +130,10 @@ final class PhabricatorBadgesEditController
|
|||
->setLabel(pht('Flavor Text'))
|
||||
->setValue($v_flav))
|
||||
->appendChild(
|
||||
id(new AphrontFormChooseButtonControl())
|
||||
id(new PHUIFormIconSetControl())
|
||||
->setLabel(pht('Icon'))
|
||||
->setName('icon')
|
||||
->setDisplayValue($icon_display)
|
||||
->setButtonText(pht('Choose Icon...'))
|
||||
->setChooseURI($icon_uri)
|
||||
->setIconSet(new PhabricatorBadgesIconSet())
|
||||
->setValue($v_icon))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorBadgesEditIconController
|
||||
extends PhabricatorBadgesController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if ($id) {
|
||||
$badge = id(new PhabricatorBadgesQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$badge) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
$cancel_uri =
|
||||
$this->getApplicationURI('view/'.$badge->getID().'/');
|
||||
$badge_icon = $badge->getIcon();
|
||||
} else {
|
||||
$this->requireApplicationCapability(
|
||||
PhabricatorBadgesCreateCapability::CAPABILITY);
|
||||
|
||||
$cancel_uri = '/badges/';
|
||||
$badge_icon = $request->getStr('value');
|
||||
}
|
||||
|
||||
require_celerity_resource('project-icon-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$badge_icons = PhabricatorBadgesIcon::getIconMap();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_icon = $request->getStr('icon');
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
'value' => $v_icon,
|
||||
'display' => PhabricatorBadgesIcon::renderIconForChooser($v_icon),
|
||||
));
|
||||
}
|
||||
|
||||
$ii = 0;
|
||||
$buttons = array();
|
||||
foreach ($badge_icons as $icon => $label) {
|
||||
$view = id(new PHUIIconView())
|
||||
->setIconFont($icon);
|
||||
|
||||
$aural = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'aural' => true,
|
||||
),
|
||||
pht('Choose "%s" Icon', $label));
|
||||
|
||||
if ($icon == $badge_icon) {
|
||||
$class_extra = ' selected';
|
||||
} else {
|
||||
$class_extra = null;
|
||||
}
|
||||
|
||||
$buttons[] = javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => 'icon-button'.$class_extra,
|
||||
'name' => 'icon',
|
||||
'value' => $icon,
|
||||
'type' => 'submit',
|
||||
'sigil' => 'has-tooltip',
|
||||
'meta' => array(
|
||||
'tip' => $label,
|
||||
),
|
||||
),
|
||||
array(
|
||||
$aural,
|
||||
$view,
|
||||
));
|
||||
if ((++$ii % 4) == 0) {
|
||||
$buttons[] = phutil_tag('br');
|
||||
}
|
||||
}
|
||||
|
||||
$buttons = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'icon-grid',
|
||||
),
|
||||
$buttons);
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Choose Badge Icon'))
|
||||
->appendChild($buttons)
|
||||
->addCancelButton($cancel_uri);
|
||||
}
|
||||
}
|
|
@ -85,7 +85,6 @@ final class PhabricatorBadgesViewController
|
|||
->setObject($badge);
|
||||
|
||||
$quality = idx($badge->getQualityNameMap(), $badge->getQuality());
|
||||
$icon = idx($badge->getIconNameMap(), $badge->getIcon());
|
||||
|
||||
$view->addProperty(
|
||||
pht('Quality'),
|
||||
|
@ -93,7 +92,8 @@ final class PhabricatorBadgesViewController
|
|||
|
||||
$view->addProperty(
|
||||
pht('Icon'),
|
||||
$icon);
|
||||
id(new PhabricatorBadgesIconSet())
|
||||
->getIconLabel($badge->getIcon()));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Flavor'),
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorBadgesIcon extends Phobject {
|
||||
|
||||
public static function getIconMap() {
|
||||
return
|
||||
array(
|
||||
'fa-star' => pht('Superstar'),
|
||||
'fa-user' => pht('Average Person'),
|
||||
'fa-bug' => pht('Ladybug'),
|
||||
'fa-users' => pht('Triplets'),
|
||||
|
||||
'fa-book' => pht('Nominomicon'),
|
||||
'fa-rocket' => pht('Escape Route'),
|
||||
'fa-life-ring' => pht('Foam Circle'),
|
||||
'fa-birthday-cake' => pht('Cake Day'),
|
||||
|
||||
'fa-camera-retro' => pht('Leica Enthusiast'),
|
||||
'fa-beer' => pht('Liquid Lunch'),
|
||||
'fa-gift' => pht('Free Stuff'),
|
||||
'fa-eye' => pht('Eye See You'),
|
||||
|
||||
'fa-heart' => pht('Love is Love'),
|
||||
'fa-trophy' => pht('Winner at Things'),
|
||||
'fa-umbrella' => pht('Rain Defender'),
|
||||
'fa-graduation-cap' => pht('In Debt'),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public static function getLabel($key) {
|
||||
$map = self::getIconMap();
|
||||
return $map[$key];
|
||||
}
|
||||
|
||||
public static function getAPIName($key) {
|
||||
return substr($key, 3);
|
||||
}
|
||||
|
||||
public static function renderIconForChooser($icon) {
|
||||
$badge_icons = self::getIconMap();
|
||||
|
||||
return phutil_tag(
|
||||
'span',
|
||||
array(),
|
||||
array(
|
||||
id(new PHUIIconView())->setIconFont($icon),
|
||||
' ',
|
||||
idx($badge_icons, $icon, pht('Unknown Icon')),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
45
src/applications/badges/icon/PhabricatorBadgesIconSet.php
Normal file
45
src/applications/badges/icon/PhabricatorBadgesIconSet.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorBadgesIconSet
|
||||
extends PhabricatorIconSet {
|
||||
|
||||
const ICONSETKEY = 'badges';
|
||||
|
||||
public function getSelectIconTitleText() {
|
||||
return pht('Choose Badge Icon');
|
||||
}
|
||||
|
||||
protected function newIcons() {
|
||||
$map = array(
|
||||
'fa-star' => pht('Superstar'),
|
||||
'fa-user' => pht('Average Person'),
|
||||
'fa-bug' => pht('Ladybug'),
|
||||
'fa-users' => pht('Triplets'),
|
||||
|
||||
'fa-book' => pht('Nominomicon'),
|
||||
'fa-rocket' => pht('Escape Route'),
|
||||
'fa-life-ring' => pht('Foam Circle'),
|
||||
'fa-birthday-cake' => pht('Cake Day'),
|
||||
|
||||
'fa-camera-retro' => pht('Leica Enthusiast'),
|
||||
'fa-beer' => pht('Liquid Lunch'),
|
||||
'fa-gift' => pht('Free Stuff'),
|
||||
'fa-eye' => pht('Eye See You'),
|
||||
|
||||
'fa-heart' => pht('Love is Love'),
|
||||
'fa-trophy' => pht('Winner at Things'),
|
||||
'fa-umbrella' => pht('Rain Defender'),
|
||||
'fa-graduation-cap' => pht('In Debt'),
|
||||
);
|
||||
|
||||
$icons = array();
|
||||
foreach ($map as $key => $label) {
|
||||
$icons[] = id(new PhabricatorIconSetIcon())
|
||||
->setKey($key)
|
||||
->setLabel($label);
|
||||
}
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
}
|
|
@ -54,10 +54,6 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
|
|||
);
|
||||
}
|
||||
|
||||
public static function getIconNameMap() {
|
||||
return PhabricatorBadgesIcon::getIconMap();
|
||||
}
|
||||
|
||||
public static function initializeNewBadge(PhabricatorUser $actor) {
|
||||
$app = id(new PhabricatorApplicationQuery())
|
||||
->setViewer($actor)
|
||||
|
|
|
@ -78,9 +78,11 @@ final class PhabricatorBadgesTransaction
|
|||
$this->renderHandleLink($author_phid),
|
||||
$new);
|
||||
} else {
|
||||
$icon_map = PhabricatorBadgesBadge::getIconNameMap();
|
||||
$icon_new = idx($icon_map, $new, $new);
|
||||
$icon_old = idx($icon_map, $old, $old);
|
||||
$set = new PhabricatorBadgesIconSet();
|
||||
|
||||
$icon_old = $set->getIconLabel($old);
|
||||
$icon_new = $set->getIconLabel($new);
|
||||
|
||||
return pht(
|
||||
'%s updated the icon for this badge from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
|
|
|
@ -46,10 +46,6 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
|||
'(?:query/(?P<queryKey>[^/]+)/(?:(?P<year>\d+)/'.
|
||||
'(?P<month>\d+)/)?(?:(?P<day>\d+)/)?)?'
|
||||
=> 'PhabricatorCalendarEventListController',
|
||||
'icon/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorCalendarEventEditIconController',
|
||||
'icon/'
|
||||
=> 'PhabricatorCalendarEventEditIconController',
|
||||
'event/' => array(
|
||||
'create/'
|
||||
=> 'PhabricatorCalendarEventEditController',
|
||||
|
|
|
@ -499,18 +499,11 @@ final class PhabricatorCalendarEventEditController
|
|||
->setUser($viewer)
|
||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
|
||||
|
||||
if ($this->isCreate()) {
|
||||
$icon_uri = $this->getApplicationURI('icon/');
|
||||
} else {
|
||||
$icon_uri = $this->getApplicationURI('icon/'.$event->getID().'/');
|
||||
}
|
||||
$icon_display = PhabricatorCalendarIcon::renderIconForChooser($icon);
|
||||
$icon = id(new AphrontFormChooseButtonControl())
|
||||
|
||||
$icon = id(new PHUIFormIconSetControl())
|
||||
->setLabel(pht('Icon'))
|
||||
->setName('icon')
|
||||
->setDisplayValue($icon_display)
|
||||
->setButtonText(pht('Choose Icon...'))
|
||||
->setChooseURI($icon_uri)
|
||||
->setIconSet(new PhabricatorCalendarIconSet())
|
||||
->setValue($icon);
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCalendarEventEditIconController
|
||||
extends PhabricatorCalendarController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getUser();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if ($id) {
|
||||
$event = id(new PhabricatorCalendarEventQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$event) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
$cancel_uri = $this->getApplicationURI('/E'.$event->getID());
|
||||
$event_icon = $event->getIcon();
|
||||
} else {
|
||||
$cancel_uri = '/calendar/';
|
||||
$event_icon = $request->getStr('value');
|
||||
}
|
||||
|
||||
require_celerity_resource('calendar-icon-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$calendar_icons = PhabricatorCalendarIcon::getIconMap();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_icon = $request->getStr('icon');
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
'value' => $v_icon,
|
||||
'display' => PhabricatorCalendarIcon::renderIconForChooser($v_icon),
|
||||
));
|
||||
}
|
||||
|
||||
$ii = 0;
|
||||
$buttons = array();
|
||||
foreach ($calendar_icons as $icon => $label) {
|
||||
$view = id(new PHUIIconView())
|
||||
->setIconFont($icon);
|
||||
|
||||
$aural = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'aural' => true,
|
||||
),
|
||||
pht('Choose "%s" Icon', $label));
|
||||
|
||||
if ($icon == $event_icon) {
|
||||
$class_extra = ' selected';
|
||||
} else {
|
||||
$class_extra = null;
|
||||
}
|
||||
|
||||
$buttons[] = javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => 'icon-button'.$class_extra,
|
||||
'name' => 'icon',
|
||||
'value' => $icon,
|
||||
'type' => 'submit',
|
||||
'sigil' => 'has-tooltip',
|
||||
'meta' => array(
|
||||
'tip' => $label,
|
||||
),
|
||||
),
|
||||
array(
|
||||
$aural,
|
||||
$view,
|
||||
));
|
||||
if ((++$ii % 4) == 0) {
|
||||
$buttons[] = phutil_tag('br');
|
||||
}
|
||||
}
|
||||
|
||||
$buttons = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'icon-grid',
|
||||
),
|
||||
$buttons);
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Choose Calendar Event Icon'))
|
||||
->appendChild($buttons)
|
||||
->addCancelButton($cancel_uri);
|
||||
}
|
||||
}
|
|
@ -360,11 +360,10 @@ final class PhabricatorCalendarEventViewController
|
|||
|
||||
$properties->invokeWillRenderEvent();
|
||||
|
||||
$icon_display = PhabricatorCalendarIcon::renderIconForChooser(
|
||||
$event->getIcon());
|
||||
$properties->addProperty(
|
||||
pht('Icon'),
|
||||
$icon_display);
|
||||
id(new PhabricatorCalendarIconSet())
|
||||
->getIconLabel($event->getIcon()));
|
||||
|
||||
if (strlen($event->getDescription())) {
|
||||
$description = PhabricatorMarkupEngine::renderOneObject(
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCalendarIcon extends Phobject {
|
||||
|
||||
public static function getIconMap() {
|
||||
return
|
||||
array(
|
||||
'fa-calendar' => pht('Default'),
|
||||
'fa-glass' => pht('Party'),
|
||||
'fa-plane' => pht('Travel'),
|
||||
'fa-plus-square' => pht('Health / Appointment'),
|
||||
'fa-rocket' => pht('Sabatical / Leave'),
|
||||
'fa-home' => pht('Working From Home'),
|
||||
'fa-tree' => pht('Holiday'),
|
||||
'fa-gamepad' => pht('Staycation'),
|
||||
'fa-coffee' => pht('Coffee Meeting'),
|
||||
'fa-film' => pht('Movie'),
|
||||
'fa-users' => pht('Meeting'),
|
||||
'fa-cutlery' => pht('Meal'),
|
||||
'fa-paw' => pht('Pet Activity'),
|
||||
'fa-institution' => pht('Official Business'),
|
||||
'fa-bus' => pht('Field Trip'),
|
||||
'fa-microphone' => pht('Conference'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getLabel($key) {
|
||||
$map = self::getIconMap();
|
||||
return $map[$key];
|
||||
}
|
||||
|
||||
public static function getAPIName($key) {
|
||||
return substr($key, 3);
|
||||
}
|
||||
|
||||
public static function renderIconForChooser($icon) {
|
||||
$calendar_icons = self::getIconMap();
|
||||
|
||||
return phutil_tag(
|
||||
'span',
|
||||
array(),
|
||||
array(
|
||||
id(new PHUIIconView())->setIconFont($icon),
|
||||
' ',
|
||||
idx($calendar_icons, $icon, pht('Unknown Icon')),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCalendarIconSet
|
||||
extends PhabricatorIconSet {
|
||||
|
||||
const ICONSETKEY = 'calendar.event';
|
||||
|
||||
public function getSelectIconTitleText() {
|
||||
return pht('Choose Event Icon');
|
||||
}
|
||||
|
||||
protected function newIcons() {
|
||||
$map = array(
|
||||
'fa-calendar' => pht('Default'),
|
||||
'fa-glass' => pht('Party'),
|
||||
'fa-plane' => pht('Travel'),
|
||||
'fa-plus-square' => pht('Health / Appointment'),
|
||||
|
||||
'fa-rocket' => pht('Sabatical / Leave'),
|
||||
'fa-home' => pht('Working From Home'),
|
||||
'fa-tree' => pht('Holiday'),
|
||||
'fa-gamepad' => pht('Staycation'),
|
||||
|
||||
'fa-coffee' => pht('Coffee Meeting'),
|
||||
'fa-film' => pht('Movie'),
|
||||
'fa-users' => pht('Meeting'),
|
||||
'fa-cutlery' => pht('Meal'),
|
||||
|
||||
'fa-paw' => pht('Pet Activity'),
|
||||
'fa-institution' => pht('Official Business'),
|
||||
'fa-bus' => pht('Field Trip'),
|
||||
'fa-microphone' => pht('Conference'),
|
||||
);
|
||||
|
||||
$icons = array();
|
||||
foreach ($map as $key => $label) {
|
||||
$icons[] = id(new PhabricatorIconSetIcon())
|
||||
->setKey($key)
|
||||
->setLabel($label);
|
||||
}
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
}
|
|
@ -156,10 +156,11 @@ final class PhabricatorCalendarEventTransaction
|
|||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
case self::TYPE_ICON:
|
||||
$set = new PhabricatorCalendarIconSet();
|
||||
return pht(
|
||||
'%s set this event\'s icon to %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
PhabricatorCalendarIcon::getLabel($new));
|
||||
$set->getIconLabel($new));
|
||||
break;
|
||||
case self::TYPE_CANCEL:
|
||||
if ($new) {
|
||||
|
@ -356,11 +357,12 @@ final class PhabricatorCalendarEventTransaction
|
|||
$this->renderHandleLink($object_phid));
|
||||
}
|
||||
case self::TYPE_ICON:
|
||||
$set = new PhabricatorCalendarIconSet();
|
||||
return pht(
|
||||
'%s set the icon for %s to %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
PhabricatorCalendarIcon::getLabel($new));
|
||||
$set->getIconLabel($new));
|
||||
case self::TYPE_CANCEL:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
|
|
@ -83,6 +83,9 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
|
|||
'PhabricatorFileTransformListController',
|
||||
'uploaddialog/' => 'PhabricatorFileUploadDialogController',
|
||||
'download/(?P<phid>[^/]+)/' => 'PhabricatorFileDialogController',
|
||||
'iconset/(?P<key>[^/]+)/' => array(
|
||||
'select/' => 'PhabricatorFileIconSetSelectController',
|
||||
),
|
||||
) + $this->getResourceSubroutes(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorFileIconSetSelectController
|
||||
extends PhabricatorFileController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$key = $request->getURIData('key');
|
||||
|
||||
$set = PhabricatorIconSet::getIconSetByKey($key);
|
||||
if (!$set) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$v_icon = $request->getStr('icon');
|
||||
if ($request->isFormPost()) {
|
||||
$icon = $set->getIcon($v_icon);
|
||||
|
||||
if ($icon) {
|
||||
$payload = array(
|
||||
'value' => $icon->getKey(),
|
||||
'display' => $set->renderIconForControl($icon),
|
||||
);
|
||||
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent($payload);
|
||||
}
|
||||
}
|
||||
|
||||
require_celerity_resource('project-icon-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$ii = 0;
|
||||
$buttons = array();
|
||||
foreach ($set->getIcons() as $icon) {
|
||||
$label = $icon->getLabel();
|
||||
|
||||
$view = id(new PHUIIconView())
|
||||
->setIconFont($icon->getIcon());
|
||||
|
||||
$aural = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'aural' => true,
|
||||
),
|
||||
pht('Choose "%s" Icon', $label));
|
||||
|
||||
$classes = array();
|
||||
$classes[] = 'icon-button';
|
||||
|
||||
if ($icon->getKey() == $v_icon) {
|
||||
$classes[] = 'selected';
|
||||
}
|
||||
|
||||
$buttons[] = javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => implode(' ', $classes),
|
||||
'name' => 'icon',
|
||||
'value' => $icon->getKey(),
|
||||
'type' => 'submit',
|
||||
'sigil' => 'has-tooltip',
|
||||
'meta' => array(
|
||||
'tip' => $label,
|
||||
),
|
||||
),
|
||||
array(
|
||||
$aural,
|
||||
$view,
|
||||
));
|
||||
|
||||
if ((++$ii % 4) == 0) {
|
||||
$buttons[] = phutil_tag('br');
|
||||
}
|
||||
}
|
||||
|
||||
$buttons = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'icon-grid',
|
||||
),
|
||||
$buttons);
|
||||
|
||||
$dialog_title = $set->getSelectIconTitleText();
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle($dialog_title)
|
||||
->appendChild($buttons)
|
||||
->addCancelButton('/');
|
||||
}
|
||||
|
||||
}
|
70
src/applications/files/iconset/PhabricatorIconSet.php
Normal file
70
src/applications/files/iconset/PhabricatorIconSet.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
abstract class PhabricatorIconSet
|
||||
extends Phobject {
|
||||
|
||||
final public function getIconSetKey() {
|
||||
return $this->getPhobjectClassConstant('ICONSETKEY');
|
||||
}
|
||||
|
||||
public function getChooseButtonText() {
|
||||
return pht('Choose Icon...');
|
||||
}
|
||||
|
||||
public function getSelectIconTitleText() {
|
||||
return pht('Choose Icon');
|
||||
}
|
||||
|
||||
public function getSelectURI() {
|
||||
$key = $this->getIconSetKey();
|
||||
return "/file/iconset/{$key}/select/";
|
||||
}
|
||||
|
||||
final public function getIcons() {
|
||||
$icons = $this->newIcons();
|
||||
|
||||
// TODO: Validate icons.
|
||||
$icons = mpull($icons, null, 'getKey');
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
final public function getIcon($key) {
|
||||
$icons = $this->getIcons();
|
||||
return idx($icons, $key);
|
||||
}
|
||||
|
||||
final public function getIconLabel($key) {
|
||||
$icon = $this->getIcon($key);
|
||||
|
||||
if ($icon) {
|
||||
return $icon->getLabel();
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
final public function renderIconForControl(PhabricatorIconSetIcon $icon) {
|
||||
return phutil_tag(
|
||||
'span',
|
||||
array(),
|
||||
array(
|
||||
id(new PHUIIconView())->setIconFont($icon->getIcon()),
|
||||
' ',
|
||||
$icon->getLabel(),
|
||||
));
|
||||
}
|
||||
|
||||
final public static function getIconSetByKey($key) {
|
||||
$sets = self::getAllIconSets();
|
||||
return idx($sets, $key);
|
||||
}
|
||||
|
||||
final public static function getAllIconSets() {
|
||||
return id(new PhutilClassMapQuery())
|
||||
->setAncestorClass(__CLASS__)
|
||||
->setUniqueMethod('getIconSetKey')
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
40
src/applications/files/iconset/PhabricatorIconSetIcon.php
Normal file
40
src/applications/files/iconset/PhabricatorIconSetIcon.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorIconSetIcon
|
||||
extends Phobject {
|
||||
|
||||
private $key;
|
||||
private $icon;
|
||||
private $label;
|
||||
|
||||
public function setKey($key) {
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKey() {
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function setIcon($icon) {
|
||||
$this->icon = $icon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
if ($this->icon === null) {
|
||||
return $this->getKey();
|
||||
}
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
public function setLabel($label) {
|
||||
$this->label = $label;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
}
|
|
@ -59,10 +59,6 @@ final class PhabricatorProjectApplication extends PhabricatorApplication {
|
|||
=> 'PhabricatorProjectViewController',
|
||||
'picture/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectEditPictureController',
|
||||
'icon/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectEditIconController',
|
||||
'icon/'
|
||||
=> 'PhabricatorProjectEditIconController',
|
||||
'create/' => 'PhabricatorProjectEditDetailsController',
|
||||
'board/(?P<id>[1-9]\d*)/'.
|
||||
'(?P<filter>filter/)?'.
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class ProjectConduitAPIMethod extends ConduitAPIMethod {
|
|||
$project_slugs = $project->getSlugs();
|
||||
$project_slugs = array_values(mpull($project_slugs, 'getSlug'));
|
||||
|
||||
$project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon());
|
||||
$project_icon = substr($project->getIcon(), 3);
|
||||
|
||||
$result[$project->getPHID()] = array(
|
||||
'id' => $project->getID(),
|
||||
|
|
|
@ -188,14 +188,8 @@ final class PhabricatorProjectEditDetailsController
|
|||
->setError($e_name));
|
||||
$field_list->appendFieldsToForm($form);
|
||||
|
||||
$shades = PhabricatorProjectIcon::getColorMap();
|
||||
$shades = PhabricatorProjectIconSet::getColorMap();
|
||||
|
||||
if ($is_new) {
|
||||
$icon_uri = $this->getApplicationURI('icon/');
|
||||
} else {
|
||||
$icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/');
|
||||
}
|
||||
$icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon);
|
||||
list($can_lock, $lock_message) = $this->explainApplicationCapability(
|
||||
ProjectCanLockProjectsCapability::CAPABILITY,
|
||||
pht('You can update the Lock Project setting.'),
|
||||
|
@ -203,12 +197,10 @@ final class PhabricatorProjectEditDetailsController
|
|||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormChooseButtonControl())
|
||||
id(new PHUIFormIconSetControl())
|
||||
->setLabel(pht('Icon'))
|
||||
->setName('icon')
|
||||
->setDisplayValue($icon_display)
|
||||
->setButtonText(pht('Choose Icon...'))
|
||||
->setChooseURI($icon_uri)
|
||||
->setIconSet(new PhabricatorProjectIconSet())
|
||||
->setValue($v_icon))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectEditIconController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if ($id) {
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
$cancel_uri = $this->getApplicationURI('profile/'.$project->getID().'/');
|
||||
$project_icon = $project->getIcon();
|
||||
} else {
|
||||
$this->requireApplicationCapability(
|
||||
ProjectCreateProjectsCapability::CAPABILITY);
|
||||
|
||||
$cancel_uri = '/project/';
|
||||
$project_icon = $request->getStr('value');
|
||||
}
|
||||
|
||||
require_celerity_resource('project-icon-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$project_icons = PhabricatorProjectIcon::getIconMap();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_icon = $request->getStr('icon');
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
'value' => $v_icon,
|
||||
'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon),
|
||||
));
|
||||
}
|
||||
|
||||
$ii = 0;
|
||||
$buttons = array();
|
||||
foreach ($project_icons as $icon => $label) {
|
||||
$view = id(new PHUIIconView())
|
||||
->setIconFont($icon);
|
||||
|
||||
$aural = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'aural' => true,
|
||||
),
|
||||
pht('Choose "%s" Icon', $label));
|
||||
|
||||
if ($icon == $project_icon) {
|
||||
$class_extra = ' selected';
|
||||
} else {
|
||||
$class_extra = null;
|
||||
}
|
||||
|
||||
$buttons[] = javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => 'icon-button'.$class_extra,
|
||||
'name' => 'icon',
|
||||
'value' => $icon,
|
||||
'type' => 'submit',
|
||||
'sigil' => 'has-tooltip',
|
||||
'meta' => array(
|
||||
'tip' => $label,
|
||||
),
|
||||
),
|
||||
array(
|
||||
$aural,
|
||||
$view,
|
||||
));
|
||||
if ((++$ii % 4) == 0) {
|
||||
$buttons[] = phutil_tag('br');
|
||||
}
|
||||
}
|
||||
|
||||
$buttons = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'icon-grid',
|
||||
),
|
||||
$buttons);
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Choose Project Icon'))
|
||||
->appendChild($buttons)
|
||||
->addCancelButton($cancel_uri);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectIcon extends Phobject {
|
||||
|
||||
public static function getIconMap() {
|
||||
return
|
||||
array(
|
||||
'fa-briefcase' => pht('Briefcase'),
|
||||
'fa-tags' => pht('Tag'),
|
||||
'fa-folder' => pht('Folder'),
|
||||
'fa-users' => pht('Team'),
|
||||
'fa-bug' => pht('Bug'),
|
||||
'fa-trash-o' => pht('Garbage'),
|
||||
'fa-calendar' => pht('Deadline'),
|
||||
'fa-flag-checkered' => pht('Goal'),
|
||||
'fa-envelope' => pht('Communication'),
|
||||
'fa-truck' => pht('Release'),
|
||||
'fa-lock' => pht('Policy'),
|
||||
'fa-umbrella' => pht('An Umbrella'),
|
||||
'fa-cloud' => pht('The Cloud'),
|
||||
'fa-building' => pht('Company'),
|
||||
'fa-credit-card' => pht('Accounting'),
|
||||
'fa-flask' => pht('Experimental'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getColorMap() {
|
||||
$shades = PHUITagView::getShadeMap();
|
||||
$shades = array_select_keys(
|
||||
$shades,
|
||||
array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
|
||||
unset($shades[PHUITagView::COLOR_DISABLED]);
|
||||
|
||||
return $shades;
|
||||
}
|
||||
|
||||
public static function getLabel($key) {
|
||||
$map = self::getIconMap();
|
||||
return $map[$key];
|
||||
}
|
||||
|
||||
public static function getAPIName($key) {
|
||||
return substr($key, 3);
|
||||
}
|
||||
|
||||
public static function renderIconForChooser($icon) {
|
||||
$project_icons = self::getIconMap();
|
||||
|
||||
return phutil_tag(
|
||||
'span',
|
||||
array(),
|
||||
array(
|
||||
id(new PHUIIconView())->setIconFont($icon),
|
||||
' ',
|
||||
idx($project_icons, $icon, pht('Unknown Icon')),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
55
src/applications/project/icon/PhabricatorProjectIconSet.php
Normal file
55
src/applications/project/icon/PhabricatorProjectIconSet.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectIconSet
|
||||
extends PhabricatorIconSet {
|
||||
|
||||
const ICONSETKEY = 'projects';
|
||||
|
||||
public function getSelectIconTitleText() {
|
||||
return pht('Choose Project Icon');
|
||||
}
|
||||
|
||||
protected function newIcons() {
|
||||
$map = array(
|
||||
'fa-briefcase' => pht('Briefcase'),
|
||||
'fa-tags' => pht('Tag'),
|
||||
'fa-folder' => pht('Folder'),
|
||||
'fa-users' => pht('Team'),
|
||||
|
||||
'fa-bug' => pht('Bug'),
|
||||
'fa-trash-o' => pht('Garbage'),
|
||||
'fa-calendar' => pht('Deadline'),
|
||||
'fa-flag-checkered' => pht('Goal'),
|
||||
|
||||
'fa-envelope' => pht('Communication'),
|
||||
'fa-truck' => pht('Release'),
|
||||
'fa-lock' => pht('Policy'),
|
||||
'fa-umbrella' => pht('An Umbrella'),
|
||||
|
||||
'fa-cloud' => pht('The Cloud'),
|
||||
'fa-building' => pht('Company'),
|
||||
'fa-credit-card' => pht('Accounting'),
|
||||
'fa-flask' => pht('Experimental'),
|
||||
);
|
||||
|
||||
$icons = array();
|
||||
foreach ($map as $key => $label) {
|
||||
$icons[] = id(new PhabricatorIconSetIcon())
|
||||
->setKey($key)
|
||||
->setLabel($label);
|
||||
}
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
public static function getColorMap() {
|
||||
$shades = PHUITagView::getShadeMap();
|
||||
$shades = array_select_keys(
|
||||
$shades,
|
||||
array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
|
||||
unset($shades[PHUITagView::COLOR_DISABLED]);
|
||||
|
||||
return $shades;
|
||||
}
|
||||
|
||||
}
|
|
@ -128,12 +128,13 @@ protected function buildQueryFromParameters(array $map) {
|
|||
private function getIconOptions() {
|
||||
$options = array();
|
||||
|
||||
foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) {
|
||||
$options[$icon] = array(
|
||||
$set = new PhabricatorProjectIconSet();
|
||||
foreach ($set->getIcons() as $icon) {
|
||||
$options[$icon->getKey()] = array(
|
||||
id(new PHUIIconView())
|
||||
->setIconFont($icon),
|
||||
->setIconFont($icon->getIcon()),
|
||||
' ',
|
||||
$name,
|
||||
$icon->getLabel(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -143,7 +144,7 @@ protected function buildQueryFromParameters(array $map) {
|
|||
private function getColorOptions() {
|
||||
$options = array();
|
||||
|
||||
foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) {
|
||||
foreach (PhabricatorProjectIconSet::getColorMap() as $color => $name) {
|
||||
$options[$color] = array(
|
||||
id(new PHUITagView())
|
||||
->setType(PHUITagView::TYPE_SHADE)
|
||||
|
|
|
@ -147,10 +147,12 @@ final class PhabricatorProjectTransaction
|
|||
break;
|
||||
|
||||
case self::TYPE_ICON:
|
||||
$set = new PhabricatorProjectIconSet();
|
||||
|
||||
return pht(
|
||||
"%s set this project's icon to %s.",
|
||||
$author_handle,
|
||||
PhabricatorProjectIcon::getLabel($new));
|
||||
$set->getIconLabel($new));
|
||||
break;
|
||||
|
||||
case self::TYPE_COLOR:
|
||||
|
@ -301,11 +303,13 @@ final class PhabricatorProjectTransaction
|
|||
}
|
||||
|
||||
case self::TYPE_ICON:
|
||||
$set = new PhabricatorProjectIconSet();
|
||||
|
||||
return pht(
|
||||
'%s set the icon for %s to %s.',
|
||||
$author_handle,
|
||||
$object_handle,
|
||||
PhabricatorProjectIcon::getLabel($new));
|
||||
$set->getIconLabel($new));
|
||||
|
||||
case self::TYPE_COLOR:
|
||||
return pht(
|
||||
|
|
|
@ -1,62 +1,59 @@
|
|||
<?php
|
||||
|
||||
final class AphrontFormChooseButtonControl extends AphrontFormControl {
|
||||
final class PHUIFormIconSetControl
|
||||
extends AphrontFormControl {
|
||||
|
||||
private $displayValue;
|
||||
private $buttonText;
|
||||
private $chooseURI;
|
||||
private $iconSet;
|
||||
|
||||
public function setDisplayValue($display_value) {
|
||||
$this->displayValue = $display_value;
|
||||
public function setIconSet(PhabricatorIconSet $icon_set) {
|
||||
$this->iconSet = $icon_set;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisplayValue() {
|
||||
return $this->displayValue;
|
||||
}
|
||||
|
||||
public function setButtonText($text) {
|
||||
$this->buttonText = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setChooseURI($choose_uri) {
|
||||
$this->chooseURI = $choose_uri;
|
||||
return $this;
|
||||
public function getIconSet() {
|
||||
return $this->iconSet;
|
||||
}
|
||||
|
||||
protected function getCustomControlClass() {
|
||||
return 'aphront-form-control-choose-button';
|
||||
return 'phui-form-iconset-control';
|
||||
}
|
||||
|
||||
protected function renderInput() {
|
||||
Javelin::initBehavior('choose-control');
|
||||
|
||||
$set = $this->getIconSet();
|
||||
|
||||
$input_id = celerity_generate_unique_node_id();
|
||||
$display_id = celerity_generate_unique_node_id();
|
||||
|
||||
$display_value = $this->displayValue;
|
||||
$button = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#',
|
||||
'class' => 'button grey',
|
||||
'sigil' => 'aphront-form-choose-button',
|
||||
'sigil' => 'phui-form-iconset-button',
|
||||
),
|
||||
nonempty($this->buttonText, pht('Choose...')));
|
||||
$set->getChooseButtonText());
|
||||
|
||||
$icon = $set->getIcon($this->getValue());
|
||||
if ($icon) {
|
||||
$display = $set->renderIconForControl($icon);
|
||||
} else {
|
||||
$display = null;
|
||||
}
|
||||
|
||||
$display_cell = phutil_tag(
|
||||
'td',
|
||||
array(
|
||||
'class' => 'aphront-form-choose-display-cell',
|
||||
'class' => 'phui-form-iconset-display-cell',
|
||||
'id' => $display_id,
|
||||
),
|
||||
$display_value);
|
||||
$display);
|
||||
|
||||
$button_cell = phutil_tag(
|
||||
'td',
|
||||
array(
|
||||
'class' => 'aphront-form-choose-button-cell',
|
||||
'class' => 'phui-form-iconset-button-cell',
|
||||
),
|
||||
$button);
|
||||
|
||||
|
@ -68,10 +65,10 @@ final class AphrontFormChooseButtonControl extends AphrontFormControl {
|
|||
$layout = javelin_tag(
|
||||
'table',
|
||||
array(
|
||||
'class' => 'aphront-form-choose-table',
|
||||
'sigil' => 'aphront-form-choose',
|
||||
'class' => 'phui-form-iconset-table',
|
||||
'sigil' => 'phui-form-iconset',
|
||||
'meta' => array(
|
||||
'uri' => $this->chooseURI,
|
||||
'uri' => $set->getSelectURI(),
|
||||
'inputID' => $input_id,
|
||||
'displayID' => $display_id,
|
||||
),
|
|
@ -519,12 +519,12 @@ properly, and submit values. */
|
|||
width: 180px;
|
||||
}
|
||||
|
||||
.aphront-form-choose-table td {
|
||||
.phui-form-iconset-table td {
|
||||
vertical-align: middle;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.aphront-form-choose-table .aphront-form-choose-button-cell {
|
||||
.phui-form-iconset-table .phui-form-iconset-button-cell {
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ JX.behavior('choose-control', function() {
|
|||
|
||||
JX.Stratcom.listen(
|
||||
'click',
|
||||
'aphront-form-choose-button',
|
||||
'phui-form-iconset-button',
|
||||
function(e) {
|
||||
e.kill();
|
||||
|
||||
var data = e.getNodeData('aphront-form-choose');
|
||||
var data = e.getNodeData('phui-form-iconset');
|
||||
|
||||
var params = {
|
||||
value: JX.$(data.inputID).value
|
||||
|
|
Loading…
Reference in a new issue