Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13962650
D12731.id30591.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D12731.id30591.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1906,7 +1906,6 @@
'PhabricatorFlaggableInterface' => 'applications/flag/interface/PhabricatorFlaggableInterface.php',
'PhabricatorFlagsApplication' => 'applications/flag/application/PhabricatorFlagsApplication.php',
'PhabricatorFlagsUIEventListener' => 'applications/flag/events/PhabricatorFlagsUIEventListener.php',
- 'PhabricatorFormUIExample' => 'applications/uiexample/examples/PhabricatorFormUIExample.php',
'PhabricatorFundApplication' => 'applications/fund/application/PhabricatorFundApplication.php',
'PhabricatorGDSetupCheck' => 'applications/config/check/PhabricatorGDSetupCheck.php',
'PhabricatorGarbageCollector' => 'infrastructure/daemon/garbagecollector/PhabricatorGarbageCollector.php',
@@ -5311,7 +5310,6 @@
'PhabricatorFlaggableInterface' => 'PhabricatorPHIDInterface',
'PhabricatorFlagsApplication' => 'PhabricatorApplication',
'PhabricatorFlagsUIEventListener' => 'PhabricatorEventListener',
- 'PhabricatorFormUIExample' => 'PhabricatorUIExample',
'PhabricatorFundApplication' => 'PhabricatorApplication',
'PhabricatorGDSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorGarbageCollector' => 'Phobject',
diff --git a/src/applications/countdown/controller/PhabricatorCountdownEditController.php b/src/applications/countdown/controller/PhabricatorCountdownEditController.php
--- a/src/applications/countdown/controller/PhabricatorCountdownEditController.php
+++ b/src/applications/countdown/controller/PhabricatorCountdownEditController.php
@@ -12,11 +12,6 @@
$request = $this->getRequest();
$user = $request->getUser();
- $epoch_control = id(new AphrontFormDateControl())
- ->setUser($user)
- ->setName('epoch')
- ->setLabel(pht('End Date'))
- ->setInitialTime(AphrontFormDateControl::TIME_END_OF_DAY);
if ($this->id) {
$page_title = pht('Edit Countdown');
@@ -32,31 +27,41 @@
if (!$countdown) {
return new Aphront404Response();
}
+ $date_value = AphrontFormDateControlValue::newFromEpoch(
+ $user,
+ $countdown->getEpoch());
} else {
$page_title = pht('Create Countdown');
$countdown = PhabricatorCountdown::initializeNewCountdown($user);
+ $date_value = AphrontFormDateControlValue::newFromEpoch($user, time());
}
- $epoch_control->setValue($countdown->getEpoch());
- $e_text = true;
$errors = array();
+ $e_text = true;
+ $e_epoch = null;
+
+ $v_text = $countdown->getTitle();
+
if ($request->isFormPost()) {
- $title = $request->getStr('title');
- $epoch = $epoch_control->readValueFromRequest($request);
+ $v_text = $request->getStr('title');
+ $date_value = AphrontFormDateControlValue::newFromRequest(
+ $request,
+ 'epoch');
$view_policy = $request->getStr('viewPolicy');
$e_text = null;
- if (!strlen($title)) {
+ if (!strlen($v_text)) {
$e_text = pht('Required');
$errors[] = pht('You must give the countdown a name.');
}
- if (!$epoch) {
+ if (!$date_value->isValid()) {
+ $e_epoch = pht('Invalid');
$errors[] = pht('You must give the countdown a valid end date.');
}
if (!count($errors)) {
- $countdown->setTitle($title);
- $countdown->setEpoch($epoch);
+ $countdown->setTitle($v_text);
+ $countdown->setEpoch($date_value->getEpoch());
$countdown->setViewPolicy($view_policy);
$countdown->save();
return id(new AphrontRedirectResponse())
@@ -64,12 +69,6 @@
}
}
- if ($countdown->getEpoch()) {
- $display_epoch = phabricator_datetime($countdown->getEpoch(), $user);
- } else {
- $display_epoch = $request->getStr('epoch');
- }
-
$crumbs = $this->buildApplicationCrumbs();
$cancel_uri = '/countdown/';
@@ -94,10 +93,16 @@
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Title'))
- ->setValue($countdown->getTitle())
+ ->setValue($v_text)
->setName('title')
->setError($e_text))
- ->appendChild($epoch_control)
+ ->appendChild(
+ id(new AphrontFormDateControl())
+ ->setUser($user)
+ ->setName('epoch')
+ ->setLabel(pht('End Date'))
+ ->setError($e_epoch)
+ ->setValue($date_value))
->appendChild(
id(new AphrontFormPolicyControl())
->setUser($user)
diff --git a/src/applications/phrequent/controller/PhrequentTrackController.php b/src/applications/phrequent/controller/PhrequentTrackController.php
--- a/src/applications/phrequent/controller/PhrequentTrackController.php
+++ b/src/applications/phrequent/controller/PhrequentTrackController.php
@@ -62,22 +62,22 @@
$v_note = null;
$e_date = null;
- $epoch_control = id(new AphrontFormDateControl())
- ->setUser($viewer)
- ->setName('epoch')
- ->setLabel($action_text)
- ->setValue(time());
+ $timestamp = AphrontFormDateControlValue::newFromEpoch(
+ $viewer,
+ time());
if ($request->isDialogFormPost()) {
$v_note = $request->getStr('note');
- $timestamp = $epoch_control->readValueFromRequest($request);
+ $timestamp = AphrontFormDateControlValue::newFromRequest(
+ $request,
+ 'epoch');
- if (!$epoch_control->isValid()) {
- $errors[] = pht('Please choose an valid date.');
+ if (!$timestamp->isValid()) {
+ $errors[] = pht('Please choose a valid date.');
$e_date = pht('Invalid');
} else {
$max_time = PhabricatorTime::getNow();
- if ($timestamp > $max_time) {
+ if ($timestamp->getEpoch() > $max_time) {
if ($this->isStoppingTracking()) {
$errors[] = pht(
'You can not stop tracking time at a future time. Enter the '.
@@ -92,7 +92,7 @@
if ($this->isStoppingTracking()) {
$min_time = $current_timer->getDateStarted();
- if ($min_time > $timestamp) {
+ if ($min_time > $timestamp->getEpoch()) {
$errors[] = pht(
'Stop time must be after start time.');
$e_date = pht('Invalid');
@@ -103,9 +103,16 @@
if (!$errors) {
$editor = new PhrequentTrackingEditor();
if ($this->isStartingTracking()) {
- $editor->startTracking($viewer, $this->phid, $timestamp);
+ $editor->startTracking(
+ $viewer,
+ $this->phid,
+ $timestamp->getEpoch());
} else if ($this->isStoppingTracking()) {
- $editor->stopTracking($viewer, $this->phid, $timestamp, $v_note);
+ $editor->stopTracking(
+ $viewer,
+ $this->phid,
+ $timestamp->getEpoch(),
+ $v_note);
}
return id(new AphrontRedirectResponse())->setURI($done_uri);
@@ -113,8 +120,6 @@
}
- $epoch_control->setError($e_date);
-
$dialog = $this->newDialog()
->setTitle($title_text)
->setWidth(AphrontDialogView::WIDTH_FORM)
@@ -136,7 +141,13 @@
->setValue($start_string));
}
- $form->appendChild($epoch_control);
+ $form->appendChild(
+ id(new AphrontFormDateControl())
+ ->setUser($viewer)
+ ->setName('epoch')
+ ->setLabel($action_text)
+ ->setError($e_date)
+ ->setValue($timestamp));
if ($this->isStoppingTracking()) {
$form->appendChild(
diff --git a/src/applications/uiexample/examples/PhabricatorFormUIExample.php b/src/applications/uiexample/examples/PhabricatorFormUIExample.php
deleted file mode 100644
--- a/src/applications/uiexample/examples/PhabricatorFormUIExample.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-final class PhabricatorFormUIExample extends PhabricatorUIExample {
-
- public function getName() {
- return 'Form';
- }
-
- public function getDescription() {
- return hsprintf('Use <tt>AphrontFormView</tt> to render forms.');
- }
-
- public function renderExample() {
- $request = $this->getRequest();
- $user = $request->getUser();
-
- $start_time = id(new AphrontFormDateControl())
- ->setUser($user)
- ->setName('start')
- ->setLabel('Start')
- ->setInitialTime(AphrontFormDateControl::TIME_START_OF_BUSINESS);
-
- $end_time = id(new AphrontFormDateControl())
- ->setUser($user)
- ->setName('end')
- ->setLabel('End')
- ->setInitialTime(AphrontFormDateControl::TIME_END_OF_BUSINESS);
-
- $null_time = id(new AphrontFormDateControl())
- ->setUser($user)
- ->setName('nulltime')
- ->setLabel('Nullable')
- ->setAllowNull(true);
-
- if ($request->isFormPost()) {
- $start_value = $start_time->readValueFromRequest($request);
- $end_value = $end_time->readValueFromRequest($request);
- $null_value = $null_time->readValueFromRequest($request);
- }
-
- $divider_control = new AphrontFormDividerControl();
-
- $credentials = array();
- $password_control = id(new PassphraseCredentialControl())
- ->setName('credentialPHID')
- ->setLabel(pht('Password'))
- ->setCredentialType('password')
- ->setOptions($credentials);
-
- $form = id(new AphrontFormView())
- ->setUser($user)
- ->appendChild($start_time)
- ->appendChild($end_time)
- ->appendChild($null_time)
- ->appendChild($divider_control)
- ->appendChild($password_control)
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->setValue('Submit'));
-
- return $form;
- }
-}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 16 2024, 11:26 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6715979
Default Alt Text
D12731.id30591.diff (9 KB)
Attached To
Mode
D12731: Refactor most uses of `AphrontFormDateControl` to user `AphrontFormDateControlValue`
Attached
Detach File
Event Timeline
Log In to Comment