Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/storage/PhabricatorProjectColumn.php
Show All 11 Lines | final class PhabricatorProjectColumn | ||||
const DEFAULT_ORDER = 'natural'; | const DEFAULT_ORDER = 'natural'; | ||||
const ORDER_NATURAL = 'natural'; | const ORDER_NATURAL = 'natural'; | ||||
const ORDER_PRIORITY = 'priority'; | const ORDER_PRIORITY = 'priority'; | ||||
protected $name; | protected $name; | ||||
protected $status; | protected $status; | ||||
protected $projectPHID; | protected $projectPHID; | ||||
protected $proxyPHID; | |||||
protected $sequence; | protected $sequence; | ||||
protected $properties = array(); | protected $properties = array(); | ||||
private $project = self::ATTACHABLE; | private $project = self::ATTACHABLE; | ||||
private $proxy = self::ATTACHABLE; | |||||
public static function initializeNewColumn(PhabricatorUser $user) { | public static function initializeNewColumn(PhabricatorUser $user) { | ||||
return id(new PhabricatorProjectColumn()) | return id(new PhabricatorProjectColumn()) | ||||
->setName('') | ->setName('') | ||||
->setStatus(self::STATUS_ACTIVE); | ->setStatus(self::STATUS_ACTIVE); | ||||
} | } | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
'properties' => self::SERIALIZATION_JSON, | 'properties' => self::SERIALIZATION_JSON, | ||||
), | ), | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'name' => 'text255', | 'name' => 'text255', | ||||
'status' => 'uint32', | 'status' => 'uint32', | ||||
'sequence' => 'uint32', | 'sequence' => 'uint32', | ||||
'proxyPHID' => 'phid?', | |||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_status' => array( | 'key_status' => array( | ||||
'columns' => array('projectPHID', 'status', 'sequence'), | 'columns' => array('projectPHID', 'status', 'sequence'), | ||||
), | ), | ||||
'key_sequence' => array( | 'key_sequence' => array( | ||||
'columns' => array('projectPHID', 'sequence'), | 'columns' => array('projectPHID', 'sequence'), | ||||
), | ), | ||||
'key_proxy' => array( | |||||
'columns' => array('projectPHID', 'proxyPHID'), | |||||
'unique' => true, | |||||
), | |||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
PhabricatorProjectColumnPHIDType::TYPECONST); | PhabricatorProjectColumnPHIDType::TYPECONST); | ||||
} | } | ||||
public function attachProject(PhabricatorProject $project) { | public function attachProject(PhabricatorProject $project) { | ||||
$this->project = $project; | $this->project = $project; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getProject() { | public function getProject() { | ||||
return $this->assertAttached($this->project); | return $this->assertAttached($this->project); | ||||
} | } | ||||
public function attachProxy($proxy) { | |||||
$this->proxy = $proxy; | |||||
return $this; | |||||
} | |||||
public function getProxy() { | |||||
return $this->assertAttached($this->proxy); | |||||
} | |||||
public function isDefaultColumn() { | public function isDefaultColumn() { | ||||
return (bool)$this->getProperty('isDefault'); | return (bool)$this->getProperty('isDefault'); | ||||
} | } | ||||
public function isHidden() { | public function isHidden() { | ||||
return ($this->getStatus() == self::STATUS_HIDDEN); | return ($this->getStatus() == self::STATUS_HIDDEN); | ||||
} | } | ||||
public function getDisplayName() { | public function getDisplayName() { | ||||
$proxy = $this->getProxy(); | |||||
if ($proxy) { | |||||
return $proxy->getProxyColumnName(); | |||||
} | |||||
$name = $this->getName(); | $name = $this->getName(); | ||||
if (strlen($name)) { | if (strlen($name)) { | ||||
return $name; | return $name; | ||||
} | } | ||||
if ($this->isDefaultColumn()) { | if ($this->isDefaultColumn()) { | ||||
return pht('Backlog'); | return pht('Backlog'); | ||||
} | } | ||||
return pht('Unnamed Column'); | return pht('Unnamed Column'); | ||||
} | } | ||||
public function getDisplayType() { | public function getDisplayType() { | ||||
if ($this->isDefaultColumn()) { | if ($this->isDefaultColumn()) { | ||||
return pht('(Default)'); | return pht('(Default)'); | ||||
} | } | ||||
if ($this->isHidden()) { | if ($this->isHidden()) { | ||||
return pht('(Hidden)'); | return pht('(Hidden)'); | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
public function getDisplayClass() { | |||||
$proxy = $this->getProxy(); | |||||
if ($proxy) { | |||||
return $proxy->getProxyColumnClass(); | |||||
} | |||||
return null; | |||||
} | |||||
public function getHeaderIcon() { | public function getHeaderIcon() { | ||||
$icon = null; | $proxy = $this->getProxy(); | ||||
if ($proxy) { | |||||
return $proxy->getProxyColumnIcon(); | |||||
} | |||||
if ($this->isHidden()) { | if ($this->isHidden()) { | ||||
$icon = 'fa-eye-slash'; | return 'fa-eye-slash'; | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
public function getProperty($key, $default = null) { | public function getProperty($key, $default = null) { | ||||
return idx($this->properties, $key, $default); | return idx($this->properties, $key, $default); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |