Differential D20269 Diff 48404 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 608 Lines • ▼ Show 20 Lines | foreach ($visible_columns as $column_phid => $column) { | ||||
| $all_tasks[$object_phid] = $task; | $all_tasks[$object_phid] = $task; | ||||
| } | } | ||||
| $panel->setCards($cards); | $panel->setCards($cards); | ||||
| $board->addPanel($panel); | $board->addPanel($panel); | ||||
| } | } | ||||
| // It's possible for tasks to have an invalid/unknown priority in the | $order_key = $this->sortKey; | ||||
| // database. We still want to generate a header for these tasks so we | |||||
| // don't break the workboard. | |||||
| $priorities = | |||||
| ManiphestTaskPriority::getTaskPriorityMap() + | |||||
| mpull($all_tasks, null, 'getPriority'); | |||||
| $priorities = array_keys($priorities); | |||||
| $headers = array(); | |||||
| foreach ($priorities as $priority) { | |||||
| $header_key = sprintf('priority(%s)', $priority); | |||||
| $priority_name = ManiphestTaskPriority::getTaskPriorityName($priority); | |||||
| $priority_color = ManiphestTaskPriority::getTaskPriorityColor($priority); | |||||
| $priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($priority); | |||||
| $icon_view = id(new PHUIIconView()) | $ordering_map = PhabricatorProjectColumnOrder::getAllOrders(); | ||||
| ->setIcon("{$priority_icon} {$priority_color}"); | $ordering = id(clone $ordering_map[$order_key]) | ||||
| ->setViewer($viewer); | |||||
| $template = phutil_tag( | $headers = $ordering->getHeadersForObjects($all_tasks); | ||||
| 'li', | $headers = mpull($headers, 'toDictionary'); | ||||
| array( | |||||
| 'class' => 'workboard-group-header', | |||||
| ), | |||||
| array( | |||||
| $icon_view, | |||||
| $priority_name, | |||||
| )); | |||||
| $headers[] = array( | $vectors = $ordering->getSortVectorsForObjects($all_tasks); | ||||
| 'order' => PhabricatorProjectColumn::ORDER_PRIORITY, | $vector_map = array(); | ||||
| 'key' => $header_key, | foreach ($vectors as $task_phid => $vector) { | ||||
| 'template' => hsprintf('%s', $template), | $vector_map[$task_phid][$order_key] = $vector; | ||||
| 'vector' => array( | |||||
| (int)-$priority, | |||||
| PhabricatorProjectColumn::NODETYPE_HEADER, | |||||
| ), | |||||
| 'editProperties' => array( | |||||
| PhabricatorProjectColumn::ORDER_PRIORITY => (int)$priority, | |||||
| ), | |||||
| ); | |||||
| } | } | ||||
| $header_keys = $ordering->getHeaderKeysForObjects($all_tasks); | |||||
| $properties = array(); | |||||
| $behavior_config = array( | $behavior_config = array( | ||||
| 'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'), | 'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'), | ||||
| 'uploadURI' => '/file/dropupload/', | 'uploadURI' => '/file/dropupload/', | ||||
| 'coverURI' => $this->getApplicationURI('cover/'), | 'coverURI' => $this->getApplicationURI('cover/'), | ||||
| 'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(), | 'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(), | ||||
| 'pointsEnabled' => ManiphestTaskPoints::getIsEnabled(), | 'pointsEnabled' => ManiphestTaskPoints::getIsEnabled(), | ||||
| 'boardPHID' => $project->getPHID(), | 'boardPHID' => $project->getPHID(), | ||||
| 'order' => $this->sortKey, | 'order' => $this->sortKey, | ||||
| 'headers' => $headers, | 'headers' => $headers, | ||||
| 'headerKeys' => $header_keys, | |||||
| 'templateMap' => $templates, | 'templateMap' => $templates, | ||||
| 'columnMaps' => $column_maps, | 'columnMaps' => $column_maps, | ||||
| 'orderMaps' => mpull($all_tasks, 'getWorkboardOrderVectors'), | 'orderMaps' => $vector_map, | ||||
| 'propertyMaps' => mpull($all_tasks, 'getWorkboardProperties'), | 'propertyMaps' => $properties, | ||||
| 'boardID' => $board_id, | 'boardID' => $board_id, | ||||
| 'projectPHID' => $project->getPHID(), | 'projectPHID' => $project->getPHID(), | ||||
| ); | ); | ||||
| $this->initBehavior('project-boards', $behavior_config); | $this->initBehavior('project-boards', $behavior_config); | ||||
| $sort_menu = $this->buildSortMenu( | $sort_menu = $this->buildSortMenu( | ||||
| $viewer, | $viewer, | ||||
| $project, | $project, | ||||
| $this->sortKey); | $this->sortKey, | ||||
| $ordering_map); | |||||
| $filter_menu = $this->buildFilterMenu( | $filter_menu = $this->buildFilterMenu( | ||||
| $viewer, | $viewer, | ||||
| $project, | $project, | ||||
| $custom_query, | $custom_query, | ||||
| $search_engine, | $search_engine, | ||||
| $query_key); | $query_key); | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | final class PhabricatorProjectBoardViewController | ||||
| private function getDefaultSort(PhabricatorProject $project) { | private function getDefaultSort(PhabricatorProject $project) { | ||||
| $default_sort = $project->getDefaultWorkboardSort(); | $default_sort = $project->getDefaultWorkboardSort(); | ||||
| if ($this->isValidSort($default_sort)) { | if ($this->isValidSort($default_sort)) { | ||||
| return $default_sort; | return $default_sort; | ||||
| } | } | ||||
| return PhabricatorProjectColumn::DEFAULT_ORDER; | return PhabricatorProjectColumnNaturalOrder::ORDERKEY; | ||||
| } | } | ||||
| private function getDefaultFilter(PhabricatorProject $project) { | private function getDefaultFilter(PhabricatorProject $project) { | ||||
| $default_filter = $project->getDefaultWorkboardFilter(); | $default_filter = $project->getDefaultWorkboardFilter(); | ||||
| if (strlen($default_filter)) { | if (strlen($default_filter)) { | ||||
| return $default_filter; | return $default_filter; | ||||
| } | } | ||||
| return 'open'; | return 'open'; | ||||
| } | } | ||||
| private function isValidSort($sort) { | private function isValidSort($sort) { | ||||
| switch ($sort) { | $map = PhabricatorProjectColumnOrder::getAllOrders(); | ||||
| case PhabricatorProjectColumn::ORDER_NATURAL: | return isset($map[$sort]); | ||||
| case PhabricatorProjectColumn::ORDER_PRIORITY: | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | } | ||||
| private function buildSortMenu( | private function buildSortMenu( | ||||
| PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
| PhabricatorProject $project, | PhabricatorProject $project, | ||||
| $sort_key) { | $sort_key, | ||||
| array $ordering_map) { | |||||
| $sort_icon = id(new PHUIIconView()) | |||||
| ->setIcon('fa-sort-amount-asc bluegrey'); | |||||
| $named = array( | |||||
| PhabricatorProjectColumn::ORDER_NATURAL => pht('Natural'), | |||||
| PhabricatorProjectColumn::ORDER_PRIORITY => pht('Sort by Priority'), | |||||
| ); | |||||
| $base_uri = $this->getURIWithState(); | $base_uri = $this->getURIWithState(); | ||||
| $items = array(); | $items = array(); | ||||
| foreach ($named as $key => $name) { | foreach ($ordering_map as $key => $ordering) { | ||||
| $is_selected = ($key == $sort_key); | // TODO: It would be desirable to build a real "PHUIIconView" here, but | ||||
| // the pathway for threading that through all the view classes ends up | |||||
| // being fairly complex, since some callers read the icon out of other | |||||
| // views. For now, just stick with a string. | |||||
| $ordering_icon = $ordering->getMenuIconIcon(); | |||||
| $ordering_name = $ordering->getDisplayName(); | |||||
| $is_selected = ($key === $sort_key); | |||||
| if ($is_selected) { | if ($is_selected) { | ||||
| $active_order = $name; | $active_name = $ordering_name; | ||||
| $active_icon = $ordering_icon; | |||||
| } | } | ||||
| $item = id(new PhabricatorActionView()) | $item = id(new PhabricatorActionView()) | ||||
| ->setIcon('fa-sort-amount-asc') | ->setIcon($ordering_icon) | ||||
| ->setSelected($is_selected) | ->setSelected($is_selected) | ||||
| ->setName($name); | ->setName($ordering_name); | ||||
| $uri = $base_uri->alter('order', $key); | $uri = $base_uri->alter('order', $key); | ||||
| $item->setHref($uri); | $item->setHref($uri); | ||||
| $items[] = $item; | $items[] = $item; | ||||
| } | } | ||||
| $id = $project->getID(); | $id = $project->getID(); | ||||
| Show All 16 Lines | private function buildSortMenu( | ||||
| $sort_menu = id(new PhabricatorActionListView()) | $sort_menu = id(new PhabricatorActionListView()) | ||||
| ->setUser($viewer); | ->setUser($viewer); | ||||
| foreach ($items as $item) { | foreach ($items as $item) { | ||||
| $sort_menu->addAction($item); | $sort_menu->addAction($item); | ||||
| } | } | ||||
| $sort_button = id(new PHUIListItemView()) | $sort_button = id(new PHUIListItemView()) | ||||
| ->setName($active_order) | ->setName($active_name) | ||||
| ->setIcon('fa-sort-amount-asc') | ->setIcon($active_icon) | ||||
| ->setHref('#') | ->setHref('#') | ||||
| ->addSigil('boards-dropdown-menu') | ->addSigil('boards-dropdown-menu') | ||||
| ->setMetadata( | ->setMetadata( | ||||
| array( | array( | ||||
| 'items' => hsprintf('%s', $sort_menu), | 'items' => hsprintf('%s', $sort_menu), | ||||
| )); | )); | ||||
| return $sort_button; | return $sort_button; | ||||
| ▲ Show 20 Lines • Show All 552 Lines • Show Last 20 Lines | |||||