[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/maniphest/view/ -> ManiphestTaskListView.php (source)

   1  <?php
   2  
   3  final class ManiphestTaskListView extends ManiphestView {
   4  
   5    private $tasks;
   6    private $handles;
   7    private $showBatchControls;
   8    private $showSubpriorityControls;
   9  
  10    public function setTasks(array $tasks) {
  11      assert_instances_of($tasks, 'ManiphestTask');
  12      $this->tasks = $tasks;
  13      return $this;
  14    }
  15  
  16    public function setHandles(array $handles) {
  17      assert_instances_of($handles, 'PhabricatorObjectHandle');
  18      $this->handles = $handles;
  19      return $this;
  20    }
  21  
  22    public function setShowBatchControls($show_batch_controls) {
  23      $this->showBatchControls = $show_batch_controls;
  24      return $this;
  25    }
  26  
  27    public function setShowSubpriorityControls($show_subpriority_controls) {
  28      $this->showSubpriorityControls = $show_subpriority_controls;
  29      return $this;
  30    }
  31  
  32    public function render() {
  33      $handles = $this->handles;
  34  
  35      require_celerity_resource('maniphest-task-summary-css');
  36  
  37      $list = new PHUIObjectItemListView();
  38      $list->setFlush(true);
  39  
  40      $status_map = ManiphestTaskStatus::getTaskStatusMap();
  41      $color_map = ManiphestTaskPriority::getColorMap();
  42  
  43      if ($this->showBatchControls) {
  44        Javelin::initBehavior('maniphest-list-editor');
  45      }
  46  
  47      foreach ($this->tasks as $task) {
  48        $item = new PHUIObjectItemView();
  49        $item->setObjectName('T'.$task->getID());
  50        $item->setHeader($task->getTitle());
  51        $item->setHref('/T'.$task->getID());
  52  
  53        if ($task->getOwnerPHID()) {
  54          $owner = $handles[$task->getOwnerPHID()];
  55          $item->addByline(pht('Assigned: %s', $owner->renderLink()));
  56        }
  57  
  58        $status = $task->getStatus();
  59        if ($task->isClosed()) {
  60          $item->setDisabled(true);
  61        }
  62  
  63        $item->setBarColor(idx($color_map, $task->getPriority(), 'grey'));
  64  
  65        $item->addIcon(
  66          'none',
  67          phabricator_datetime($task->getDateModified(), $this->getUser()));
  68  
  69        if ($this->showSubpriorityControls) {
  70          $item->setGrippable(true);
  71        }
  72        if ($this->showSubpriorityControls || $this->showBatchControls) {
  73          $item->addSigil('maniphest-task');
  74        }
  75  
  76        $project_handles = array_select_keys(
  77          $handles,
  78          $task->getProjectPHIDs());
  79  
  80        $item->addAttribute(
  81          id(new PHUIHandleTagListView())
  82            ->setLimit(4)
  83            ->setNoDataString(pht('No Projects'))
  84            ->setSlim(true)
  85            ->setHandles($project_handles));
  86  
  87        $item->setMetadata(
  88          array(
  89            'taskID' => $task->getID(),
  90          ));
  91  
  92        if ($this->showBatchControls) {
  93          $href = new PhutilURI('/maniphest/task/edit/'.$task->getID().'/');
  94          if (!$this->showSubpriorityControls) {
  95            $href->setQueryParam('ungrippable', 'true');
  96          }
  97          $item->addAction(
  98            id(new PHUIListItemView())
  99              ->setIcon('fa-pencil')
 100              ->addSigil('maniphest-edit-task')
 101              ->setHref($href));
 102        }
 103  
 104        $list->addItem($item);
 105      }
 106  
 107      return $list;
 108    }
 109  
 110    public static function loadTaskHandles(
 111      PhabricatorUser $viewer,
 112      array $tasks) {
 113      assert_instances_of($tasks, 'ManiphestTask');
 114  
 115      $phids = array();
 116      foreach ($tasks as $task) {
 117        $assigned_phid = $task->getOwnerPHID();
 118        if ($assigned_phid) {
 119          $phids[] = $assigned_phid;
 120        }
 121        foreach ($task->getProjectPHIDs() as $project_phid) {
 122          $phids[] = $project_phid;
 123        }
 124      }
 125  
 126      if (!$phids) {
 127        return array();
 128      }
 129  
 130      return id(new PhabricatorHandleQuery())
 131        ->setViewer($viewer)
 132        ->withPHIDs($phids)
 133        ->execute();
 134    }
 135  
 136  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1