mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-27 07:50:57 +01:00
Close pholio mocks
Summary: Fixes T4299, Add status dropdown to mock edit view Test Plan: Edit mock, close mock, thumbnail title should read (Disabled). Default mocks list should show only open mocks. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: chad, epriestley, Korvin Maniphest Tasks: T4299 Differential Revision: https://secure.phabricator.com/D9145
This commit is contained in:
parent
25f9facba6
commit
3d457a53be
10 changed files with 107 additions and 3 deletions
5
resources/sql/autopatches/20140514.pholiomockclose.sql
Normal file
5
resources/sql/autopatches/20140514.pholiomockclose.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE {$NAMESPACE}_pholio.pholio_mock
|
||||
ADD COLUMN status VARCHAR(12) NOT NULL COLLATE utf8_bin;
|
||||
|
||||
UPDATE {$NAMESPACE}_pholio.pholio_mock
|
||||
SET status = "open" WHERE status = "";
|
|
@ -8,6 +8,7 @@ final class PholioTransactionType extends PholioConstants {
|
|||
/* edits to the high level mock */
|
||||
const TYPE_NAME = 'name';
|
||||
const TYPE_DESCRIPTION = 'description';
|
||||
const TYPE_STATUS = 'status';
|
||||
|
||||
/* edits to images within the mock */
|
||||
const TYPE_IMAGE_FILE = 'image-file';
|
||||
|
|
|
@ -54,6 +54,7 @@ final class PholioMockEditController extends PholioController {
|
|||
|
||||
$v_name = $mock->getName();
|
||||
$v_desc = $mock->getDescription();
|
||||
$v_status = $mock->getStatus();
|
||||
$v_view = $mock->getViewPolicy();
|
||||
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||
$mock->getPHID());
|
||||
|
@ -63,17 +64,20 @@ final class PholioMockEditController extends PholioController {
|
|||
|
||||
$type_name = PholioTransactionType::TYPE_NAME;
|
||||
$type_desc = PholioTransactionType::TYPE_DESCRIPTION;
|
||||
$type_status = PholioTransactionType::TYPE_STATUS;
|
||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS;
|
||||
|
||||
$v_name = $request->getStr('name');
|
||||
$v_desc = $request->getStr('description');
|
||||
$v_status = $request->getStr('status');
|
||||
$v_view = $request->getStr('can_view');
|
||||
$v_cc = $request->getArr('cc');
|
||||
|
||||
$mock_xactions = array();
|
||||
$mock_xactions[$type_name] = $v_name;
|
||||
$mock_xactions[$type_desc] = $v_desc;
|
||||
$mock_xactions[$type_status] = $v_status;
|
||||
$mock_xactions[$type_view] = $v_view;
|
||||
$mock_xactions[$type_cc] = array('=' => $v_cc);
|
||||
|
||||
|
@ -298,6 +302,12 @@ final class PholioMockEditController extends PholioController {
|
|||
->setValue($v_desc)
|
||||
->setLabel(pht('Description'))
|
||||
->setUser($user))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Status'))
|
||||
->setName('status')
|
||||
->setValue($mock->getStatus())
|
||||
->setOptions($mock->getStatuses()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('CC'))
|
||||
|
|
|
@ -67,9 +67,18 @@ final class PholioMockViewController extends PholioController {
|
|||
|
||||
$title = $mock->getName();
|
||||
|
||||
if ($mock->isClosed()) {
|
||||
$header_icon = 'oh-closed';
|
||||
$header_name = pht('Closed');
|
||||
} else {
|
||||
$header_icon = 'open';
|
||||
$header_name = pht('Open');
|
||||
}
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($title)
|
||||
->setUser($user)
|
||||
->setStatus($header_icon, '', $header_name)
|
||||
->setPolicyObject($mock);
|
||||
|
||||
$actions = $this->buildActionView($mock);
|
||||
|
|
|
@ -25,6 +25,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
|
||||
$types[] = PholioTransactionType::TYPE_NAME;
|
||||
$types[] = PholioTransactionType::TYPE_DESCRIPTION;
|
||||
$types[] = PholioTransactionType::TYPE_STATUS;
|
||||
$types[] = PholioTransactionType::TYPE_INLINE;
|
||||
|
||||
$types[] = PholioTransactionType::TYPE_IMAGE_FILE;
|
||||
|
@ -45,6 +46,8 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
return $object->getName();
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
return $object->getDescription();
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
return $object->getStatus();
|
||||
case PholioTransactionType::TYPE_IMAGE_FILE:
|
||||
$images = $object->getImages();
|
||||
return mpull($images, 'getPHID');
|
||||
|
@ -88,6 +91,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
switch ($xaction->getTransactionType()) {
|
||||
case PholioTransactionType::TYPE_NAME:
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
case PholioTransactionType::TYPE_IMAGE_NAME:
|
||||
case PholioTransactionType::TYPE_IMAGE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_IMAGE_SEQUENCE:
|
||||
|
@ -196,6 +200,9 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
$object->setDescription($xaction->getNewValue());
|
||||
break;
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
$object->setStatus($xaction->getNewValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,6 +294,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
switch ($type) {
|
||||
case PholioTransactionType::TYPE_NAME:
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
return $v;
|
||||
case PholioTransactionType::TYPE_IMAGE_REPLACE:
|
||||
$u_img = $u->getNewValue();
|
||||
|
|
|
@ -42,6 +42,10 @@ final class PholioPHIDTypeMock extends PhabricatorPHIDType {
|
|||
$handle->setURI("/M{$id}");
|
||||
$handle->setName("M{$id}");
|
||||
$handle->setFullName("M{$id}: {$name}");
|
||||
|
||||
if ($mock->isClosed()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ final class PholioMockQuery
|
|||
private $ids;
|
||||
private $phids;
|
||||
private $authorPHIDs;
|
||||
private $statuses;
|
||||
|
||||
private $needCoverFiles;
|
||||
private $needImages;
|
||||
|
@ -30,6 +31,11 @@ final class PholioMockQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withStatuses(array $statuses) {
|
||||
$this->statuses = $statuses;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needCoverFiles($need_cover_files) {
|
||||
$this->needCoverFiles = $need_cover_files;
|
||||
return $this;
|
||||
|
@ -105,6 +111,13 @@ final class PholioMockQuery
|
|||
$this->authorPHIDs);
|
||||
}
|
||||
|
||||
if ($this->statuses) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'status IN (%Ls)',
|
||||
$this->statuses);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ final class PholioMockSearchEngine
|
|||
$saved->setParameter(
|
||||
'authorPHIDs',
|
||||
$this->readUsersFromRequest($request, 'authors'));
|
||||
$saved->setParameter(
|
||||
'statuses',
|
||||
$request->getStrList('status'));
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
@ -21,7 +24,8 @@ final class PholioMockSearchEngine
|
|||
->needCoverFiles(true)
|
||||
->needImages(true)
|
||||
->needTokenCounts(true)
|
||||
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()));
|
||||
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
|
||||
->withStatuses($saved->getParameter('statuses', array()));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
@ -36,13 +40,27 @@ final class PholioMockSearchEngine
|
|||
->withPHIDs($phids)
|
||||
->execute();
|
||||
|
||||
$statuses = array(
|
||||
''=>pht('Any Status'),
|
||||
'closed'=>pht('Closed'),
|
||||
'open'=>pht('Open'));
|
||||
|
||||
$status = $saved_query->getParameter('statuses', array());
|
||||
$status = head($status);
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/users/')
|
||||
->setName('authors')
|
||||
->setLabel(pht('Authors'))
|
||||
->setValue($author_handles));
|
||||
->setValue($author_handles))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Status'))
|
||||
->setName('status')
|
||||
->setOptions($statuses)
|
||||
->setValue($status));
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
|
@ -51,6 +69,7 @@ final class PholioMockSearchEngine
|
|||
|
||||
public function getBuiltinQueryNames() {
|
||||
$names = array(
|
||||
'open' => pht('Open Mocks'),
|
||||
'all' => pht('All Mocks'),
|
||||
);
|
||||
|
||||
|
@ -67,6 +86,10 @@ final class PholioMockSearchEngine
|
|||
$query->setQueryKey($query_key);
|
||||
|
||||
switch ($query_key) {
|
||||
case 'open':
|
||||
return $query->setParameter(
|
||||
'statuses',
|
||||
array('open'));
|
||||
case 'all':
|
||||
return $query;
|
||||
case 'authored':
|
||||
|
@ -94,8 +117,14 @@ final class PholioMockSearchEngine
|
|||
|
||||
$board = new PHUIPinboardView();
|
||||
foreach ($mocks as $mock) {
|
||||
|
||||
$header = 'M'.$mock->getID().' '.$mock->getName();
|
||||
if ($mock->isClosed()) {
|
||||
$header = pht('%s (Closed)', $header);
|
||||
}
|
||||
|
||||
$item = id(new PHUIPinboardItemView())
|
||||
->setHeader('M'.$mock->getID().' '.$mock->getName())
|
||||
->setHeader($header)
|
||||
->setURI('/M'.$mock->getID())
|
||||
->setImageURI($mock->getCoverFile()->getThumb280x210URI())
|
||||
->setImageSize(280, 210)
|
||||
|
|
|
@ -19,6 +19,7 @@ final class PholioMock extends PholioDAO
|
|||
protected $description;
|
||||
protected $coverPHID;
|
||||
protected $mailKey;
|
||||
protected $status;
|
||||
|
||||
private $images = self::ATTACHABLE;
|
||||
private $allImages = self::ATTACHABLE;
|
||||
|
@ -129,6 +130,17 @@ final class PholioMock extends PholioDAO
|
|||
return $history;
|
||||
}
|
||||
|
||||
public function getStatuses() {
|
||||
$options = array();
|
||||
$options['closed'] = 'Closed';
|
||||
$options['open'] = 'Open';
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function isClosed() {
|
||||
return ($this->getStatus() == 'closed');
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
return 'fa-comment';
|
||||
case PholioTransactionType::TYPE_NAME:
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
case PholioTransactionType::TYPE_IMAGE_NAME:
|
||||
case PholioTransactionType::TYPE_IMAGE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_IMAGE_SEQUENCE:
|
||||
|
@ -105,6 +106,11 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
"%s updated the mock's description.",
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
return pht(
|
||||
"%s updated the mock's status.",
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case PholioTransactionType::TYPE_INLINE:
|
||||
$count = 1;
|
||||
foreach ($this->getTransactionGroup() as $xaction) {
|
||||
|
@ -207,6 +213,12 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
return pht(
|
||||
'%s updated the status for %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
case PholioTransactionType::TYPE_INLINE:
|
||||
return pht(
|
||||
'%s added an inline comment to %s.',
|
||||
|
@ -299,6 +311,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
return PhabricatorTransactions::COLOR_GREEN;
|
||||
}
|
||||
case PholioTransactionType::TYPE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_STATUS:
|
||||
case PholioTransactionType::TYPE_IMAGE_NAME:
|
||||
case PholioTransactionType::TYPE_IMAGE_DESCRIPTION:
|
||||
case PholioTransactionType::TYPE_IMAGE_SEQUENCE:
|
||||
|
|
Loading…
Reference in a new issue