From a69ac888b3732d67fa8b0cc89d5a9cfb822c3794 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Tue, 25 Oct 2016 17:09:02 -0700 Subject: [PATCH] Add Contact Information to Phortune Merchants Summary: Part of making this look/feel/be more professional is having decent receipts for billing, including contact information (whatever we want to put in there). I'm not using this anywhere at the moment, but will. Test Plan: Add Contact Info, see Contact Info. Also, why is Remarkup not rendering with line breaks? Seems to be a OneOff thing... anywho... bears! Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T7607 Differential Revision: https://secure.phabricator.com/D14125 --- .../20161025.phortune.contact.1.sql | 2 + .../PhortuneMerchantEditController.php | 13 +++++++ .../PhortuneMerchantViewController.php | 38 +++++++++---------- .../editor/PhortuneMerchantEditor.php | 8 ++++ .../phortune/storage/PhortuneMerchant.php | 2 + .../storage/PhortuneMerchantTransaction.php | 8 ++++ 6 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 resources/sql/autopatches/20161025.phortune.contact.1.sql diff --git a/resources/sql/autopatches/20161025.phortune.contact.1.sql b/resources/sql/autopatches/20161025.phortune.contact.1.sql new file mode 100644 index 0000000000..48bacd1a21 --- /dev/null +++ b/resources/sql/autopatches/20161025.phortune.contact.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_phortune.phortune_merchant + ADD contactInfo LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL; diff --git a/src/applications/phortune/controller/PhortuneMerchantEditController.php b/src/applications/phortune/controller/PhortuneMerchantEditController.php index 3a6aad215f..4def6edebf 100644 --- a/src/applications/phortune/controller/PhortuneMerchantEditController.php +++ b/src/applications/phortune/controller/PhortuneMerchantEditController.php @@ -47,6 +47,7 @@ final class PhortuneMerchantEditController $e_name = true; $v_name = $merchant->getName(); $v_desc = $merchant->getDescription(); + $v_cont = $merchant->getContactInfo(); $v_members = $merchant->getMemberPHIDs(); $e_members = null; @@ -54,12 +55,14 @@ final class PhortuneMerchantEditController if ($request->isFormPost()) { $v_name = $request->getStr('name'); $v_desc = $request->getStr('desc'); + $v_cont = $request->getStr('cont'); $v_view = $request->getStr('viewPolicy'); $v_edit = $request->getStr('editPolicy'); $v_members = $request->getArr('memberPHIDs'); $type_name = PhortuneMerchantTransaction::TYPE_NAME; $type_desc = PhortuneMerchantTransaction::TYPE_DESCRIPTION; + $type_cont = PhortuneMerchantTransaction::TYPE_CONTACTINFO; $type_edge = PhabricatorTransactions::TYPE_EDGE; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; @@ -75,6 +78,10 @@ final class PhortuneMerchantEditController ->setTransactionType($type_desc) ->setNewValue($v_desc); + $xactions[] = id(new PhortuneMerchantTransaction()) + ->setTransactionType($type_cont) + ->setNewValue($v_cont); + $xactions[] = id(new PhortuneMerchantTransaction()) ->setTransactionType($type_view) ->setNewValue($v_view); @@ -127,6 +134,12 @@ final class PhortuneMerchantEditController ->setName('desc') ->setLabel(pht('Description')) ->setValue($v_desc)) + ->appendChild( + id(new PhabricatorRemarkupControl()) + ->setUser($viewer) + ->setName('cont') + ->setLabel(pht('Contact Info')) + ->setValue($v_cont)) ->appendControl( id(new AphrontFormTokenizerControl()) ->setDatasource(new PhabricatorPeopleDatasource()) diff --git a/src/applications/phortune/controller/PhortuneMerchantViewController.php b/src/applications/phortune/controller/PhortuneMerchantViewController.php index a0e1100004..cc94da6f4f 100644 --- a/src/applications/phortune/controller/PhortuneMerchantViewController.php +++ b/src/applications/phortune/controller/PhortuneMerchantViewController.php @@ -36,7 +36,6 @@ final class PhortuneMerchantViewController ->execute(); $details = $this->buildDetailsView($merchant, $providers); - $description = $this->buildDescriptionView($merchant); $curtain = $this->buildCurtainView($merchant); $provider_list = $this->buildProviderList( @@ -53,7 +52,6 @@ final class PhortuneMerchantViewController ->setCurtain($curtain) ->setMainColumn(array( $details, - $description, $provider_list, $timeline, )); @@ -130,30 +128,30 @@ final class PhortuneMerchantViewController $view->addProperty(pht('Status'), $status_view); + $description = $merchant->getDescription(); + if (strlen($description)) { + $description = new PHUIRemarkupView($viewer, $description); + $view->addSectionHeader( + pht('Description'), + PHUIPropertyListView::ICON_SUMMARY); + $view->addTextContent($description); + } + + $contact_info = $merchant->getContactInfo(); + if (strlen($contact_info)) { + $contact_info = new PHUIRemarkupView($viewer, $contact_info); + $view->addSectionHeader( + pht('Contact Info'), + PHUIPropertyListView::ICON_SUMMARY); + $view->addTextContent($contact_info); + } + return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Details')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($view); } - private function buildDescriptionView(PhortuneMerchant $merchant) { - $viewer = $this->getViewer(); - $view = id(new PHUIPropertyListView()) - ->setUser($viewer); - - $description = $merchant->getDescription(); - if (strlen($description)) { - $description = new PHUIRemarkupView($viewer, $description); - $view->addTextContent($description); - return id(new PHUIObjectBoxView()) - ->setHeaderText(pht('Description')) - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->appendChild($view); - } - - return null; - } - private function buildCurtainView(PhortuneMerchant $merchant) { $viewer = $this->getRequest()->getUser(); $id = $merchant->getID(); diff --git a/src/applications/phortune/editor/PhortuneMerchantEditor.php b/src/applications/phortune/editor/PhortuneMerchantEditor.php index 1c659c0d5f..20f329b202 100644 --- a/src/applications/phortune/editor/PhortuneMerchantEditor.php +++ b/src/applications/phortune/editor/PhortuneMerchantEditor.php @@ -16,6 +16,7 @@ final class PhortuneMerchantEditor $types[] = PhortuneMerchantTransaction::TYPE_NAME; $types[] = PhortuneMerchantTransaction::TYPE_DESCRIPTION; + $types[] = PhortuneMerchantTransaction::TYPE_CONTACTINFO; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDGE; @@ -30,6 +31,8 @@ final class PhortuneMerchantEditor return $object->getName(); case PhortuneMerchantTransaction::TYPE_DESCRIPTION: return $object->getDescription(); + case PhortuneMerchantTransaction::TYPE_CONTACTINFO: + return $object->getContactInfo(); } return parent::getCustomTransactionOldValue($object, $xaction); @@ -42,6 +45,7 @@ final class PhortuneMerchantEditor switch ($xaction->getTransactionType()) { case PhortuneMerchantTransaction::TYPE_NAME: case PhortuneMerchantTransaction::TYPE_DESCRIPTION: + case PhortuneMerchantTransaction::TYPE_CONTACTINFO: return $xaction->getNewValue(); } @@ -59,6 +63,9 @@ final class PhortuneMerchantEditor case PhortuneMerchantTransaction::TYPE_DESCRIPTION: $object->setDescription($xaction->getNewValue()); return; + case PhortuneMerchantTransaction::TYPE_CONTACTINFO: + $object->setContactInfo($xaction->getNewValue()); + return; } return parent::applyCustomInternalTransaction($object, $xaction); @@ -71,6 +78,7 @@ final class PhortuneMerchantEditor switch ($xaction->getTransactionType()) { case PhortuneMerchantTransaction::TYPE_NAME: case PhortuneMerchantTransaction::TYPE_DESCRIPTION: + case PhortuneMerchantTransaction::TYPE_CONTACTINFO: return; } diff --git a/src/applications/phortune/storage/PhortuneMerchant.php b/src/applications/phortune/storage/PhortuneMerchant.php index 2f09abd6d7..fef1728014 100644 --- a/src/applications/phortune/storage/PhortuneMerchant.php +++ b/src/applications/phortune/storage/PhortuneMerchant.php @@ -8,6 +8,7 @@ final class PhortuneMerchant extends PhortuneDAO protected $name; protected $viewPolicy; protected $description; + protected $contactInfo; private $memberPHIDs = self::ATTACHABLE; @@ -23,6 +24,7 @@ final class PhortuneMerchant extends PhortuneDAO self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text255', 'description' => 'text', + 'contactInfo' => 'text', ), ) + parent::getConfiguration(); } diff --git a/src/applications/phortune/storage/PhortuneMerchantTransaction.php b/src/applications/phortune/storage/PhortuneMerchantTransaction.php index 32c32b0778..9c284ca7fd 100644 --- a/src/applications/phortune/storage/PhortuneMerchantTransaction.php +++ b/src/applications/phortune/storage/PhortuneMerchantTransaction.php @@ -5,6 +5,7 @@ final class PhortuneMerchantTransaction const TYPE_NAME = 'merchant:name'; const TYPE_DESCRIPTION = 'merchant:description'; + const TYPE_CONTACTINFO = 'merchant:contactinfo'; public function getApplicationName() { return 'phortune'; @@ -42,6 +43,10 @@ final class PhortuneMerchantTransaction return pht( '%s updated the description for this merchant.', $this->renderHandleLink($author_phid)); + case self::TYPE_CONTACTINFO: + return pht( + '%s updated the contact information for this merchant.', + $this->renderHandleLink($author_phid)); } return parent::getTitle(); @@ -51,6 +56,7 @@ final class PhortuneMerchantTransaction $old = $this->getOldValue(); switch ($this->getTransactionType()) { case self::TYPE_DESCRIPTION: + case self::TYPE_CONTACTINFO: return ($old === null); } return parent::shouldHide(); @@ -60,6 +66,8 @@ final class PhortuneMerchantTransaction switch ($this->getTransactionType()) { case self::TYPE_DESCRIPTION: return ($this->getOldValue() !== null); + case self::TYPE_CONTACTINFO: + return ($this->getOldValue() !== null); } return parent::hasChangeDetails();