1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

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
This commit is contained in:
Afaque Hussain 2013-04-09 09:43:41 -07:00 committed by epriestley
parent c621da8e97
commit a78b02e193
3 changed files with 160 additions and 26 deletions

View file

@ -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',

View file

@ -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(
"<strong>%s</strong><br /><em> Default: %s</em>"
, $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')));

View file

@ -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;
}