Page MenuHomePhabricator

D9145.id21845.diff
No OneTemporary

D9145.id21845.diff

diff --git a/resources/sql/autopatches/20140514.pholiomockclose.sql b/resources/sql/autopatches/20140514.pholiomockclose.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140514.pholiomockclose.sql
@@ -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 = "";
diff --git a/src/applications/pholio/constants/PholioTransactionType.php b/src/applications/pholio/constants/PholioTransactionType.php
--- a/src/applications/pholio/constants/PholioTransactionType.php
+++ b/src/applications/pholio/constants/PholioTransactionType.php
@@ -8,6 +8,7 @@
/* 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';
diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php
--- a/src/applications/pholio/controller/PholioMockEditController.php
+++ b/src/applications/pholio/controller/PholioMockEditController.php
@@ -54,6 +54,7 @@
$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 @@
$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);
@@ -299,6 +303,12 @@
->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'))
->setName('cc')
diff --git a/src/applications/pholio/controller/PholioMockViewController.php b/src/applications/pholio/controller/PholioMockViewController.php
--- a/src/applications/pholio/controller/PholioMockViewController.php
+++ b/src/applications/pholio/controller/PholioMockViewController.php
@@ -67,9 +67,18 @@
$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);
diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php
--- a/src/applications/pholio/editor/PholioMockEditor.php
+++ b/src/applications/pholio/editor/PholioMockEditor.php
@@ -25,6 +25,7 @@
$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 @@
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 @@
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 @@
case PholioTransactionType::TYPE_DESCRIPTION:
$object->setDescription($xaction->getNewValue());
break;
+ case PholioTransactionType::TYPE_STATUS:
+ $object->setStatus($xaction->getNewValue());
+ break;
}
}
@@ -287,6 +294,7 @@
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();
diff --git a/src/applications/pholio/phid/PholioPHIDTypeMock.php b/src/applications/pholio/phid/PholioPHIDTypeMock.php
--- a/src/applications/pholio/phid/PholioPHIDTypeMock.php
+++ b/src/applications/pholio/phid/PholioPHIDTypeMock.php
@@ -42,6 +42,10 @@
$handle->setURI("/M{$id}");
$handle->setName("M{$id}");
$handle->setFullName("M{$id}: {$name}");
+
+ if ($mock->isClosed()) {
+ $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
+ }
}
}
diff --git a/src/applications/pholio/query/PholioMockQuery.php b/src/applications/pholio/query/PholioMockQuery.php
--- a/src/applications/pholio/query/PholioMockQuery.php
+++ b/src/applications/pholio/query/PholioMockQuery.php
@@ -9,6 +9,7 @@
private $ids;
private $phids;
private $authorPHIDs;
+ private $statuses;
private $needCoverFiles;
private $needImages;
@@ -30,6 +31,11 @@
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 @@
$this->authorPHIDs);
}
+ if ($this->statuses) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'status IN (%Ls)',
+ $this->statuses);
+ }
+
return $this->formatWhereClause($where);
}
diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php
--- a/src/applications/pholio/query/PholioMockSearchEngine.php
+++ b/src/applications/pholio/query/PholioMockSearchEngine.php
@@ -12,6 +12,9 @@
$saved->setParameter(
'authorPHIDs',
$this->readUsersFromRequest($request, 'authors'));
+ $saved->setParameter(
+ 'statuses',
+ $request->getStrList('status'));
return $saved;
}
@@ -21,7 +24,8 @@
->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 @@
->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 @@
public function getBuiltinQueryNames() {
$names = array(
+ 'open' => pht('Open Mocks'),
'all' => pht('All Mocks'),
);
@@ -67,6 +86,10 @@
$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 @@
$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)
diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php
--- a/src/applications/pholio/storage/PholioMock.php
+++ b/src/applications/pholio/storage/PholioMock.php
@@ -19,6 +19,7 @@
protected $description;
protected $coverPHID;
protected $mailKey;
+ protected $status;
private $images = self::ATTACHABLE;
private $allImages = self::ATTACHABLE;
@@ -129,6 +130,17 @@
return $history;
}
+ public function getStatuses() {
+ $options = array();
+ $options['closed'] = 'Closed';
+ $options['open'] = 'Open';
+ return $options;
+ }
+
+ public function isClosed() {
+ return ($this->getStatus() == 'closed');
+ }
+
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
diff --git a/src/applications/pholio/storage/PholioTransaction.php b/src/applications/pholio/storage/PholioTransaction.php
--- a/src/applications/pholio/storage/PholioTransaction.php
+++ b/src/applications/pholio/storage/PholioTransaction.php
@@ -66,6 +66,7 @@
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 @@
"%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 @@
$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 @@
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:

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 28, 7:44 PM (1 w, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7690788
Default Alt Text
D9145.id21845.diff (11 KB)

Event Timeline