1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Transactions - make the details stuff generic and ajaxy

Summary: Fixes T2213

Test Plan: Updated a pholio mock description. Observed that when I first showed details there was a round trip made. Toggled show / hide noting no more trips made to server.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T2213

Differential Revision: https://secure.phabricator.com/D6801
This commit is contained in:
Bob Trahan 2013-08-22 16:45:14 -07:00
parent 099695ab61
commit 320498d3d0
9 changed files with 97 additions and 24 deletions

View file

@ -2178,7 +2178,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-phabricator-transaction-list' =>
array(
'uri' => '/res/8d602093/rsrc/js/application/transactions/behavior-transaction-list.js',
'uri' => '/res/db441ac4/rsrc/js/application/transactions/behavior-transaction-list.js',
'type' => 'js',
'requires' =>
array(

View file

@ -837,6 +837,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionCommentQuery' => 'applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php',
'PhabricatorApplicationTransactionCommentView' => 'applications/transactions/view/PhabricatorApplicationTransactionCommentView.php',
'PhabricatorApplicationTransactionController' => 'applications/transactions/controller/PhabricatorApplicationTransactionController.php',
'PhabricatorApplicationTransactionDetailController' => 'applications/transactions/controller/PhabricatorApplicationTransactionDetailController.php',
'PhabricatorApplicationTransactionEditor' => 'applications/transactions/editor/PhabricatorApplicationTransactionEditor.php',
'PhabricatorApplicationTransactionFeedStory' => 'applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php',
'PhabricatorApplicationTransactionInterface' => 'applications/transactions/interface/PhabricatorApplicationTransactionInterface.php',
@ -2878,6 +2879,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionCommentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorApplicationTransactionCommentView' => 'AphrontView',
'PhabricatorApplicationTransactionController' => 'PhabricatorController',
'PhabricatorApplicationTransactionDetailController' => 'PhabricatorApplicationTransactionController',
'PhabricatorApplicationTransactionEditor' => 'PhabricatorEditor',
'PhabricatorApplicationTransactionFeedStory' => 'PhabricatorFeedStory',
'PhabricatorApplicationTransactionNoEffectException' => 'Exception',

View file

@ -17,6 +17,8 @@ final class PhabricatorApplicationTransactions extends PhabricatorApplication {
=> 'PhabricatorApplicationTransactionCommentEditController',
'history/(?<phid>[^/]+)/'
=> 'PhabricatorApplicationTransactionCommentHistoryController',
'detail/(?<phid>[^/]+)/'
=> 'PhabricatorApplicationTransactionDetailController',
),
);
}

View file

@ -13,10 +13,10 @@ final class PhabricatorApplicationTransactionCommentEditController
$request = $this->getRequest();
$user = $request->getUser();
$xactions = id(new PhabricatorObjectHandleData(array($this->phid)))
$xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($this->phid))
->setViewer($user)
->loadObjects();
$xaction = idx($xactions, $this->phid);
->executeOne();
if (!$xaction) {
// TODO: This may also mean you don't have permission to edit the object,
@ -33,10 +33,6 @@ final class PhabricatorApplicationTransactionCommentEditController
$obj_phid = $xaction->getObjectPHID();
$obj_handle = PhabricatorObjectHandleData::loadOneHandle($obj_phid, $user);
if (!$obj_handle) {
// Require the corresponding object exist and be visible to the user.
return new Aphront404Response();
}
if ($request->isDialogFormPost()) {
$text = $request->getStr('text');

View file

@ -13,10 +13,10 @@ final class PhabricatorApplicationTransactionCommentHistoryController
$request = $this->getRequest();
$user = $request->getUser();
$xactions = id(new PhabricatorObjectHandleData(array($this->phid)))
$xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($this->phid))
->setViewer($user)
->loadObjects();
$xaction = idx($xactions, $this->phid);
->executeOne();
if (!$xaction) {
// TODO: This may also mean you don't have permission to edit the object,
@ -30,13 +30,6 @@ final class PhabricatorApplicationTransactionCommentHistoryController
return new Aphront404Response();
}
$obj_phid = $xaction->getObjectPHID();
$obj_handle = PhabricatorObjectHandleData::loadOneHandle($obj_phid, $user);
if (!$obj_handle) {
// Require the corresponding object exist and be visible to the user.
return new Aphront404Response();
}
$comments = id(new PhabricatorApplicationTransactionCommentQuery())
->setViewer($user)
->setTemplate($xaction->getApplicationTransactionCommentObject())
@ -59,13 +52,15 @@ final class PhabricatorApplicationTransactionCommentHistoryController
->attachComment($comment);
}
$obj_phid = $xaction->getObjectPHID();
$obj_handle = PhabricatorObjectHandleData::loadOneHandle($obj_phid, $user);
$view = id(new PhabricatorApplicationTransactionView())
->setUser($user)
->setObjectPHID($obj_phid)
->setTransactions($xactions)
->setShowEditActions(false);
$dialog = id(new AphrontDialogView())
->setUser($user)
->setWidth(AphrontDialogView::WIDTH_FULL)

View file

@ -0,0 +1,33 @@
<?php
final class PhabricatorApplicationTransactionDetailController
extends PhabricatorApplicationTransactionController {
private $phid;
public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($this->phid))
->setViewer($user)
->executeOne();
if (!$xaction) {
// future proofing for the day visibility of transactions can change
return new Aphront404Response();
}
return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user)
->setTransactions(array($xaction))
->setIsDetailView(true)
->setAnchorOffset($request->getStr('anchor'));
}
}

View file

@ -7,6 +7,7 @@ final class PhabricatorApplicationTransactionResponse
private $transactions;
private $anchorOffset;
private $isPreview;
private $isDetailView;
protected function buildProxy() {
return new AphrontAjaxResponse();
@ -46,6 +47,11 @@ final class PhabricatorApplicationTransactionResponse
return $this;
}
public function setIsDetailView($is_detail_view) {
$this->isDetailView = $is_detail_view;
return $this;
}
public function reduceProxyResponse() {
if ($this->getTransactions()) {
$view = head($this->getTransactions())
@ -57,7 +63,8 @@ final class PhabricatorApplicationTransactionResponse
$view
->setUser($this->getViewer())
->setTransactions($this->getTransactions())
->setIsPreview($this->isPreview);
->setIsPreview($this->isPreview)
->setIsDetailView($this->isDetailView);
if ($this->getAnchorOffset()) {
$view->setAnchorOffset($this->getAnchorOffset());

View file

@ -11,6 +11,12 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private $showEditActions = true;
private $isPreview;
private $objectPHID;
private $isDetailView;
public function setIsDetailView($is_detail_view) {
$this->isDetailView = $is_detail_view;
return $this;
}
public function setObjectPHID($object_phid) {
$this->objectPHID = $object_phid;
@ -89,10 +95,15 @@ class PhabricatorApplicationTransactionView extends AphrontView {
$title = $xaction->getTitle();
if ($xaction->hasChangeDetails()) {
if ($this->isPreview || $this->isDetailView) {
$details = $this->buildChangeDetails($xaction);
} else {
$details = $this->buildChangeDetailsLink($xaction);
}
$title = array(
$title,
' ',
$this->buildChangeDetails($xaction),
$details,
);
}
$event->setTitle($title);
@ -168,7 +179,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
return $view->render();
}
protected function getOrBuildEngine() {
if ($this->engine) {
return $this->engine;
@ -205,6 +215,7 @@ class PhabricatorApplicationTransactionView extends AphrontView {
'sigil' => 'reveal-content',
'mustcapture' => true,
'id' => $show_id,
'style' => 'display: none',
'meta' => array(
'hideIDs' => array($show_id),
'showIDs' => array($hide_id, $content_id),
@ -219,7 +230,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
'sigil' => 'reveal-content',
'mustcapture' => true,
'id' => $hide_id,
'style' => 'display: none',
'meta' => array(
'hideIDs' => array($hide_id, $content_id),
'showIDs' => array($show_id),
@ -231,7 +241,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
'div',
array(
'id' => $content_id,
'style' => 'display: none',
'class' => 'phabricator-timeline-change-details',
),
$xaction->renderChangeDetails($this->getUser()));
@ -243,6 +252,22 @@ class PhabricatorApplicationTransactionView extends AphrontView {
);
}
private function buildChangeDetailsLink(
PhabricatorApplicationTransaction $xaction) {
return javelin_tag(
'a',
array(
'href' => '/transactions/detail/'.$xaction->getPHID().'/',
'sigil' => 'transaction-detail',
'mustcapture' => true,
'meta' => array(
'anchor' => $this->anchorOffset,
),
),
pht('(Show Details)'));
}
protected function shouldGroupTransactions(
PhabricatorApplicationTransaction $u,
PhabricatorApplicationTransaction $v) {

View file

@ -75,6 +75,19 @@ JX.behavior('phabricator-transaction-list', function(config) {
e.kill();
});
JX.DOM.listen(list, 'click', 'transaction-detail', function(e) {
if (!e.isNormalClick()) {
return;
}
JX.Workflow.newFromLink(e.getTarget())
.setData({anchor: e.getData('anchor')})
.setHandler(ontransactions)
.start();
e.kill();
});
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'transaction-append',