mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 09:20:58 +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:
parent
1f00f2728b
commit
7ab7783ad3
7 changed files with 103 additions and 52 deletions
|
@ -170,6 +170,8 @@ abstract class PhabricatorController extends AphrontController {
|
||||||
$page->setDeviceReady(true);
|
$page->setDeviceReady(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$page->setShowChrome(idx($options, 'chrome', true));
|
||||||
|
|
||||||
$application_menu = $this->buildApplicationMenu();
|
$application_menu = $this->buildApplicationMenu();
|
||||||
if ($application_menu) {
|
if ($application_menu) {
|
||||||
$page->setApplicationMenu($application_menu);
|
$page->setApplicationMenu($application_menu);
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class PhabricatorApplicationCountdown extends PhabricatorApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShortDescription() {
|
public function getShortDescription() {
|
||||||
return 'Countdown Timers';
|
return pht('Countdown Timers');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitleGlyph() {
|
public function getTitleGlyph() {
|
||||||
|
|
|
@ -2,20 +2,33 @@
|
||||||
|
|
||||||
abstract class PhabricatorCountdownController extends PhabricatorController {
|
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');
|
$nav->addFilter('', pht('All Timers'),
|
||||||
$page->setBaseURI('/countdown/');
|
$this->getApplicationURI(''));
|
||||||
$page->setTitle(idx($data, 'title'));
|
$nav->addFilter('', pht('Create Timer'),
|
||||||
$page->setGlyph("\xE2\x9A\xB2");
|
$this->getApplicationURI('edit/'));
|
||||||
$page->setShowChrome(idx($data, 'chrome', true));
|
|
||||||
|
|
||||||
$page->appendChild($view);
|
return $nav;
|
||||||
|
}
|
||||||
|
|
||||||
$response = new AphrontWebpageResponse();
|
public function buildApplicationMenu() {
|
||||||
return $response->setContent($page->render());
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,14 @@ final class PhabricatorCountdownDeleteController
|
||||||
->setURI('/countdown/');
|
->setURI('/countdown/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$inst = pht('Are you sure you want to delete the countdown %s?',
|
||||||
|
$timer->getTitle());
|
||||||
|
|
||||||
$dialog = new AphrontDialogView();
|
$dialog = new AphrontDialogView();
|
||||||
$dialog->setUser($request->getUser());
|
$dialog->setUser($request->getUser());
|
||||||
$dialog->setTitle('Really delete this countdown?');
|
$dialog->setTitle(pht('Really delete this countdown?'));
|
||||||
$dialog->appendChild(hsprintf(
|
$dialog->appendChild(hsprintf('<p>%s</p>', $inst));
|
||||||
'<p>Are you sure you want to delete the countdown "%s"?</p>',
|
$dialog->addSubmitButton(pht('Delete'));
|
||||||
$timer->getTitle()));
|
|
||||||
$dialog->addSubmitButton('Delete');
|
|
||||||
$dialog->addCancelButton('/countdown/');
|
$dialog->addCancelButton('/countdown/');
|
||||||
$dialog->setSubmitURI($request->getPath());
|
$dialog->setSubmitURI($request->getPath());
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class PhabricatorCountdownEditController
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
$action_label = 'Create Timer';
|
$action_label = pht('Create Timer');
|
||||||
|
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
$timer = id(new PhabricatorTimer())->load($this->id);
|
$timer = id(new PhabricatorTimer())->load($this->id);
|
||||||
|
@ -26,7 +26,7 @@ final class PhabricatorCountdownEditController
|
||||||
return new Aphront403Response();
|
return new Aphront403Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$action_label = 'Update Timer';
|
$action_label = pht('Update Timer');
|
||||||
} else {
|
} else {
|
||||||
$timer = new PhabricatorTimer();
|
$timer = new PhabricatorTimer();
|
||||||
$timer->setDatePoint(time());
|
$timer->setDatePoint(time());
|
||||||
|
@ -42,8 +42,8 @@ final class PhabricatorCountdownEditController
|
||||||
|
|
||||||
$e_text = null;
|
$e_text = null;
|
||||||
if (!strlen($title)) {
|
if (!strlen($title)) {
|
||||||
$e_text = 'Required';
|
$e_text = pht('Required');
|
||||||
$errors[] = 'You must give it a name.';
|
$errors[] = pht('You must give it a name.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user types something like "5 PM", convert it to a timestamp
|
// 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);
|
$date = new DateTime($datepoint, $timezone);
|
||||||
$timestamp = $date->format('U');
|
$timestamp = $date->format('U');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$errors[] = 'You entered an incorrect date. You can enter date like'.
|
$errors[] = pht('You entered an incorrect date. You can enter date'.
|
||||||
' \'2011-06-26 13:33:37\' to create an event at'.
|
' like \'2011-06-26 13:33:37\' to create an event at'.
|
||||||
' 13:33:37 on the 26th of June 2011.';
|
' 13:33:37 on the 26th of June 2011.');
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ final class PhabricatorCountdownEditController
|
||||||
} else {
|
} else {
|
||||||
$error_view = id(new AphrontErrorView())
|
$error_view = id(new AphrontErrorView())
|
||||||
->setErrors($errors)
|
->setErrors($errors)
|
||||||
->setTitle('It\'s not The Final Countdown (du nu nuuu nun)' .
|
->setTitle(pht('It\'s not The Final Countdown (du nu nuuu nun)' .
|
||||||
' until you fix these problem');
|
' until you fix these problem'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,19 +89,17 @@ final class PhabricatorCountdownEditController
|
||||||
->setAction($request->getRequestURI()->getPath())
|
->setAction($request->getRequestURI()->getPath())
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel('Title')
|
->setLabel(pht('Title'))
|
||||||
->setValue($timer->getTitle())
|
->setValue($timer->getTitle())
|
||||||
->setName('title'))
|
->setName('title'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel('End date')
|
->setLabel(pht('End date'))
|
||||||
->setValue($display_datepoint)
|
->setValue($display_datepoint)
|
||||||
->setName('datepoint')
|
->setName('datepoint')
|
||||||
->setCaption(hsprintf(
|
->setCaption(pht('Examples: '.
|
||||||
'Examples: '.
|
'2011-12-25 or 3 hours or '.
|
||||||
'<tt>2011-12-25</tt> or '.
|
'June 8 2011, 5 PM.')))
|
||||||
'<tt>3 hours</tt> or '.
|
|
||||||
'<tt>June 8 2011, 5 PM</tt>.')))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->addCancelButton('/countdown/')
|
->addCancelButton('/countdown/')
|
||||||
|
@ -110,15 +108,25 @@ final class PhabricatorCountdownEditController
|
||||||
$panel = id(new AphrontPanelView())
|
$panel = id(new AphrontPanelView())
|
||||||
->setWidth(AphrontPanelView::WIDTH_FORM)
|
->setWidth(AphrontPanelView::WIDTH_FORM)
|
||||||
->setHeader($action_label)
|
->setHeader($action_label)
|
||||||
|
->setNoBackground()
|
||||||
->appendChild($form);
|
->appendChild($form);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
$crumbs = $this
|
||||||
|
->buildApplicationCrumbs()
|
||||||
|
->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName($action_label)
|
||||||
|
->setHref($this->getApplicationURI('edit/')));
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
|
$crumbs,
|
||||||
$error_view,
|
$error_view,
|
||||||
$panel,
|
$panel,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => 'Edit Countdown',
|
'title' => pht('Edit Countdown'),
|
||||||
|
'device' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class PhabricatorCountdownListController
|
||||||
'class' => 'small button grey',
|
'class' => 'small button grey',
|
||||||
'href' => '/countdown/edit/'.$timer->getID().'/'
|
'href' => '/countdown/edit/'.$timer->getID().'/'
|
||||||
),
|
),
|
||||||
'Edit');
|
pht('Edit'));
|
||||||
|
|
||||||
$delete_button = javelin_tag(
|
$delete_button = javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
|
@ -43,7 +43,7 @@ final class PhabricatorCountdownListController
|
||||||
'href' => '/countdown/delete/'.$timer->getID().'/',
|
'href' => '/countdown/delete/'.$timer->getID().'/',
|
||||||
'sigil' => 'workflow'
|
'sigil' => 'workflow'
|
||||||
),
|
),
|
||||||
'Delete');
|
pht('Delete'));
|
||||||
}
|
}
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$timer->getID(),
|
$timer->getID(),
|
||||||
|
@ -63,10 +63,10 @@ final class PhabricatorCountdownListController
|
||||||
$table = new AphrontTableView($rows);
|
$table = new AphrontTableView($rows);
|
||||||
$table->setHeaders(
|
$table->setHeaders(
|
||||||
array(
|
array(
|
||||||
'ID',
|
pht('ID'),
|
||||||
'Author',
|
pht('Author'),
|
||||||
'Title',
|
pht('Title'),
|
||||||
'End Date',
|
pht('End Date'),
|
||||||
'',
|
'',
|
||||||
''
|
''
|
||||||
));
|
));
|
||||||
|
@ -83,13 +83,25 @@ final class PhabricatorCountdownListController
|
||||||
|
|
||||||
$panel = id(new AphrontPanelView())
|
$panel = id(new AphrontPanelView())
|
||||||
->appendChild($table)
|
->appendChild($table)
|
||||||
->setHeader('Timers')
|
->setHeader(pht('Timers'))
|
||||||
->setCreateButton('Create Timer', '/countdown/edit/')
|
->setNoBackground()
|
||||||
->appendChild($pager);
|
->appendChild($pager);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse($panel,
|
$crumbs = $this
|
||||||
|
->buildApplicationCrumbs()
|
||||||
|
->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName(pht('All Timers'))
|
||||||
|
->setHref($this->getApplicationURI()));
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
'title' => 'Countdown',
|
$crumbs,
|
||||||
|
$panel
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => pht('Countdown'),
|
||||||
|
'device' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ final class PhabricatorCountdownViewController
|
||||||
<div class="phabricator-timer-pane">
|
<div class="phabricator-timer-pane">
|
||||||
<table class="phabricator-timer-table">
|
<table class="phabricator-timer-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Days</th>
|
<th>%s</th>
|
||||||
<th>Hours</th>
|
<th>%s</th>
|
||||||
<th>Minutes</th>
|
<th>%s</th>
|
||||||
<th>Seconds</th>
|
<th>%s</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>%s%s%s%s</tr>
|
<tr>%s%s%s%s</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -51,6 +51,10 @@ final class PhabricatorCountdownViewController
|
||||||
$container,
|
$container,
|
||||||
$timer->getTitle(),
|
$timer->getTitle(),
|
||||||
phabricator_datetime($timer->getDatePoint(), $user),
|
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-days'), ''),
|
||||||
javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), ''),
|
javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), ''),
|
||||||
javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), ''),
|
javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), ''),
|
||||||
|
@ -64,11 +68,22 @@ final class PhabricatorCountdownViewController
|
||||||
|
|
||||||
$panel = $content;
|
$panel = $content;
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
$crumbs = $this
|
||||||
$panel,
|
->buildApplicationCrumbs()
|
||||||
|
->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName($timer->getTitle())
|
||||||
|
->setHref($this->getApplicationURI($this->id.'/')));
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
'title' => 'Countdown: '.$timer->getTitle(),
|
($chrome_visible ? $crumbs : ''),
|
||||||
'chrome' => $chrome_visible
|
$panel,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => pht('Countdown: %s', $timer->getTitle()),
|
||||||
|
'chrome' => $chrome_visible,
|
||||||
|
'device' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue