1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Add Description field to Countdowns

Summary: Allows countdowns to have a description.

Test Plan: Use description, edit description. Check timeline, etc.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13691
This commit is contained in:
Chad Little 2015-07-23 10:56:18 -07:00
parent 062f38e163
commit 875dc54516
6 changed files with 88 additions and 0 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_countdown.countdown
ADD description LONGTEXT NOT NULL;

View file

@ -41,12 +41,14 @@ final class PhabricatorCountdownEditController
$e_epoch = null; $e_epoch = null;
$v_text = $countdown->getTitle(); $v_text = $countdown->getTitle();
$v_desc = $countdown->getDescription();
$v_space = $countdown->getSpacePHID(); $v_space = $countdown->getSpacePHID();
$v_view = $countdown->getViewPolicy(); $v_view = $countdown->getViewPolicy();
$v_edit = $countdown->getEditPolicy(); $v_edit = $countdown->getEditPolicy();
if ($request->isFormPost()) { if ($request->isFormPost()) {
$v_text = $request->getStr('title'); $v_text = $request->getStr('title');
$v_desc = $request->getStr('description');
$v_space = $request->getStr('spacePHID'); $v_space = $request->getStr('spacePHID');
$date_value = AphrontFormDateControlValue::newFromRequest( $date_value = AphrontFormDateControlValue::newFromRequest(
$request, $request,
@ -57,6 +59,7 @@ final class PhabricatorCountdownEditController
$type_title = PhabricatorCountdownTransaction::TYPE_TITLE; $type_title = PhabricatorCountdownTransaction::TYPE_TITLE;
$type_epoch = PhabricatorCountdownTransaction::TYPE_EPOCH; $type_epoch = PhabricatorCountdownTransaction::TYPE_EPOCH;
$type_description = PhabricatorCountdownTransaction::TYPE_DESCRIPTION;
$type_space = PhabricatorTransactions::TYPE_SPACE; $type_space = PhabricatorTransactions::TYPE_SPACE;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
@ -71,6 +74,10 @@ final class PhabricatorCountdownEditController
->setTransactionType($type_epoch) ->setTransactionType($type_epoch)
->setNewValue($date_value); ->setNewValue($date_value);
$xactions[] = id(new PhabricatorCountdownTransaction())
->setTransactionType($type_description)
->setNewValue($v_desc);
$xactions[] = id(new PhabricatorCountdownTransaction()) $xactions[] = id(new PhabricatorCountdownTransaction())
->setTransactionType($type_space) ->setTransactionType($type_space)
->setNewValue($v_space); ->setNewValue($v_space);
@ -141,6 +148,11 @@ final class PhabricatorCountdownEditController
->setLabel(pht('End Date')) ->setLabel(pht('End Date'))
->setError($e_epoch) ->setError($e_epoch)
->setValue($date_value)) ->setValue($date_value))
->appendControl(
id(new PhabricatorRemarkupControl())
->setName('description')
->setLabel(pht('Description'))
->setValue($v_desc))
->appendControl( ->appendControl(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
->setName('viewPolicy') ->setName('viewPolicy')

View file

@ -123,6 +123,21 @@ final class PhabricatorCountdownViewController
pht('Author'), pht('Author'),
$viewer->renderHandle($countdown->getAuthorPHID())); $viewer->renderHandle($countdown->getAuthorPHID()));
$view->invokeWillRenderEvent();
$description = $countdown->getDescription();
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer);
$view->addSectionHeader(
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent($description);
}
return $view; return $view;
} }

View file

@ -16,6 +16,7 @@ final class PhabricatorCountdownEditor
$types[] = PhabricatorCountdownTransaction::TYPE_TITLE; $types[] = PhabricatorCountdownTransaction::TYPE_TITLE;
$types[] = PhabricatorCountdownTransaction::TYPE_EPOCH; $types[] = PhabricatorCountdownTransaction::TYPE_EPOCH;
$types[] = PhabricatorCountdownTransaction::TYPE_DESCRIPTION;
$types[] = PhabricatorTransactions::TYPE_EDGE; $types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorTransactions::TYPE_SPACE; $types[] = PhabricatorTransactions::TYPE_SPACE;
@ -31,6 +32,8 @@ final class PhabricatorCountdownEditor
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorCountdownTransaction::TYPE_TITLE: case PhabricatorCountdownTransaction::TYPE_TITLE:
return $object->getTitle(); return $object->getTitle();
case PhabricatorCountdownTransaction::TYPE_DESCRIPTION:
return $object->getDescription();
case PhabricatorCountdownTransaction::TYPE_EPOCH: case PhabricatorCountdownTransaction::TYPE_EPOCH:
return $object->getEpoch(); return $object->getEpoch();
} }
@ -45,6 +48,8 @@ final class PhabricatorCountdownEditor
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorCountdownTransaction::TYPE_TITLE: case PhabricatorCountdownTransaction::TYPE_TITLE:
return $xaction->getNewValue(); return $xaction->getNewValue();
case PhabricatorCountdownTransaction::TYPE_DESCRIPTION:
return $xaction->getNewValue();
case PhabricatorCountdownTransaction::TYPE_EPOCH: case PhabricatorCountdownTransaction::TYPE_EPOCH:
return $xaction->getNewValue()->getEpoch(); return $xaction->getNewValue()->getEpoch();
} }
@ -61,6 +66,9 @@ final class PhabricatorCountdownEditor
case PhabricatorCountdownTransaction::TYPE_TITLE: case PhabricatorCountdownTransaction::TYPE_TITLE:
$object->setTitle($xaction->getNewValue()); $object->setTitle($xaction->getNewValue());
return; return;
case PhabricatorCountdownTransaction::TYPE_DESCRIPTION:
$object->setDescription($xaction->getNewValue());
return;
case PhabricatorCountdownTransaction::TYPE_EPOCH: case PhabricatorCountdownTransaction::TYPE_EPOCH:
$object->setEpoch($xaction->getNewValue()); $object->setEpoch($xaction->getNewValue());
return; return;
@ -77,6 +85,8 @@ final class PhabricatorCountdownEditor
switch ($type) { switch ($type) {
case PhabricatorCountdownTransaction::TYPE_TITLE: case PhabricatorCountdownTransaction::TYPE_TITLE:
return; return;
case PhabricatorCountdownTransaction::TYPE_DESCRIPTION:
return;
case PhabricatorCountdownTransaction::TYPE_EPOCH: case PhabricatorCountdownTransaction::TYPE_EPOCH:
return; return;
} }
@ -138,6 +148,8 @@ final class PhabricatorCountdownEditor
return array( return array(
PhabricatorCountdownTransaction::MAILTAG_TITLE => PhabricatorCountdownTransaction::MAILTAG_TITLE =>
pht('Someone changes the countdown title.'), pht('Someone changes the countdown title.'),
PhabricatorCountdownTransaction::MAILTAG_DESCRIPTION =>
pht('Someone changes the countdown description.'),
PhabricatorCountdownTransaction::MAILTAG_EPOCH => PhabricatorCountdownTransaction::MAILTAG_EPOCH =>
pht('Someone changes the countdown end date.'), pht('Someone changes the countdown end date.'),
PhabricatorCountdownTransaction::MAILTAG_OTHER => PhabricatorCountdownTransaction::MAILTAG_OTHER =>

View file

@ -13,6 +13,7 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
protected $title; protected $title;
protected $authorPHID; protected $authorPHID;
protected $epoch; protected $epoch;
protected $description;
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
@ -39,6 +40,7 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
self::CONFIG_AUX_PHID => true, self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array( self::CONFIG_COLUMN_SCHEMA => array(
'title' => 'text255', 'title' => 'text255',
'description' => 'text',
), ),
) + parent::getConfiguration(); ) + parent::getConfiguration();
} }

View file

@ -5,9 +5,11 @@ final class PhabricatorCountdownTransaction
const TYPE_TITLE = 'countdown:title'; const TYPE_TITLE = 'countdown:title';
const TYPE_EPOCH = 'countdown:epoch'; const TYPE_EPOCH = 'countdown:epoch';
const TYPE_DESCRIPTION = 'countdown:description';
const MAILTAG_TITLE = 'countdown:title'; const MAILTAG_TITLE = 'countdown:title';
const MAILTAG_EPOCH = 'countdown:epoch'; const MAILTAG_EPOCH = 'countdown:epoch';
const MAILTAG_DESRICPTION = 'countdown:description';
const MAILTAG_OTHER = 'countdown:other'; const MAILTAG_OTHER = 'countdown:other';
public function getApplicationName() { public function getApplicationName() {
@ -43,6 +45,18 @@ final class PhabricatorCountdownTransaction
$old, $old,
$new); $new);
} }
break;
case self::TYPE_DESCRIPTION:
if ($old === null) {
return pht(
'%s set the description of this countdown.',
$this->renderHandleLink($author_phid));
} else {
return pht(
'%s edited the description of this countdown.',
$this->renderHandleLink($author_phid));
}
break;
case self::TYPE_EPOCH: case self::TYPE_EPOCH:
if ($old === null) { if ($old === null) {
return pht( return pht(
@ -84,6 +98,34 @@ final class PhabricatorCountdownTransaction
$this->renderHandleLink($object_phid)); $this->renderHandleLink($object_phid));
} }
break; break;
case self::TYPE_DESCRIPTION:
if ($old === null) {
return pht(
'%s set the description of %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
} else {
return pht(
'%s edited the description of %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
}
break;
case self::TYPE_EPOCH:
if ($old === null) {
return pht(
'%s set the end date of %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
} else {
return pht(
'%s edited the end date of %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
}
break;
} }
return parent::getTitleForFeed(); return parent::getTitleForFeed();
@ -99,6 +141,9 @@ final class PhabricatorCountdownTransaction
case self::TYPE_EPOCH: case self::TYPE_EPOCH:
$tags[] = self::MAILTAG_EPOCH; $tags[] = self::MAILTAG_EPOCH;
break; break;
case self::TYPE_DESCRIPTION:
$tags[] = self::MAILTAG_DESCRIPTION;
break;
default: default:
$tags[] = self::MAILTAG_OTHER; $tags[] = self::MAILTAG_OTHER;
break; break;