Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkp/pkp-lib#7188] Adds number of user assignments on user assignment grid #10807

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion controllers/grid/users/userSelect/UserSelectGridCellProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@

namespace PKP\controllers\grid\users\userSelect;

use APP\facades\Repo;
use APP\submission\Submission;
use PKP\controllers\grid\DataObjectGridCellProvider;
use PKP\controllers\grid\GridColumn;
use PKP\user\User;

class UserSelectGridCellProvider extends DataObjectGridCellProvider
{
/** @var int ID of the current context */
public $_contextId;

/** @var int User ID of already-selected user */
public $_userId;

Expand All @@ -30,8 +35,9 @@ class UserSelectGridCellProvider extends DataObjectGridCellProvider
*
* @param int $userId ID of preselected user.
*/
public function __construct($userId = null)
public function __construct($contextId, $userId = null)
{
$this->_contextId = $contextId;
$this->_userId = $userId;
}

Expand All @@ -57,7 +63,22 @@ public function getTemplateVarsFromRowColumn($row, $column)

case 'name': // User's name
return ['label' => $element->getFullName()];

case 'assignments': //User's assignments count
$countUserAssignments = $this->getCountUserAssignments($element->getId());
return ['label' => $countUserAssignments];
}
assert(false);
}

private function getCountUserAssignments($userId)
{
$countAssignedSubmissions = Repo::submission()->getCollector()
->filterByContextIds([$this->_contextId])
->filterByStatus([Submission::STATUS_QUEUED])
->assignedTo([$userId])
->getCount();

return $countAssignedSubmissions;
}
}
20 changes: 16 additions & 4 deletions controllers/grid/users/userSelect/UserSelectGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ public function initialize($request, $args = null)
{
parent::initialize($request, $args);

$contextId = $request->getContext()->getId();
$stageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);

$userGroups = Repo::userGroup()->getUserGroupsByStage(
$request->getContext()->getId(),
$contextId,
$stageId
);

Expand All @@ -85,7 +86,7 @@ public function initialize($request, $args = null)
$this->setTitle('editor.submission.findAndSelectUser');

// Columns
$cellProvider = new UserSelectGridCellProvider();
$cellProvider = new UserSelectGridCellProvider($contextId);
$this->addColumn(
new GridColumn(
'select',
Expand All @@ -109,9 +110,20 @@ public function initialize($request, $args = null)
]
)
);
$this->addColumn(
new GridColumn(
'assignments',
'common.assignments',
null,
null,
$cellProvider,
[
'alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
'width' => 30
]
)
);
}



//
// Overridden methods from GridHandler
Expand Down
3 changes: 3 additions & 0 deletions locale/en/common.po
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ msgstr "Assigned"
msgid "common.assigned.date"
msgstr "Assigned: {$dateAssigned}"

msgid "common.assignments"
msgstr "Assignments"

msgid "common.available"
msgstr "Available"

Expand Down
3 changes: 3 additions & 0 deletions locale/es/common.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ msgstr "Asignado"
msgid "common.assigned.date"
msgstr "Asignado: {$dateAssigned}"

msgid "common.assignments"
msgstr "Asignaciones"

msgid "common.available"
msgstr "Disponible"

Expand Down
3 changes: 3 additions & 0 deletions locale/pt_BR/common.po
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ msgstr "Designado"
msgid "common.assigned.date"
msgstr "Designado em: {$dateAssigned}"

msgid "common.assignments"
msgstr "Designações"

msgid "common.available"
msgstr "Disponível"

Expand Down