mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Make Phortune account page a little more usable
Summary: Ref T2787. Minor UI improvements. Test Plan: {F214945} Reviewers: btrahan Reviewed By: btrahan Subscribers: chad, epriestley Maniphest Tasks: T2787 Differential Revision: https://secure.phabricator.com/D10658
This commit is contained in:
parent
608465da1e
commit
65421a9e3e
12 changed files with 80 additions and 53 deletions
|
@ -23,6 +23,10 @@ final class FundBackerCart extends PhortuneCartImplementation {
|
|||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return pht('Fund Initiative');
|
||||
}
|
||||
|
||||
public function willCreateCart(
|
||||
PhabricatorUser $viewer,
|
||||
PhortuneCart $cart) {
|
||||
|
|
|
@ -22,7 +22,7 @@ final class FundBackerProduct extends PhortuneProductImplementation {
|
|||
public function getName(PhortuneProduct $product) {
|
||||
$initiative = $this->getInitiative();
|
||||
return pht(
|
||||
'Back Initiative %s %s',
|
||||
'Fund %s %s',
|
||||
$initiative->getMonogram(),
|
||||
$initiative->getName());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ abstract class PhortuneCartImplementation {
|
|||
PhabricatorUser $viewer,
|
||||
array $carts);
|
||||
|
||||
abstract public function getName();
|
||||
|
||||
abstract public function getCancelURI(PhortuneCart $cart);
|
||||
abstract public function getDoneURI(PhortuneCart $cart);
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||
->setObject($account)
|
||||
->setUser($user);
|
||||
|
||||
$properties->addProperty(pht('Balance'), '-');
|
||||
$properties->setActionList($actions);
|
||||
|
||||
$payment_methods = $this->buildPaymentMethodsSection($account);
|
||||
|
@ -163,39 +162,52 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||
))
|
||||
->execute();
|
||||
|
||||
$phids = array();
|
||||
foreach ($carts as $cart) {
|
||||
$phids[] = $cart->getPHID();
|
||||
foreach ($cart->getPurchases() as $purchase) {
|
||||
$phids[] = $purchase->getPHID();
|
||||
}
|
||||
}
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$rows = array();
|
||||
$rowc = array();
|
||||
foreach ($carts as $cart) {
|
||||
$cart_link = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $this->getApplicationURI('cart/'.$cart->getID().'/'),
|
||||
),
|
||||
pht('Cart %d', $cart->getID()));
|
||||
$cart_link = $handles[$cart->getPHID()]->renderLink();
|
||||
$purchases = $cart->getPurchases();
|
||||
|
||||
$rowc[] = 'highlighted';
|
||||
if (count($purchases) == 1) {
|
||||
$purchase_name = $handles[$purchase->getPHID()]->renderLink();
|
||||
$purchases = array();
|
||||
} else {
|
||||
$purchase_name = '';
|
||||
}
|
||||
|
||||
$rowc[] = '';
|
||||
$rows[] = array(
|
||||
phutil_tag('strong', array(), $cart_link),
|
||||
'',
|
||||
'',
|
||||
phutil_tag(
|
||||
'strong',
|
||||
array(),
|
||||
$cart_link),
|
||||
$purchase_name,
|
||||
phutil_tag(
|
||||
'strong',
|
||||
array(),
|
||||
$cart->getTotalPriceAsCurrency()->formatForDisplay()),
|
||||
phabricator_datetime($cart->getDateModified(), $viewer),
|
||||
);
|
||||
foreach ($cart->getPurchases() as $purchase) {
|
||||
foreach ($purchases as $purchase) {
|
||||
$id = $purchase->getID();
|
||||
|
||||
$price = $purchase->getTotalPriceAsCurrency()->formatForDisplay();
|
||||
|
||||
$purchase_link = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $this->getApplicationURI('purchase/'.$id.'/'),
|
||||
),
|
||||
$purchase->getFullDisplayName());
|
||||
|
||||
$rowc[] = '';
|
||||
$rows[] = array(
|
||||
'',
|
||||
$purchase_link,
|
||||
$handles[$purchase->getPHID()]->renderLink(),
|
||||
$price,
|
||||
'',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -207,12 +219,14 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||
pht('Cart'),
|
||||
pht('Purchase'),
|
||||
pht('Amount'),
|
||||
pht('Updated'),
|
||||
))
|
||||
->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'wide',
|
||||
'right',
|
||||
'right',
|
||||
));
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
|
@ -240,9 +254,6 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Account History'));
|
||||
|
||||
$xactions = id(new PhortuneAccountTransactionQuery())
|
||||
->setViewer($user)
|
||||
->withObjectPHIDs(array($account->getPHID()))
|
||||
|
@ -257,13 +268,7 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||
->setTransactions($xactions)
|
||||
->setMarkupEngine($engine);
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setHeader($header);
|
||||
|
||||
return array(
|
||||
$box,
|
||||
$xaction_view,
|
||||
);
|
||||
return $xaction_view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,25 +12,26 @@ abstract class PhortuneController extends PhabricatorController {
|
|||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$phids = array();
|
||||
foreach ($charges as $charge) {
|
||||
$phids[] = $charge->getProviderPHID();
|
||||
$phids[] = $charge->getCartPHID();
|
||||
$phids[] = $charge->getMerchantPHID();
|
||||
$phids[] = $charge->getPaymentMethodPHID();
|
||||
}
|
||||
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$rows = array();
|
||||
foreach ($charges as $charge) {
|
||||
$cart = $charge->getCart();
|
||||
$cart_id = $cart->getID();
|
||||
$cart_uri = $this->getApplicationURI("cart/{$cart_id}/");
|
||||
$cart_href = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $cart_uri,
|
||||
),
|
||||
pht('Cart %d', $cart_id));
|
||||
|
||||
$rows[] = array(
|
||||
$charge->getID(),
|
||||
$cart_href,
|
||||
$charge->getProviderPHID(),
|
||||
$charge->getPaymentMethodPHID(),
|
||||
$handles[$charge->getCartPHID()]->renderLink(),
|
||||
$handles[$charge->getProviderPHID()]->renderLink(),
|
||||
$handles[$charge->getPaymentMethodPHID()]->renderLink(),
|
||||
$handles[$charge->getMerchantPHID()]->renderLink(),
|
||||
$charge->getAmountAsCurrency()->formatForDisplay(),
|
||||
$charge->getStatus(),
|
||||
PhortuneCharge::getNameForStatus($charge->getStatus()),
|
||||
phabricator_datetime($charge->getDateCreated(), $viewer),
|
||||
);
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ abstract class PhortuneController extends PhabricatorController {
|
|||
pht('Cart'),
|
||||
pht('Provider'),
|
||||
pht('Method'),
|
||||
pht('Merchant'),
|
||||
pht('Amount'),
|
||||
pht('Status'),
|
||||
pht('Created'),
|
||||
|
@ -49,7 +51,8 @@ abstract class PhortuneController extends PhabricatorController {
|
|||
->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'strong',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'wide right',
|
||||
|
|
|
@ -29,8 +29,9 @@ final class PhortuneCartPHIDType extends PhabricatorPHIDType {
|
|||
$cart = $objects[$phid];
|
||||
|
||||
$id = $cart->getID();
|
||||
$name = $cart->getImplementation()->getName();
|
||||
|
||||
$handle->setName(pht('Cart %d', $id));
|
||||
$handle->setName($name);
|
||||
$handle->setURI("/phortune/cart/{$id}/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ final class PhortuneMerchantPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$id = $merchant->getID();
|
||||
|
||||
$handle->setName(pht('Merchant %d %s', $id, $merchant->getName()));
|
||||
$handle->setName($merchant->getName());
|
||||
$handle->setURI("/phortune/merchant/{$id}/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ final class PhortunePaymentMethodPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$id = $method->getID();
|
||||
|
||||
$handle->setName(pht('Method %d', $id));
|
||||
$handle->setName($method->getFullDisplayName());
|
||||
$handle->setURI("/phortune/method/{$id}/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,7 @@ final class PhortunePaymentProviderPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$id = $provider_config->getID();
|
||||
|
||||
$handle->setName(pht('Payment Provider %d', $id));
|
||||
$handle->setURI("/phortune/provider/{$id}/");
|
||||
$handle->setName($provider_config->buildProvider()->getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ final class PhortunePurchasePHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$id = $purchase->getID();
|
||||
|
||||
$handle->setName(pht('Purchase %d', $id));
|
||||
$handle->setName($purchase->getFullDisplayName());
|
||||
$handle->setURI("/phortune/purchase/{$id}/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,18 @@ final class PhortuneCharge extends PhortuneDAO
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public static function getStatusNameMap() {
|
||||
return array(
|
||||
self::STATUS_CHARGING => pht('Charging'),
|
||||
self::STATUS_CHARGED => pht('Charged'),
|
||||
self::STATUS_FAILED => pht('Failed'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getNameForStatus($status) {
|
||||
return idx(self::getStatusNameMap(), $status, pht('Unknown'));
|
||||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhortuneChargePHIDType::TYPECONST);
|
||||
|
|
|
@ -60,7 +60,8 @@ final class PhortunePurchase extends PhortuneDAO
|
|||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(PhortuneChargePHIDType::TYPECONST);
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhortunePurchasePHIDType::TYPECONST);
|
||||
}
|
||||
|
||||
public function attachCart(PhortuneCart $cart) {
|
||||
|
|
Loading…
Reference in a new issue