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

[dashboard] Add project filter for tasks widget #9220

Merged
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ changes in the following format: PR #1234***

#### Updates and Improvements
- Create new `sex` table to hold candidate sex options, and change Sex and ProbandSex columns of `candidate` table to a varchar(255) datatype that is restricted by the `sex` table (PR #9025)
- Add Project filter for "My tasks" counts in dashboard (PR #9220)

#### Bug Fixes
- Fix examiner site display (PR #8967)
Expand Down
1 change: 1 addition & 0 deletions modules/conflict_resolver/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Module extends \Module
s.CenterID <> 1",
'access_all_profiles',
's.CenterID',
's.ProjectID',
$baseURL . '/' . $this->getName(),
'conflict_resolver'
)
Expand Down
37 changes: 22 additions & 15 deletions modules/dashboard/php/taskquerywidget.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ class TaskQueryWidget extends TaskWidget
/**
* Construct a TaskQueryWidget
*
* @param \User $user The user whose tasks are being displayed
* @param string $label The label for the task widget. It should be
* singular and phrased in a way that adding
* an "s" pluralizes.
* @param \Database $db The database connection for the query.
* @param string $dbquery The query to run to get a count.
* @param string $allperm The permission to use to determine if the user
* has access to all sites, or only user sites.
* If the empty string, center permissions will
* not be used.
* @param string $sitefield The field to use in the query to site-restrict
* the results.
* @param string $link The link for the widget to go to when clicked.
* @param string $cssclass An optional css class to add to the task for
* testing.
* @param \User $user The user whose tasks are being displayed
* @param string $label The label for the task widget. It should be
* singular and phrased in a way that adding
* an "s" pluralizes.
* @param \Database $db The database connection for the query.
* @param string $dbquery The query to run to get a count.
* @param string $allperm The permission to use to determine if the user
* has access to all sites, or only user sites.
* If the empty string, center permissions will
* not be used.
* @param string $sitefield The field to use in the query to site-restrict
* the results.
* @param string $projectfield The field to use in the query to restrict the
* project in results.
* @param string $link The link for the widget to go to when clicked.
* @param string $cssclass An optional css class to add to the task for
* testing.
*/
public function __construct(
\User $user,
Expand All @@ -56,6 +58,7 @@ class TaskQueryWidget extends TaskWidget
string $dbquery,
string $allperm,
string $sitefield,
string $projectfield,
string $link,
string $cssclass
) {
Expand All @@ -69,6 +72,10 @@ class TaskQueryWidget extends TaskWidget
$siteLabel = 'Site: All User Sites';
}
}
if ($projectfield) {
$queryparams['ProjectID'] = implode(',', $user->getProjectIDs());
$dbquery .= " AND FIND_IN_SET($projectfield, :ProjectID)";
}

$number = (int )$db->pselectOne($dbquery, $queryparams);
if ($number != 1) {
Expand Down
24 changes: 21 additions & 3 deletions modules/dashboard/test/DashboardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ function setUp(): void
'Name' => 'TESTinProject',
]
);
$this->DB->insert(
"user_project_rel",
[
'UserID' => $user_id,
'ProjectID' => '1',
]
);
$this->DB->insert(
"candidate",
[
Expand Down Expand Up @@ -316,6 +323,17 @@ public function tearDown(): void
["Value" => null],
["ConfigID" => 48]
);
$user_id = $this->DB->pselectOne(
"SELECT ID FROM users WHERE UserID=:test_user_id",
["test_user_id" => 'testUser1']
);
$this->DB->delete(
"user_project_rel",
[
'UserID' => $user_id,
'ProjectID' => '1',
]
);
$this->DB->run('SET foreign_key_checks =1');
parent::tearDown();
}
Expand Down Expand Up @@ -406,7 +424,7 @@ public function testNewScans()
$this->safeGet($this->url . '/dashboard/');
$this->_testMytaskPanelAndLink(
".new-scans",
"10",
"4",
"- Imaging Browser"
);
$this->resetPermissions();
Expand Down Expand Up @@ -436,7 +454,7 @@ public function testConflictResolver()
$this->safeGet($this->url . '/dashboard/');
$this->_testMytaskPanelAndLink(
".conflict_resolver",
"574",
"570",
"- Conflict Resolver"
);
$this->resetPermissions();
Expand Down Expand Up @@ -513,7 +531,7 @@ public function testPendingUser()
$this->safeGet($this->url . '/dashboard/');
$this->_testMytaskPanelAndLink(
".pending-accounts",
"2",
"1",
"- User Accounts"
);
$this->resetPermissions();
Expand Down
1 change: 1 addition & 0 deletions modules/imaging_browser/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Module extends \Module
AND s.CenterID <> 1",
'imaging_browser_view_allsites',
's.CenterID',
's.ProjectID',
$baseURL . "/imaging_browser/?pendingNew=N&pendingNew=P",
"new-scans"
)
Expand Down
1 change: 1 addition & 0 deletions modules/instruments/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Module extends \Module
AND s.Active='Y' AND c.Active='Y'",
'access_all_profiles',
's.CenterID',
's.ProjectID',
$baseURL . "/statistics/statistics_site/",
""
),
Expand Down
1 change: 1 addition & 0 deletions modules/issue_tracker/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class Module extends \Module
. $DB->quote($user->getUsername()),
'',
'',
'',
$baseURL . "/issue_tracker/?$url",
"issue_tracker"
)
Expand Down
2 changes: 2 additions & 0 deletions modules/user_accounts/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ class Module extends \Module
$DB,
"SELECT COUNT(DISTINCT users.UserID) FROM users
LEFT JOIN user_psc_rel as upr ON (upr.UserID=users.ID)
LEFT JOIN user_project_rel upr2 ON (upr2.UserID=users.ID)
WHERE users.Pending_approval='Y'",
'user_accounts_multisite',
'upr.CenterID',
'upr2.ProjectID',
$baseURL . "/user_accounts/?pendingApproval=Y",
"pending-accounts"
)
Expand Down
Loading