Differential D15171 Diff 36648 src/applications/project/controller/PhabricatorProjectBoardViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectBoardViewController.php
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | if ($request->getURIData('filter')) { | ||||
| ->appendChild($filter_form->buildLayoutView()) | ->appendChild($filter_form->buildLayoutView()) | ||||
| ->setSubmitURI($board_uri) | ->setSubmitURI($board_uri) | ||||
| ->addSubmitButton(pht('Apply Filter')) | ->addSubmitButton(pht('Apply Filter')) | ||||
| ->addCancelButton($board_uri); | ->addCancelButton($board_uri); | ||||
| } | } | ||||
| $task_query = $search_engine->buildQueryFromSavedQuery($saved); | $task_query = $search_engine->buildQueryFromSavedQuery($saved); | ||||
| $select_phids = array($project->getPHID()); | |||||
| if ($project->getHasSubprojects() || $project->getHasMilestones()) { | |||||
| $descendants = id(new PhabricatorProjectQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withAncestorProjectPHIDs($select_phids) | |||||
| ->execute(); | |||||
| foreach ($descendants as $descendant) { | |||||
| $select_phids[] = $descendant->getPHID(); | |||||
| } | |||||
| } | |||||
| $tasks = $task_query | $tasks = $task_query | ||||
| ->withEdgeLogicPHIDs( | ->withEdgeLogicPHIDs( | ||||
| PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | ||||
| PhabricatorQueryConstraint::OPERATOR_AND, | PhabricatorQueryConstraint::OPERATOR_ANCESTOR, | ||||
| array($project->getPHID())) | array($select_phids)) | ||||
| ->setOrder(ManiphestTaskQuery::ORDER_PRIORITY) | ->setOrder(ManiphestTaskQuery::ORDER_PRIORITY) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->execute(); | ->execute(); | ||||
| $tasks = mpull($tasks, null, 'getPHID'); | $tasks = mpull($tasks, null, 'getPHID'); | ||||
| $board_phid = $project->getPHID(); | $board_phid = $project->getPHID(); | ||||
| $layout_engine = id(new PhabricatorBoardLayoutEngine()) | $layout_engine = id(new PhabricatorBoardLayoutEngine()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->setBoardPHIDs(array($board_phid)) | ->setBoardPHIDs(array($board_phid)) | ||||
| ->setObjectPHIDs(array_keys($tasks)) | ->setObjectPHIDs(array_keys($tasks)) | ||||
| ->executeLayout(); | ->executeLayout(); | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| foreach ($columns as $column) { | foreach ($columns as $column) { | ||||
| if (!$this->showHidden) { | if (!$this->showHidden) { | ||||
| if ($column->isHidden()) { | if ($column->isHidden()) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| $proxy = $column->getProxy(); | |||||
| if ($proxy && !$proxy->isMilestone()) { | |||||
| // TODO: For now, don't show subproject columns because we can't | |||||
| // handle tasks with multiple positions yet. | |||||
| continue; | |||||
| } | |||||
| $task_phids = $layout_engine->getColumnObjectPHIDs( | $task_phids = $layout_engine->getColumnObjectPHIDs( | ||||
| $board_phid, | $board_phid, | ||||
| $column->getPHID()); | $column->getPHID()); | ||||
| $column_tasks = array_select_keys($tasks, $task_phids); | $column_tasks = array_select_keys($tasks, $task_phids); | ||||
| // If we aren't using "natural" order, reorder the column by the original | // If we aren't using "natural" order, reorder the column by the original | ||||
| // query order. | // query order. | ||||
| if ($this->sortKey != PhabricatorProjectColumn::ORDER_NATURAL) { | if ($this->sortKey != PhabricatorProjectColumn::ORDER_NATURAL) { | ||||
| $column_tasks = array_select_keys($column_tasks, array_keys($tasks)); | $column_tasks = array_select_keys($column_tasks, array_keys($tasks)); | ||||
| } | } | ||||
| $panel = id(new PHUIWorkpanelView()) | $panel = id(new PHUIWorkpanelView()) | ||||
| ->setHeader($column->getDisplayName()) | ->setHeader($column->getDisplayName()) | ||||
| ->setSubHeader($column->getDisplayType()) | ->setSubHeader($column->getDisplayType()) | ||||
| ->addSigil('workpanel'); | ->addSigil('workpanel'); | ||||
| $header_icon = $column->getHeaderIcon(); | $header_icon = $column->getHeaderIcon(); | ||||
| if ($header_icon) { | if ($header_icon) { | ||||
| $panel->setHeaderIcon($header_icon); | $panel->setHeaderIcon($header_icon); | ||||
| } | } | ||||
| $display_class = $column->getDisplayClass(); | |||||
| if ($display_class) { | |||||
| $panel->addClass($display_class); | |||||
| } | |||||
| if ($column->isHidden()) { | if ($column->isHidden()) { | ||||
| $panel->addClass('project-panel-hidden'); | $panel->addClass('project-panel-hidden'); | ||||
| } | } | ||||
| $column_menu = $this->buildColumnMenu($project, $column); | $column_menu = $this->buildColumnMenu($project, $column); | ||||
| $panel->addHeaderAction($column_menu); | $panel->addHeaderAction($column_menu); | ||||
| $tag_id = celerity_generate_unique_node_id(); | $tag_id = celerity_generate_unique_node_id(); | ||||
| ▲ Show 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | private function buildColumnMenu( | ||||
| $can_edit = PhabricatorPolicyFilter::hasCapability( | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
| $viewer, | $viewer, | ||||
| $project, | $project, | ||||
| PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
| $column_items = array(); | $column_items = array(); | ||||
| if ($column->getProxyPHID()) { | |||||
| $default_phid = $column->getProxyPHID(); | |||||
| } else { | |||||
| $default_phid = $column->getProjectPHID(); | |||||
| } | |||||
| $column_items[] = id(new PhabricatorActionView()) | $column_items[] = id(new PhabricatorActionView()) | ||||
| ->setIcon('fa-plus') | ->setIcon('fa-plus') | ||||
| ->setName(pht('Create Task...')) | ->setName(pht('Create Task...')) | ||||
| ->setHref($this->getCreateURI()) | ->setHref($this->getCreateURI()) | ||||
| ->addSigil('column-add-task') | ->addSigil('column-add-task') | ||||
| ->setMetadata( | ->setMetadata( | ||||
| array( | array( | ||||
| 'columnPHID' => $column->getPHID(), | 'columnPHID' => $column->getPHID(), | ||||
| 'projectPHID' => $default_phid, | |||||
| )); | )); | ||||
| $batch_edit_uri = $request->getRequestURI(); | $batch_edit_uri = $request->getRequestURI(); | ||||
| $batch_edit_uri->setQueryParam('batch', $column->getID()); | $batch_edit_uri->setQueryParam('batch', $column->getID()); | ||||
| $can_batch_edit = PhabricatorPolicyFilter::hasCapability( | $can_batch_edit = PhabricatorPolicyFilter::hasCapability( | ||||
| $viewer, | $viewer, | ||||
| PhabricatorApplication::getByClass('PhabricatorManiphestApplication'), | PhabricatorApplication::getByClass('PhabricatorManiphestApplication'), | ||||
| ManiphestBulkEditCapability::CAPABILITY); | ManiphestBulkEditCapability::CAPABILITY); | ||||
| ▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
| return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
| ->setURI($board_uri); | ->setURI($board_uri); | ||||
| } else { | } else { | ||||
| return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
| ->setURI($import_uri); | ->setURI($import_uri); | ||||
| } | } | ||||
| } | } | ||||
| // TODO: Tailor this UI if the project is already a parent project. We | |||||
| // should not offer options for creating a parent project workboard, since | |||||
| // they can't have their own columns. | |||||
| $new_selector = id(new AphrontFormRadioButtonControl()) | $new_selector = id(new AphrontFormRadioButtonControl()) | ||||
| ->setLabel(pht('Columns')) | ->setLabel(pht('Columns')) | ||||
| ->setName('initialize-type') | ->setName('initialize-type') | ||||
| ->setValue('backlog-only') | ->setValue('backlog-only') | ||||
| ->addButton( | ->addButton( | ||||
| 'backlog-only', | 'backlog-only', | ||||
| pht('New Empty Board'), | pht('New Empty Board'), | ||||
| pht('Create a new board with just a backlog column.')) | pht('Create a new board with just a backlog column.')) | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||