mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 19:52:44 +01:00
7a315780b4
Summary: Ref T4788. When closing a task as a duplicate of another task, you can only select one task, since it doesn't really make sense to merge one task into several other tasks (this operation is //possible//, but probably not what anyone ever wants to do, I think?). Make the UI understand this: after you select a task, disable all of the "select" buttons in the UI to make this clear. Test Plan: - Used "Close as Duplicate", only allowed to select 1 task. - Used other editors like "Merge Duplicates In", allowed to select lots of tasks. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4788 Differential Revision: https://secure.phabricator.com/D16203
123 lines
2.9 KiB
PHP
123 lines
2.9 KiB
PHP
<?php
|
|
|
|
abstract class PhabricatorObjectRelationship extends Phobject {
|
|
|
|
private $viewer;
|
|
private $contentSource;
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
$this->viewer = $viewer;
|
|
return $this;
|
|
}
|
|
|
|
public function getViewer() {
|
|
return $this->viewer;
|
|
}
|
|
|
|
public function setContentSource(PhabricatorContentSource $content_source) {
|
|
$this->contentSource = $content_source;
|
|
return $this;
|
|
}
|
|
|
|
public function getContentSource() {
|
|
return $this->contentSource;
|
|
}
|
|
|
|
final public function getRelationshipConstant() {
|
|
return $this->getPhobjectClassConstant('RELATIONSHIPKEY');
|
|
}
|
|
|
|
abstract public function isEnabledForObject($object);
|
|
|
|
abstract public function getEdgeConstant();
|
|
|
|
abstract protected function getActionName();
|
|
abstract protected function getActionIcon();
|
|
|
|
abstract public function canRelateObjects($src, $dst);
|
|
|
|
abstract public function getDialogTitleText();
|
|
abstract public function getDialogHeaderText();
|
|
abstract public function getDialogButtonText();
|
|
|
|
public function getDialogInstructionsText() {
|
|
return null;
|
|
}
|
|
|
|
public function shouldAppearInActionMenu() {
|
|
return true;
|
|
}
|
|
|
|
protected function isActionEnabled($object) {
|
|
$viewer = $this->getViewer();
|
|
|
|
return PhabricatorPolicyFilter::hasCapability(
|
|
$viewer,
|
|
$object,
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
}
|
|
|
|
public function getRequiredRelationshipCapabilities() {
|
|
return array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
);
|
|
}
|
|
|
|
final public function newSource() {
|
|
$viewer = $this->getViewer();
|
|
|
|
return $this->newRelationshipSource()
|
|
->setViewer($viewer);
|
|
}
|
|
|
|
abstract protected function newRelationshipSource();
|
|
|
|
final public function getSourceURI($object) {
|
|
$relationship_key = $this->getRelationshipConstant();
|
|
$object_phid = $object->getPHID();
|
|
|
|
return "/search/source/{$relationship_key}/{$object_phid}/";
|
|
}
|
|
|
|
final public function newAction($object) {
|
|
$is_enabled = $this->isActionEnabled($object);
|
|
$action_uri = $this->getActionURI($object);
|
|
|
|
return id(new PhabricatorActionView())
|
|
->setName($this->getActionName())
|
|
->setHref($action_uri)
|
|
->setIcon($this->getActionIcon())
|
|
->setDisabled(!$is_enabled)
|
|
->setWorkflow(true);
|
|
}
|
|
|
|
final public static function getAllRelationships() {
|
|
return id(new PhutilClassMapQuery())
|
|
->setAncestorClass(__CLASS__)
|
|
->setUniqueMethod('getRelationshipConstant')
|
|
->execute();
|
|
}
|
|
|
|
private function getActionURI($object) {
|
|
$phid = $object->getPHID();
|
|
$type = $this->getRelationshipConstant();
|
|
return "/search/rel/{$type}/{$phid}/";
|
|
}
|
|
|
|
public function getMaximumSelectionSize() {
|
|
return null;
|
|
}
|
|
|
|
public function canUndoRelationship() {
|
|
return true;
|
|
}
|
|
|
|
public function willUpdateRelationships($object, array $add, array $rem) {
|
|
return array();
|
|
}
|
|
|
|
public function didUpdateRelationships($object, array $add, array $rem) {
|
|
return;
|
|
}
|
|
|
|
}
|