Christopher Johnson (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/185623
Change subject: adds fieldIndex criterion to taskpoints query
......................................................................
adds fieldIndex criterion to taskpoints query
reverts conditional check in SprintPoints
applied in Change-Id: Ib7b91fd86774bc5300cecf94e445cb33950a576e
Change-Id: I072e57eaefe42d0e34f367461d43243a158721f1
---
A src/controller/SprintProjectProfileController.php
A src/controller/SprintProjectViewController.php
M src/query/SprintQuery.php
M src/util/SprintPoints.php
4 files changed, 267 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint
refs/changes/23/185623/1
diff --git a/src/controller/SprintProjectProfileController.php
b/src/controller/SprintProjectProfileController.php
new file mode 100644
index 0000000..208c23e
--- /dev/null
+++ b/src/controller/SprintProjectProfileController.php
@@ -0,0 +1,256 @@
+<?php
+
+final class PhabricatorProjectProfileController
+ extends PhabricatorProjectController {
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $user = $request->getUser();
+
+ $query = id(new PhabricatorProjectQuery())
+ ->setViewer($user)
+ ->needMembers(true)
+ ->needWatchers(true)
+ ->needImages(true)
+ ->needSlugs(true);
+ $id = $request->getURIData('id');
+ $slug = $request->getURIData('slug');
+ if ($slug) {
+ $query->withSlugs(array($slug));
+ } else {
+ $query->withIDs(array($id));
+ }
+ $project = $query->executeOne();
+ if (!$project) {
+ return new Aphront404Response();
+ }
+ if ($slug && $slug != $project->getPrimarySlug()) {
+ return id(new AphrontRedirectResponse())
+ ->setURI('/tag/'.$project->getPrimarySlug().'/');
+ }
+
+ $picture = $project->getProfileImageURI();
+ require_celerity_resource('phabricator-profile-css');
+ $tasks = $this->renderTasksPage($project);
+ $content = phutil_tag_div('phabricator-project-layout', $tasks);
+
+ $phid = $project->getPHID();
+ $create_uri = '/maniphest/task/create/?projects='.$phid;
+ $icon_new = id(new PHUIIconView())
+ ->setIconFont('fa-plus');
+ $button_add = id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText(pht('New Task'))
+ ->setHref($create_uri)
+ ->setIcon($icon_new);
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader($project->getName())
+ ->setUser($user)
+ ->setPolicyObject($project)
+ ->setImage($picture)
+ ->addActionLink($button_add);
+
+ if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) {
+ $header->setStatus('fa-check', 'bluegrey', pht('Active'));
+ } else {
+ $header->setStatus('fa-ban', 'red', pht('Archived'));
+ }
+
+ $actions = $this->buildActionListView($project);
+ $properties = $this->buildPropertyListView($project, $actions);
+
+ $object_box = id(new PHUIObjectBoxView())
+ ->setHeader($header)
+ ->addPropertyList($properties);
+
+ $nav = $this->buildIconNavView($project);
+ $nav->selectFilter("profile/{$id}/");
+ $nav->appendChild($object_box);
+ $nav->appendChild($content);
+
+ return $this->buildApplicationPage(
+ array(
+ $nav,
+ ),
+ array(
+ 'title' => $project->getName(),
+ ));
+ }
+
+ private function renderTasksPage(PhabricatorProject $project) {
+
+ $user = $this->getRequest()->getUser();
+ $limit = 50;
+
+ $query = id(new ManiphestTaskQuery())
+ ->setViewer($user)
+ ->withAnyProjects(array($project->getPHID()))
+ ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())
+ ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
+ ->needProjectPHIDs(true)
+ ->setLimit(($limit + 1));
+ $tasks = $query->execute();
+ $count = count($tasks);
+ if ($count == ($limit + 1)) {
+ array_pop($tasks);
+ }
+
+ $phids = mpull($tasks, 'getOwnerPHID');
+ $phids = array_merge(
+ $phids,
+ array_mergev(mpull($tasks, 'getProjectPHIDs')));
+ $phids = array_filter($phids);
+ $handles = $this->loadViewerHandles($phids);
+
+ $task_list = new ManiphestTaskListView();
+ $task_list->setUser($user);
+ $task_list->setTasks($tasks);
+ $task_list->setHandles($handles);
+ $task_list->setNoDataString(pht('This project has no open tasks.'));
+
+ $phid = $project->getPHID();
+ $view_uri = urisprintf(
+ '/maniphest/?statuses=%s&allProjects=%s#R',
+ implode(',', ManiphestTaskStatus::getOpenStatusConstants()),
+ $phid);
+ $icon = id(new PHUIIconView())
+ ->setIconFont('fa-search');
+ $button_view = id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText(pht('View Query'))
+ ->setHref($view_uri)
+ ->setIcon($icon);
+
+ $header = id(new PHUIHeaderView())
+ ->addActionLink($button_view);
+
+ if ($count > $limit) {
+ $header->setHeader(pht('Highest Priority (some)'));
+ } else {
+ $header->setHeader(pht('Highest Priority (all)'));
+ }
+
+ $content = id(new PHUIObjectBoxView())
+ ->setHeader($header)
+ ->appendChild($task_list);
+
+ return $content;
+ }
+
+ private function buildActionListView(PhabricatorProject $project) {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $id = $project->getID();
+
+ $view = id(new PhabricatorActionListView())
+ ->setUser($viewer)
+ ->setObject($project)
+ ->setObjectURI($request->getRequestURI());
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $project,
+ PhabricatorPolicyCapability::CAN_EDIT);
+
+ $view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Edit Project'))
+ ->setIcon('fa-pencil')
+ ->setHref($this->getApplicationURI("edit/{$id}/")));
+
+
+ $action = null;
+ if (!$project->isUserMember($viewer->getPHID())) {
+ $can_join = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $project,
+ PhabricatorPolicyCapability::CAN_JOIN);
+
+ $action = id(new PhabricatorActionView())
+ ->setUser($viewer)
+ ->setRenderAsForm(true)
+ ->setHref('/project/update/'.$project->getID().'/join/')
+ ->setIcon('fa-plus')
+ ->setDisabled(!$can_join)
+ ->setName(pht('Join Project'));
+ $view->addAction($action);
+ } else {
+ $action = id(new PhabricatorActionView())
+ ->setWorkflow(true)
+ ->setHref('/project/update/'.$project->getID().'/leave/')
+ ->setIcon('fa-times')
+ ->setName(pht('Leave Project...'));
+ $view->addAction($action);
+
+ if (!$project->isUserWatcher($viewer->getPHID())) {
+ $action = id(new PhabricatorActionView())
+ ->setWorkflow(true)
+ ->setHref('/project/watch/'.$project->getID().'/')
+ ->setIcon('fa-eye')
+ ->setName(pht('Watch Project'));
+ $view->addAction($action);
+ } else {
+ $action = id(new PhabricatorActionView())
+ ->setWorkflow(true)
+ ->setHref('/project/unwatch/'.$project->getID().'/')
+ ->setIcon('fa-eye-slash')
+ ->setName(pht('Unwatch Project'));
+ $view->addAction($action);
+ }
+ }
+
+ return $view;
+ }
+
+ private function buildPropertyListView(
+ PhabricatorProject $project,
+ PhabricatorActionListView $actions) {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $this->loadHandles(
+ array_merge(
+ $project->getMemberPHIDs(),
+ $project->getWatcherPHIDs()));
+
+ $view = id(new PHUIPropertyListView())
+ ->setUser($viewer)
+ ->setObject($project)
+ ->setActionList($actions);
+
+ $hashtags = array();
+ foreach ($project->getSlugs() as $slug) {
+ $hashtags[] = id(new PHUITagView())
+ ->setType(PHUITagView::TYPE_OBJECT)
+ ->setName('#'.$slug->getSlug());
+ }
+
+ $view->addProperty(pht('Hashtags'), phutil_implode_html(' ', $hashtags));
+
+ $view->addProperty(
+ pht('Members'),
+ $project->getMemberPHIDs()
+ ? $this->renderHandlesForPHIDs($project->getMemberPHIDs(), ',')
+ : phutil_tag('em', array(), pht('None')));
+
+ $view->addProperty(
+ pht('Watchers'),
+ $project->getWatcherPHIDs()
+ ? $this->renderHandlesForPHIDs($project->getWatcherPHIDs(), ',')
+ : phutil_tag('em', array(), pht('None')));
+
+ $field_list = PhabricatorCustomField::getObjectFields(
+ $project,
+ PhabricatorCustomField::ROLE_VIEW);
+ $field_list->appendFieldsToPropertyList($project, $viewer, $view);
+
+ return $view;
+ }
+
+
+}
diff --git a/src/controller/SprintProjectViewController.php
b/src/controller/SprintProjectViewController.php
new file mode 100644
index 0000000..18fa668
--- /dev/null
+++ b/src/controller/SprintProjectViewController.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: christopher_johnson
+ * Date: 17/01/15
+ * Time: 08:29
+ */
\ No newline at end of file
diff --git a/src/query/SprintQuery.php b/src/query/SprintQuery.php
index 9275abc..e627eab 100644
--- a/src/query/SprintQuery.php
+++ b/src/query/SprintQuery.php
@@ -167,9 +167,11 @@
$task_dao = new ManiphestCustomFieldStorage();
$data = queryfx_all(
$this->getCustomFieldConn(),
- 'SELECT f.* FROM %T f %Q',
+ 'SELECT f.* FROM %T f %Q
+ WHERE fieldIndex = %s',
$this->getCustomFieldObj()->getTableName(),
- $this->getCustomFieldJoins());
+ $this->getCustomFieldJoins(),
+ SprintConstants::CUSTOMFIELD_INDEX);
$task_data = $task_dao->loadAllFromArray($data);
return $task_data;
diff --git a/src/util/SprintPoints.php b/src/util/SprintPoints.php
index dcd3b51..2bb457a 100644
--- a/src/util/SprintPoints.php
+++ b/src/util/SprintPoints.php
@@ -23,9 +23,7 @@
if (!empty($taskpoints)) {
foreach ($taskpoints as $key=>$value) {
if ($key == $task_phid) {
- if ($value->getfieldIndex() == SprintConstants::CUSTOMFIELD_INDEX) {
$points = $value->getfieldValue();
- }
}
}
if (!isset($points)) {
--
To view, visit https://gerrit.wikimedia.org/r/185623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I072e57eaefe42d0e34f367461d43243a158721f1
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/extensions/Sprint
Gerrit-Branch: master
Gerrit-Owner: Christopher Johnson (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits