1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Modernize Countdown

Summary: Crumbs, phts, and mobile layouts for Countdown.

Test Plan: Tested new, edit and delete timer. Verified timer works. Unable to get 'remove chrome' to work, will investigate.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5101
This commit is contained in:
Chad Little 2013-02-25 12:48:55 -08:00
parent 1f00f2728b
commit 7ab7783ad3
7 changed files with 103 additions and 52 deletions

View file

@ -170,6 +170,8 @@ abstract class PhabricatorController extends AphrontController {
$page->setDeviceReady(true);
}
$page->setShowChrome(idx($options, 'chrome', true));
$application_menu = $this->buildApplicationMenu();
if ($application_menu) {
$page->setApplicationMenu($application_menu);

View file

@ -11,7 +11,7 @@ final class PhabricatorApplicationCountdown extends PhabricatorApplication {
}
public function getShortDescription() {
return 'Countdown Timers';
return pht('Countdown Timers');
}
public function getTitleGlyph() {

View file

@ -2,20 +2,33 @@
abstract class PhabricatorCountdownController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
public function buildSideNavView() {
$user = $this->getRequest()->getUser();
$page = $this->buildStandardPageView();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$page->setApplicationName('Countdown');
$page->setBaseURI('/countdown/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9A\xB2");
$page->setShowChrome(idx($data, 'chrome', true));
$nav->addFilter('', pht('All Timers'),
$this->getApplicationURI(''));
$nav->addFilter('', pht('Create Timer'),
$this->getApplicationURI('edit/'));
$page->appendChild($view);
return $nav;
}
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
public function buildApplicationMenu() {
return $this->buildSideNavView()->getMenu();
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setName(pht('Create Timer'))
->setHref($this->getApplicationURI('edit/'))
->setIcon('create'));
return $crumbs;
}
}

View file

@ -30,13 +30,14 @@ final class PhabricatorCountdownDeleteController
->setURI('/countdown/');
}
$inst = pht('Are you sure you want to delete the countdown %s?',
$timer->getTitle());
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Really delete this countdown?');
$dialog->appendChild(hsprintf(
'<p>Are you sure you want to delete the countdown "%s"?</p>',
$timer->getTitle()));
$dialog->addSubmitButton('Delete');
$dialog->setTitle(pht('Really delete this countdown?'));
$dialog->appendChild(hsprintf('<p>%s</p>', $inst));
$dialog->addSubmitButton(pht('Delete'));
$dialog->addCancelButton('/countdown/');
$dialog->setSubmitURI($request->getPath());

View file

@ -12,7 +12,7 @@ final class PhabricatorCountdownEditController
$request = $this->getRequest();
$user = $request->getUser();
$action_label = 'Create Timer';
$action_label = pht('Create Timer');
if ($this->id) {
$timer = id(new PhabricatorTimer())->load($this->id);
@ -26,7 +26,7 @@ final class PhabricatorCountdownEditController
return new Aphront403Response();
}
$action_label = 'Update Timer';
$action_label = pht('Update Timer');
} else {
$timer = new PhabricatorTimer();
$timer->setDatePoint(time());
@ -42,8 +42,8 @@ final class PhabricatorCountdownEditController
$e_text = null;
if (!strlen($title)) {
$e_text = 'Required';
$errors[] = 'You must give it a name.';
$e_text = pht('Required');
$errors[] = pht('You must give it a name.');
}
// If the user types something like "5 PM", convert it to a timestamp
@ -54,9 +54,9 @@ final class PhabricatorCountdownEditController
$date = new DateTime($datepoint, $timezone);
$timestamp = $date->format('U');
} catch (Exception $e) {
$errors[] = 'You entered an incorrect date. You can enter date like'.
' \'2011-06-26 13:33:37\' to create an event at'.
' 13:33:37 on the 26th of June 2011.';
$errors[] = pht('You entered an incorrect date. You can enter date'.
' like \'2011-06-26 13:33:37\' to create an event at'.
' 13:33:37 on the 26th of June 2011.');
$timestamp = null;
}
@ -71,8 +71,8 @@ final class PhabricatorCountdownEditController
} else {
$error_view = id(new AphrontErrorView())
->setErrors($errors)
->setTitle('It\'s not The Final Countdown (du nu nuuu nun)' .
' until you fix these problem');
->setTitle(pht('It\'s not The Final Countdown (du nu nuuu nun)' .
' until you fix these problem'));
}
}
@ -89,19 +89,17 @@ final class PhabricatorCountdownEditController
->setAction($request->getRequestURI()->getPath())
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Title')
->setLabel(pht('Title'))
->setValue($timer->getTitle())
->setName('title'))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('End date')
->setLabel(pht('End date'))
->setValue($display_datepoint)
->setName('datepoint')
->setCaption(hsprintf(
'Examples: '.
'<tt>2011-12-25</tt> or '.
'<tt>3 hours</tt> or '.
'<tt>June 8 2011, 5 PM</tt>.')))
->setCaption(pht('Examples: '.
'2011-12-25 or 3 hours or '.
'June 8 2011, 5 PM.')))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/countdown/')
@ -110,15 +108,25 @@ final class PhabricatorCountdownEditController
$panel = id(new AphrontPanelView())
->setWidth(AphrontPanelView::WIDTH_FORM)
->setHeader($action_label)
->setNoBackground()
->appendChild($form);
return $this->buildStandardPageResponse(
$crumbs = $this
->buildApplicationCrumbs()
->addCrumb(
id(new PhabricatorCrumbView())
->setName($action_label)
->setHref($this->getApplicationURI('edit/')));
return $this->buildApplicationPage(
array(
$crumbs,
$error_view,
$panel,
),
array(
'title' => 'Edit Countdown',
'title' => pht('Edit Countdown'),
'device' => true,
));
}
}

View file

@ -34,7 +34,7 @@ final class PhabricatorCountdownListController
'class' => 'small button grey',
'href' => '/countdown/edit/'.$timer->getID().'/'
),
'Edit');
pht('Edit'));
$delete_button = javelin_tag(
'a',
@ -43,7 +43,7 @@ final class PhabricatorCountdownListController
'href' => '/countdown/delete/'.$timer->getID().'/',
'sigil' => 'workflow'
),
'Delete');
pht('Delete'));
}
$rows[] = array(
$timer->getID(),
@ -63,10 +63,10 @@ final class PhabricatorCountdownListController
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'ID',
'Author',
'Title',
'End Date',
pht('ID'),
pht('Author'),
pht('Title'),
pht('End Date'),
'',
''
));
@ -83,13 +83,25 @@ final class PhabricatorCountdownListController
$panel = id(new AphrontPanelView())
->appendChild($table)
->setHeader('Timers')
->setCreateButton('Create Timer', '/countdown/edit/')
->setHeader(pht('Timers'))
->setNoBackground()
->appendChild($pager);
return $this->buildStandardPageResponse($panel,
$crumbs = $this
->buildApplicationCrumbs()
->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('All Timers'))
->setHref($this->getApplicationURI()));
return $this->buildApplicationPage(
array(
'title' => 'Countdown',
$crumbs,
$panel
),
array(
'title' => pht('Countdown'),
'device' => true,
));
}
}

View file

@ -38,10 +38,10 @@ final class PhabricatorCountdownViewController
<div class="phabricator-timer-pane">
<table class="phabricator-timer-table">
<tr>
<th>Days</th>
<th>Hours</th>
<th>Minutes</th>
<th>Seconds</th>
<th>%s</th>
<th>%s</th>
<th>%s</th>
<th>%s</th>
</tr>
<tr>%s%s%s%s</tr>
</table>
@ -51,6 +51,10 @@ final class PhabricatorCountdownViewController
$container,
$timer->getTitle(),
phabricator_datetime($timer->getDatePoint(), $user),
pht('Days'),
pht('Hours'),
pht('Minutes'),
pht('Seconds'),
javelin_tag('td', array('sigil' => 'phabricator-timer-days'), ''),
javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), ''),
javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), ''),
@ -64,11 +68,22 @@ final class PhabricatorCountdownViewController
$panel = $content;
return $this->buildStandardPageResponse(
$panel,
$crumbs = $this
->buildApplicationCrumbs()
->addCrumb(
id(new PhabricatorCrumbView())
->setName($timer->getTitle())
->setHref($this->getApplicationURI($this->id.'/')));
return $this->buildApplicationPage(
array(
'title' => 'Countdown: '.$timer->getTitle(),
'chrome' => $chrome_visible
($chrome_visible ? $crumbs : ''),
$panel,
),
array(
'title' => pht('Countdown: %s', $timer->getTitle()),
'chrome' => $chrome_visible,
'device' => true,
));
}