From a78b02e193853bd72280dfbe7e0b969a6ee9ce3b Mon Sep 17 00:00:00 2001 From: Afaque Hussain Date: Tue, 9 Apr 2013 09:43:41 -0700 Subject: [PATCH] Placed Radio buttons for Home Page Preferences Settings Summary: Replaced AphrontFormSelectControl in PhabricatorSettingsPanelHomePreferences with AphrontFormRadioButtonControl :). Test Plan: By checking out Home page prefreces setting and playing around the values to see if it works ! Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin, chad, demo, AnhNhan Maniphest Tasks: T2340 Differential Revision: https://secure.phabricator.com/D5414 --- src/__celerity_resource_map__.php | 9 + ...habricatorSettingsPanelHomePreferences.php | 157 +++++++++++++++--- .../css/application/settings/settings.css | 20 +++ 3 files changed, 160 insertions(+), 26 deletions(-) create mode 100644 webroot/rsrc/css/application/settings/settings.css diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 8b39b81a07..e43a9fd3a4 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -3271,6 +3271,15 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/css/application/search/search-results.css', ), + 'phabricator-settings-css' => + array( + 'uri' => '/res/fb9d017f/rsrc/css/application/settings/settings.css', + 'type' => 'css', + 'requires' => + array( + ), + 'disk' => '/rsrc/css/application/settings/settings.css', + ), 'phabricator-shaped-request' => array( 'uri' => '/res/fbdb92db/rsrc/js/application/core/ShapedRequest.js', diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php b/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php index 7bc95340d8..bce927a3b7 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php @@ -19,6 +19,8 @@ final class PhabricatorSettingsPanelHomePreferences $user = $request->getUser(); $preferences = $user->loadPreferences(); + require_celerity_resource('phabricator-settings-css'); + $apps = PhabricatorApplication::getAllInstalledApplications(); $pref_tiles = PhabricatorUserPreferences::PREFERENCE_APP_TILES; $tiles = $preferences->getPreference($pref_tiles, array()); @@ -53,40 +55,143 @@ final class PhabricatorSettingsPanelHomePreferences ->setFlexible(true) ->setUser($user); - $apps = msort($apps, 'getName'); - foreach ($apps as $app) { - if (!$app->shouldAppearInLaunchView()) { + $group_map = PhabricatorApplication::getApplicationGroups(); + + $output = array(); + + $applications = PhabricatorApplication::getAllInstalledApplications(); + + $applications = mgroup($applications, 'getApplicationGroup'); + + $applications = array_select_keys( + $applications, + array_keys($group_map)); + + foreach ($applications as $group => $apps) { + $group_name = $group_map[$group]; + $rows = array(); + + foreach ($apps as $app) { + if (!$app->shouldAppearInLaunchView()) { + continue; + } + + $default = $app->getDefaultTileDisplay($user); + if ($default == PhabricatorApplication::TILE_INVISIBLE) { + continue; + } + + + + $default_name = PhabricatorApplication::getTileDisplayName($default); + + $hide = PhabricatorApplication::TILE_HIDE; + $show = PhabricatorApplication::TILE_SHOW; + $full = PhabricatorApplication::TILE_FULL; + + $key = get_class($app); + + $default_radio_button_status = + (idx($tiles, $key, 'default') == 'default') ? 'checked' : null; + + $hide_radio_button_status = + (idx($tiles, $key, 'default') == $hide) ? 'checked' : null; + + $show_radio_button_status = + (idx($tiles, $key, 'default') == $show) ? 'checked' : null; + + $full_radio_button_status = + (idx($tiles, $key, 'default') == $full) ? 'checked' : null; + + + $default_radio_button = phutil_tag( + 'input', + array( + 'type' => 'radio', + 'name' => 'tile['.$key.']', + 'value' => 'default', + 'checked' => $default_radio_button_status, + )); + + $hide_radio_button = phutil_tag( + 'input', + array( + 'type' => 'radio', + 'name' => 'tile['.$key.']', + 'value' => $hide, + 'checked' => $hide_radio_button_status, + )); + + $show_radio_button = phutil_tag( + 'input', + array( + 'type' => 'radio', + 'name' => 'tile['.$key.']', + 'value' => $show, + 'checked' => $show_radio_button_status, + )); + + $full_radio_button = phutil_tag( + 'input', + array( + 'type' => 'radio', + 'name' => 'tile['.$key.']', + 'value' => $full, + 'checked' => $full_radio_button_status, + )); + + $app_column = hsprintf( + "%s
Default: %s" + , $app->getName(), $default_name); + + $rows[] = array( + $app_column, + $default_radio_button, + $hide_radio_button, + $show_radio_button, + $full_radio_button, + ); + } + + if (empty($rows)) { continue; } - $default = $app->getDefaultTileDisplay($user); - if ($default == PhabricatorApplication::TILE_INVISIBLE) { - continue; - } + $table = new AphrontTableView($rows); - $default_name = PhabricatorApplication::getTileDisplayName($default); - - $hide = PhabricatorApplication::TILE_HIDE; - $show = PhabricatorApplication::TILE_SHOW; - $full = PhabricatorApplication::TILE_FULL; - - $key = get_class($app); - // Won't pht() for dynamic string (Applcation Name) - $form->appendChild( - id(new AphrontFormSelectControl()) - ->setLabel($app->getName()) - ->setName('tile['.$key.']') - ->setOptions( - array( - $hide => PhabricatorApplication::getTileDisplayName($hide), - 'default' => pht('Use Default (%s)', $default_name), - $show => PhabricatorApplication::getTileDisplayName($show), - $full => PhabricatorApplication::getTileDisplayName($full), + $table + ->setClassName('phabricator-settings-homepagetable') + ->setHeaders( + array( + pht('Applications'), + pht('Default'), + pht('Hidden'), + pht('Small'), + pht('Large'), )) - ->setValue(idx($tiles, $key, 'default'))); + ->setColumnClasses( + array( + '', + 'fixed', + 'fixed', + 'fixed', + 'fixed', + )); + + + $panel = id(new AphrontPanelView()) + ->setHeader($group_name) + ->addClass('phabricator-settings-panelview') + ->appendChild($table) + ->setNoBackground(); + + + $output[] = $panel; + } $form + ->appendChild($output) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Save Preferences'))); diff --git a/webroot/rsrc/css/application/settings/settings.css b/webroot/rsrc/css/application/settings/settings.css new file mode 100644 index 0000000000..6f71309826 --- /dev/null +++ b/webroot/rsrc/css/application/settings/settings.css @@ -0,0 +1,20 @@ +/** + * @provides phabricator-settings-css + */ + +.phabricator-settings-homepagetable { + width: 60% !important; + margin: auto; +} + +.phabricator-settings-homepagetable td.fixed { + width: 24px; + text-align: center; + +} + +.phabricator-settings-panelview h1 { + text-align: center; +} + +