1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Ponder: strike code of resolved questions in query results

Summary:
After this change, search results with resolved
questions are striked, just like any Closed Maniphest
Tasks is already striked, etc.

https://we.phorge.it/T15166

There is still the same thing to be done at Remarkup.

Ref T15166

Test Plan: - go in the page /ponder/query/all/ and see that closed questions are now striked

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15166

Differential Revision: https://we.phorge.it/D25086
This commit is contained in:
Valerio Bozzolan 2023-03-27 20:54:59 +02:00
parent 780e86acf8
commit 5eac69b79d
5 changed files with 48 additions and 0 deletions

View file

@ -5843,6 +5843,7 @@ phutil_register_library_map(array(
'PonderQuestionSearchEngine' => 'applications/ponder/query/PonderQuestionSearchEngine.php',
'PonderQuestionStatus' => 'applications/ponder/constants/PonderQuestionStatus.php',
'PonderQuestionStatusController' => 'applications/ponder/controller/PonderQuestionStatusController.php',
'PonderQuestionStatusTestCase' => 'applications/ponder/storage/__tests__/PonderQuestionStatusTestCase.php',
'PonderQuestionStatusTransaction' => 'applications/ponder/xaction/PonderQuestionStatusTransaction.php',
'PonderQuestionTitleTransaction' => 'applications/ponder/xaction/PonderQuestionTitleTransaction.php',
'PonderQuestionTransaction' => 'applications/ponder/storage/PonderQuestionTransaction.php',
@ -12757,6 +12758,7 @@ phutil_register_library_map(array(
'PonderQuestionSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PonderQuestionStatus' => 'PonderConstants',
'PonderQuestionStatusController' => 'PonderController',
'PonderQuestionStatusTestCase' => 'PhutilTestCase',
'PonderQuestionStatusTransaction' => 'PonderQuestionTransactionType',
'PonderQuestionTitleTransaction' => 'PonderQuestionTransactionType',
'PonderQuestionTransaction' => 'PhabricatorModularTransaction',

View file

@ -86,4 +86,14 @@ final class PonderQuestionStatus extends PonderConstants {
);
}
/**
* Check whenever a Ponder question status is Closed
*
* @param $status string
* @return bool
*/
public static function isQuestionStatusClosed($status) {
return in_array($status, self::getQuestionStatusClosedMap(), true);
}
}

View file

@ -157,6 +157,9 @@ final class PonderQuestionSearchEngine
'Asked by %s',
$handles[$question->getAuthorPHID()]->renderLink()));
// Render Closed Questions as striked in query results
$item->setDisabled($question->isStatusClosed());
$item->addAttribute(
pht(
'%s Answer(s)',

View file

@ -137,6 +137,14 @@ final class PonderQuestion extends PonderDAO
return self::MARKUP_FIELD_CONTENT;
}
/**
* Check whenever this Question has whatever closed status
*
* @return bool
*/
public function isStatusClosed() {
return PonderQuestionStatus::isQuestionStatusClosed($this->status);
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -0,0 +1,25 @@
<?php
final class PonderQuestionStatusTestCase extends PhutilTestCase {
public function testClosedStatuses() {
$statuses = PonderQuestionStatus::getQuestionStatusClosedMap();
foreach ($statuses as $status) {
$question = new PonderQuestion();
$question->setStatus($status);
$this->assertEqual(true, $question->isStatusClosed());
}
}
public function testOpenedStatuses() {
$statuses = PonderQuestionStatus::getQuestionStatusOpenMap();
foreach ($statuses as $status) {
$question = new PonderQuestion();
$question->setStatus($status);
$this->assertEqual(false, $question->isStatusClosed());
}
}
}