1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 16:51:08 +01:00

Make Fund backers render a little more nicely

Summary: Ref T5835. Mostly UI smoothing. Also add a "Risks" field to initiatives.

Test Plan: {F214952}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5835

Differential Revision: https://secure.phabricator.com/D10660
This commit is contained in:
epriestley 2014-10-08 05:32:42 -07:00
parent 65421a9e3e
commit 43215bf0bd
8 changed files with 69 additions and 21 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_fund.fund_initiative
ADD risks LONGTEXT NOT NULL COLLATE utf8_bin;

View file

@ -118,7 +118,8 @@ final class FundInitiativeBackController
->setError($e_amount));
return $this->newDialog()
->setTitle(pht('Back Initiative'))
->setTitle(
pht('Back %s %s', $initiative->getMonogram(), $initiative->getName()))
->setErrors($errors)
->appendChild($form->buildLayoutView())
->addCancelButton($initiative_uri)

View file

@ -52,6 +52,7 @@ final class FundInitiativeEditController
$v_merchant = $initiative->getMerchantPHID();
$v_desc = $initiative->getDescription();
$v_risk = $initiative->getRisks();
if ($is_new) {
$v_projects = array();
@ -66,6 +67,7 @@ final class FundInitiativeEditController
if ($request->isFormPost()) {
$v_name = $request->getStr('name');
$v_desc = $request->getStr('description');
$v_risk = $request->getStr('risks');
$v_view = $request->getStr('viewPolicy');
$v_edit = $request->getStr('editPolicy');
$v_merchant = $request->getStr('merchantPHID');
@ -73,6 +75,7 @@ final class FundInitiativeEditController
$type_name = FundInitiativeTransaction::TYPE_NAME;
$type_desc = FundInitiativeTransaction::TYPE_DESCRIPTION;
$type_risk = FundInitiativeTransaction::TYPE_RISKS;
$type_merchant = FundInitiativeTransaction::TYPE_MERCHANT;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
@ -87,6 +90,10 @@ final class FundInitiativeEditController
->setTransactionType($type_desc)
->setNewValue($v_desc);
$xactions[] = id(new FundInitiativeTransaction())
->setTransactionType($type_risk)
->setNewValue($v_risk);
$xactions[] = id(new FundInitiativeTransaction())
->setTransactionType($type_merchant)
->setNewValue($v_merchant);
@ -196,6 +203,11 @@ final class FundInitiativeEditController
->setName('description')
->setLabel(pht('Description'))
->setValue($v_desc))
->appendChild(
id(new PhabricatorRemarkupControl())
->setName('risks')
->setLabel(pht('Risks/Challenges'))
->setValue($v_risk))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))

View file

@ -96,7 +96,7 @@ final class FundInitiativeViewController
$this->getHandle($owner_phid)->renderLink());
$view->addProperty(
pht('Payable To Merchant'),
pht('Payable to Merchant'),
$this->getHandle($merchant_phid)->renderLink());
$view->addProperty(
@ -116,6 +116,17 @@ final class FundInitiativeViewController
$view->addTextContent($description);
}
$risks = $initiative->getRisks();
if (strlen($risks)) {
$risks = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($risks),
'default',
$viewer);
$view->addSectionHeader(pht('Risks/Challenges'));
$view->addTextContent($risks);
}
return $view;
}

View file

@ -16,6 +16,7 @@ final class FundInitiativeEditor
$types[] = FundInitiativeTransaction::TYPE_NAME;
$types[] = FundInitiativeTransaction::TYPE_DESCRIPTION;
$types[] = FundInitiativeTransaction::TYPE_RISKS;
$types[] = FundInitiativeTransaction::TYPE_STATUS;
$types[] = FundInitiativeTransaction::TYPE_BACKER;
$types[] = FundInitiativeTransaction::TYPE_MERCHANT;
@ -33,6 +34,8 @@ final class FundInitiativeEditor
return $object->getName();
case FundInitiativeTransaction::TYPE_DESCRIPTION:
return $object->getDescription();
case FundInitiativeTransaction::TYPE_RISKS:
return $object->getRisks();
case FundInitiativeTransaction::TYPE_STATUS:
return $object->getStatus();
case FundInitiativeTransaction::TYPE_BACKER:
@ -51,6 +54,7 @@ final class FundInitiativeEditor
switch ($xaction->getTransactionType()) {
case FundInitiativeTransaction::TYPE_NAME:
case FundInitiativeTransaction::TYPE_DESCRIPTION:
case FundInitiativeTransaction::TYPE_RISKS:
case FundInitiativeTransaction::TYPE_STATUS:
case FundInitiativeTransaction::TYPE_BACKER:
case FundInitiativeTransaction::TYPE_MERCHANT:
@ -71,6 +75,9 @@ final class FundInitiativeEditor
case FundInitiativeTransaction::TYPE_DESCRIPTION:
$object->setDescription($xaction->getNewValue());
return;
case FundInitiativeTransaction::TYPE_RISKS:
$object->setRisks($xaction->getNewValue());
return;
case FundInitiativeTransaction::TYPE_MERCHANT:
$object->setMerchantPHID($xaction->getNewValue());
return;
@ -106,6 +113,7 @@ final class FundInitiativeEditor
switch ($xaction->getTransactionType()) {
case FundInitiativeTransaction::TYPE_NAME:
case FundInitiativeTransaction::TYPE_DESCRIPTION:
case FundInitiativeTransaction::TYPE_RISKS:
case FundInitiativeTransaction::TYPE_STATUS:
case FundInitiativeTransaction::TYPE_MERCHANT:
case FundInitiativeTransaction::TYPE_BACKER:

View file

@ -126,29 +126,35 @@ final class FundBackerSearchEngine
$viewer = $this->requireViewer();
$list = id(new PHUIObjectItemListView());
$rows = array();
foreach ($backers as $backer) {
$backer_handle = $handles[$backer->getBackerPHID()];
$currency = $backer->getAmountAsCurrency();
$header = pht(
'%s for %s',
$currency->formatForDisplay(),
$handles[$backer->getInitiativePHID()]->renderLink());
$item = id(new PHUIObjectItemView())
->setHeader($header)
->addIcon(
'none',
phabricator_datetime($backer->getDateCreated(), $viewer))
->addByline(pht('Backer: %s', $backer_handle->renderLink()));
$list->addItem($item);
$rows[] = array(
$handles[$backer->getInitiativePHID()]->renderLink(),
$handles[$backer->getBackerPHID()]->renderLink(),
$backer->getAmountAsCurrency()->formatForDisplay(),
phabricator_datetime($backer->getDateCreated(), $viewer),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Initiative'),
pht('Backer'),
pht('Amount'),
pht('Date'),
))
->setColumnClasses(
array(
null,
null,
'wide right',
'right',
));
return $list;
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Backers'))
->appendChild($table);
}
}

View file

@ -15,6 +15,7 @@ final class FundInitiative extends FundDAO
protected $ownerPHID;
protected $merchantPHID;
protected $description;
protected $risks;
protected $viewPolicy;
protected $editPolicy;
protected $status;

View file

@ -5,6 +5,7 @@ final class FundInitiativeTransaction
const TYPE_NAME = 'fund:name';
const TYPE_DESCRIPTION = 'fund:description';
const TYPE_RISKS = 'fund:risks';
const TYPE_STATUS = 'fund:status';
const TYPE_BACKER = 'fund:backer';
const TYPE_MERCHANT = 'fund:merchant';
@ -64,6 +65,10 @@ final class FundInitiativeTransaction
$new);
}
break;
case FundInitiativeTransaction::TYPE_RISKS:
return pht(
'%s edited the risks for this initiative.',
$this->renderHandleLink($author_phid));
case FundInitiativeTransaction::TYPE_DESCRIPTION:
return pht(
'%s edited the description of this initiative.',
@ -159,6 +164,7 @@ final class FundInitiativeTransaction
$old = $this->getOldValue();
switch ($this->getTransactionType()) {
case FundInitiativeTransaction::TYPE_DESCRIPTION:
case FundInitiativeTransaction::TYPE_RISKS:
return ($old === null);
}
return parent::shouldHide();
@ -167,6 +173,7 @@ final class FundInitiativeTransaction
public function hasChangeDetails() {
switch ($this->getTransactionType()) {
case FundInitiativeTransaction::TYPE_DESCRIPTION:
case FundInitiativeTransaction::TYPE_RISKS:
return ($this->getOldValue() !== null);
}