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

LIMS-1371, LIMS-1372: Add search and 'My Groups' to Sample Groups page #799

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
14 changes: 13 additions & 1 deletion api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Sample extends Page
'SCREENINGMETHOD' => '\w+',
'SCREENINGCOLLECTVALUE' => '\d+',
'SAMPLEGROUP' => '\d+',
'currentuser' => '\d',
'INITIALSAMPLEGROUP' => '\d+',
'STRATEGYOPTION' => '',
'MINIMUMRESOLUTION' => '\d+(.\d+)?',
Expand Down Expand Up @@ -2578,6 +2579,16 @@ function _sample_groups()
$from_table = '';
$group_by = '';

if ($this->has_arg('currentuser') && $this->arg('currentuser') == 1) {
$where .= ' AND bsg.ownerid = :' . (sizeof($args) + 1);
array_push($args, $this->user->personId);
}
if ($this->has_arg('s')) {
$st = sizeof($args) + 1;
$where .= " AND bsg.name LIKE CONCAT('%',:" . $st . ",'%')";
array_push($args, $this->arg('s'));
}

// Check if we are grouping the result by BlSAMPLEID or BLSAMPLEGROUPID.
// This is currently being used by xpdf when fetching the list of sample group samples.
if ($this->has_arg('groupSamplesType') && $this->arg('groupSamplesType') === 'BLSAMPLEGROUPID') {
Expand Down Expand Up @@ -2660,7 +2671,8 @@ function _add_new_sample_group()
function _create_sample_group()
{
$name = $this->has_arg('NAME') ? $this->arg('NAME') : NULL;
$this->db->pq("INSERT INTO blsamplegroup (blsamplegroupid, name, proposalid) VALUES(NULL, :1, :2)", array($name, $this->proposalid));
$this->db->pq("INSERT INTO blsamplegroup (blsamplegroupid, name, proposalid, ownerid) VALUES(NULL, :1, :2, :3)",
array($name, $this->proposalid, $this->user->personId));
return $this->db->id();
}

Expand Down
41 changes: 39 additions & 2 deletions client/src/js/modules/samples/components/sample-groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@
<div class="content">
<h1>Sample Group Management</h1>

<base-input-checkbox
:outerClass="
`l tw-mx-1 tw-mb-3 tw-rounded-md tw-w-40
tw-p-2 tw-bg-content-filter-background`
"
:value="showUserSampleGroups"
id="mysamplegroups"
description="My Sample Groups"
name="currentUserSampleGroups"
@input="setUserSampleGroupsState"/>

<div class="r tw-mb-2">
<button @click="onAddSampleGroup" class="button tw-text-lg">
<button @click="onAddSampleGroup" class="button tw-text-lg tw-p-2">
<i class="fa fa-plus"></i> Create Sample Group
</button>
</div>

<div class="r tw-mb-2 tw-mx-2 tw-p-2 tw-rounded-md tw-bg-content-filter-background">
<input data-testid="sample-groups-table-search"
placeholder='Search'
v-model = "searchSampleGroups"
/>
</div>

<custom-table-component :data-list="groups" table-class="tw-w-full">
<template v-slot:tableHeaders>
<td class="tw-w-3/12 tw-py-2 tw-pl-2">Group Name</td>
Expand Down Expand Up @@ -85,9 +104,11 @@

<script>
import Pagination from 'app/components/pagination.vue'
import { debounce } from 'lodash-es'

import SampleGroupsCollection from 'collections/samplegroups.js'
import SampleGroupSamplesCollection from 'collections/samplegroupsamples.js'
import BaseInputCheckbox from 'app/components/base-input-checkbox.vue'
import CustomTableComponent from 'app/components/custom-table-component.vue'
import CustomTableRow from 'app/components/custom-table-row.vue'
import ValidContainerGraphic from 'modules/types/mx/samples/valid-container-graphic.vue'
Expand All @@ -99,6 +120,7 @@ export default {
components: {
'auto-processing-jobs-list': AutoProcessingJobsList,
'valid-container-graphic': ValidContainerGraphic,
'base-input-checkbox': BaseInputCheckbox,
'custom-table-row': CustomTableRow,
'custom-table-component': CustomTableComponent,
'pagination-panel': Pagination,
Expand All @@ -116,6 +138,9 @@ export default {
sampleGroupsListState: {},
selectedSampleGroup: null,
latestMultiplexJobs: [],
showUserSampleGroups: false,
searchSampleGroups : '',
doSearchSampleGroups: debounce(this.getSampleGroups, 500),
loadedMultiplex: false
};
},
Expand Down Expand Up @@ -160,6 +185,7 @@ export default {
async getSampleGroups() {
try {
this.$store.commit('loading', true)
this.sampleGroups.queryParams.s = this.searchSampleGroups

const collection = await this.$store.dispatch('getCollection', this.sampleGroups)

Expand Down Expand Up @@ -205,14 +231,25 @@ export default {
}, [])
this.loadedMultiplex = true
},
setUserSampleGroupsState() {
this.showUserSampleGroups = !this.showUserSampleGroups
},
async goToSampleGroupsDataCollections() {
await this.$router.push(`/dc/sgid/${this.sampleGroupId}`)
}
},
watch: {
selectedSampleGroup() {
this.onSampleGroupSelected()
}
},
searchSampleGroups: {
handler: 'doSearchSampleGroups'
},
showUserSampleGroups() {
this.sampleGroups.queryParams.currentuser = this.showUserSampleGroups ? 1 : 0
this.sampleGroups.queryParams.page = 1
this.getSampleGroups()
},
}
}
</script>
Expand Down
Loading