Page MenuHomePhabricator

[PATCH]_Allow_assigning_users_other_than_oneself_when_closing_owner-less_tasks_(T84833)

Authored By
matmarex
Jan 10 2015, 1:49 AM
Size
4 KB
Referenced Files
None
Subscribers
None

[PATCH]_Allow_assigning_users_other_than_oneself_when_closing_owner-less_tasks_(T84833)

From e81fb1a6d2b492f9db463ef4bf754b88d2f537ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= <matma.rex@gmail.com>
Date: Sat, 10 Jan 2015 02:18:17 +0100
Subject: [PATCH] Allow assigning users other than oneself when closing
owner-less tasks
See T84833 (https://phabricator.wikimedia.org/T84833).
I have yet to test this, but I'm pretty sure it will work, and
I'm definitely sure this is the right approach to solve this bug.
The patch should be easy to maintain locally if it comes to that.
---
.../controller/ManiphestTaskDetailController.php | 5 +++++
.../ManiphestTransactionSaveController.php | 22 ++++++++++++++--------
.../maniphest/behavior-transaction-controls.js | 18 ++++++++++++++++++
3 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
index 8107021..9edb1a0 100644
--- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php
+++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
@@ -297,6 +297,11 @@ final class ManiphestTaskDetailController extends ManiphestController {
Javelin::initBehavior('maniphest-transaction-controls', array(
'select' => 'transaction-action',
'controlMap' => $control_map,
+ 'closedStatuses' => ManiphestTaskStatus::getClosedStatusConstants(),
+ 'statusConstant' => ManiphestTransaction::TYPE_STATUS,
+ 'ownerConstant' => ManiphestTransaction::TYPE_OWNER,
+ 'statusSelect' => 'resolution',
+ 'ownerSelect' => 'assign_to',
'tokenizers' => $tokenizer_map,
));
diff --git a/src/applications/maniphest/controller/ManiphestTransactionSaveController.php b/src/applications/maniphest/controller/ManiphestTransactionSaveController.php
index 52cb751..d28373f 100644
--- a/src/applications/maniphest/controller/ManiphestTransactionSaveController.php
+++ b/src/applications/maniphest/controller/ManiphestTransactionSaveController.php
@@ -97,16 +97,22 @@ final class ManiphestTransactionSaveController extends ManiphestController {
if ($action == ManiphestTransaction::TYPE_STATUS) {
$resolution = $request->getStr('resolution');
- if (!$task->getOwnerPHID() &&
- ManiphestTaskStatus::isClosedStatus($resolution)) {
- // Closing an unassigned task. Assign the user as the owner of
- // this task.
+ if (ManiphestTaskStatus::isClosedStatus($resolution)) {
+ // Closing the task, maybe change assignee.
$assign = new ManiphestTransaction();
$assign->setTransactionType(ManiphestTransaction::TYPE_OWNER);
- $assign->setNewValue($user->getPHID());
- $transactions[] = $assign;
-
- $implicitly_claimed = true;
+ $assign_to = $request->getArr('assign_to');
+ $assign_to = reset($assign_to);
+ $assign->setNewValue($assign_to);
+ // Skip if no-op.
+ if ($task->getOwnerPHID() != $assign->getNewValue()) {
+ $transactions[] = $assign;
+ // Move the previous owner to CC.
+ $added_ccs[] = $task->getOwnerPHID();
+ if ($user->getPHID() == $assign->getNewValue()) {
+ $implicitly_claimed = true;
+ }
+ }
}
}
diff --git a/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js b/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js
index 48e6c43..52c0432 100644
--- a/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js
+++ b/webroot/rsrc/js/application/maniphest/behavior-transaction-controls.js
@@ -25,6 +25,9 @@ JX.behavior('maniphest-transaction-controls', function(config) {
JX.DOM.show(JX.$(config.controlMap[k]));
if (tokenizers[k]) {
tokenizers[k].refresh();
+ if(k == config.statusConstant) {
+ tokenizers[k].invoke('change');
+ }
}
} else {
JX.DOM.hide(JX.$(config.controlMap[k]));
@@ -32,4 +35,19 @@ JX.behavior('maniphest-transaction-controls', function(config) {
}
});
+ JX.DOM.listen(
+ JX.$(config.statusSelect),
+ 'change',
+ null,
+ function() {
+ var selectedStatus = JX.$(config.statusSelect).value;
+ if (config.closedStatuses.indexOf(selectedStatus) != -1) {
+ JX.DOM.show(JX.$(config.ownerSelect));
+ tokenizers[config.ownerConstant].refresh();
+ } else {
+ JX.DOM.hide(JX.$(config.ownerSelect));
+ }
+ }
+ );
+
});
--
1.9.5.msysgit.0

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26085
Default Alt Text
[PATCH]_Allow_assigning_users_other_than_oneself_when_closing_owner-less_tasks_(T84833) (4 KB)

Event Timeline