mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Slightly modernize NuanceQueue
Summary: Ref T8434. Touch things up a bit. This also cleans up the missing ApplicationTransactionInterface for T6367. Test Plan: Didn't create a new queue. Didn't edit an existing queue. Reviewers: btrahan Reviewed By: btrahan Subscribers: jeremyb, epriestley Maniphest Tasks: T8434 Differential Revision: https://secure.phabricator.com/D13160
This commit is contained in:
parent
ef90007a21
commit
1f65a50f04
3 changed files with 67 additions and 43 deletions
|
@ -2,43 +2,36 @@
|
|||
|
||||
final class NuanceQueueEditController extends NuanceController {
|
||||
|
||||
private $queueID;
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
public function setQueueID($queue_id) {
|
||||
$this->queueID = $queue_id;
|
||||
return $this;
|
||||
}
|
||||
public function getQueueID() {
|
||||
return $this->queueID;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->setQueueID(idx($data, 'id'));
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$queue_id = $this->getQueueID();
|
||||
$queue_id = $request->getURIData('id');
|
||||
$is_new = !$queue_id;
|
||||
|
||||
if ($is_new) {
|
||||
$queue = new NuanceQueue();
|
||||
|
||||
$queue = NuanceQueue::initializeNewQueue();
|
||||
} else {
|
||||
$queue = id(new NuanceQueueQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($queue_id))
|
||||
->executeOne();
|
||||
}
|
||||
|
||||
if (!$queue) {
|
||||
return new Aphront404Response();
|
||||
if (!$queue) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
}
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$title = 'TODO';
|
||||
$crumbs->addTextCrumb(
|
||||
pht('Queues'),
|
||||
$this->getApplicationURI('queue/'));
|
||||
|
||||
if ($is_new) {
|
||||
$title = pht('Create Queue');
|
||||
$crumbs->addTextCrumb(pht('Create'));
|
||||
} else {
|
||||
$title = pht('Edit %s', $queue->getName());
|
||||
$crumbs->addTextCrumb($queue->getName(), $queue->getURI());
|
||||
$crumbs->addTextCrumb(pht('Edit'));
|
||||
}
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$crumbs,
|
||||
|
|
|
@ -18,39 +18,38 @@ final class NuanceQueueQuery
|
|||
|
||||
protected function loadPage() {
|
||||
$table = new NuanceQueue();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
$conn = $table->establishConnection('r');
|
||||
|
||||
$data = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT FROM %T %Q %Q %Q',
|
||||
$conn,
|
||||
'%Q FROM %T %Q %Q %Q',
|
||||
$this->buildSelectClause($conn),
|
||||
$table->getTableName(),
|
||||
$this->buildWhereClause($conn_r),
|
||||
$this->buildOrderClause($conn_r),
|
||||
$this->buildLimitClause($conn_r));
|
||||
$this->buildWhereClause($conn),
|
||||
$this->buildOrderClause($conn),
|
||||
$this->buildLimitClause($conn));
|
||||
|
||||
return $table->loadAllFromArray($data);
|
||||
}
|
||||
|
||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
||||
$where = array();
|
||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||
$where = parent::buildWhereClauseParts($conn);
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
if ($this->ids) {
|
||||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
$conn,
|
||||
'id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids) {
|
||||
if ($this->phids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
$conn,
|
||||
'phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
final class NuanceQueue
|
||||
extends NuanceDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorApplicationTransactionInterface {
|
||||
|
||||
protected $name;
|
||||
protected $mailKey;
|
||||
|
@ -24,6 +26,10 @@ final class NuanceQueue
|
|||
NuanceQueuePHIDType::TYPECONST);
|
||||
}
|
||||
|
||||
public static function initializeNewQueue() {
|
||||
return new NuanceQueue();
|
||||
}
|
||||
|
||||
public function save() {
|
||||
if (!$this->getMailKey()) {
|
||||
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
||||
|
@ -35,6 +41,10 @@ final class NuanceQueue
|
|||
return '/nuance/queue/view/'.$this->getID().'/';
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
||||
public function getCapabilities() {
|
||||
return array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
|
@ -59,4 +69,26 @@ final class NuanceQueue
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
|
||||
public function getApplicationTransactionEditor() {
|
||||
return new NuanceQueueEditor();
|
||||
}
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionTemplate() {
|
||||
return new NuanceQueueTransaction();
|
||||
}
|
||||
|
||||
public function willRenderTimeline(
|
||||
PhabricatorApplicationTransactionView $timeline,
|
||||
AphrontRequest $request) {
|
||||
return $timeline;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue