1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

Send search term to api call

This commit is contained in:
Adria Navarro 2023-05-08 14:54:43 +02:00
parent 8bbfa7e0ab
commit d33a06c89c
3 changed files with 25 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<script> <script>
import EditUserPicker from "./EditUserPicker.svelte" import EditUserPicker from "./EditUserPicker.svelte"
import { Heading, Pagination, Table } from "@budibase/bbui" import { Heading, Pagination, Table, Search } from "@budibase/bbui"
import { fetchData } from "@budibase/frontend-core" import { fetchData } from "@budibase/frontend-core"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { API } from "api" import { API } from "api"
@ -12,7 +12,9 @@
export let groupId export let groupId
const fetchGroupUsers = fetchData({ let searchTerm
let fetchGroupUsers
$: fetchGroupUsers = fetchData({
API, API,
datasource: { datasource: {
type: "groupUser", type: "groupUser",
@ -20,6 +22,7 @@
options: { options: {
query: { query: {
groupId, groupId,
searchTerm,
}, },
}, },
}) })
@ -67,6 +70,9 @@
{/if} {/if}
</div> </div>
<div class="controls-right">
<Search bind:value={searchTerm} placeholder="Search" />
</div>
<Table <Table
schema={userSchema} schema={userSchema}
data={$fetchGroupUsers?.rows} data={$fetchGroupUsers?.rows}
@ -109,4 +115,15 @@
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
.controls-right {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
gap: var(--spacing-xl);
}
.controls-right :global(.spectrum-Search) {
width: 200px;
}
</style> </style>

View file

@ -55,10 +55,13 @@ export const buildGroupsEndpoints = API => {
/** /**
* Gets a group users by the group id * Gets a group users by the group id
*/ */
getGroupUsers: async ({ id, bookmark }) => { getGroupUsers: async ({ id, bookmark, searchTerm }) => {
let url = `/api/global/groups/${id}/users?` let url = `/api/global/groups/${id}/users?`
if (bookmark) { if (bookmark) {
url += `bookmark=${bookmark}` url += `bookmark=${bookmark}&`
}
if (searchTerm) {
url += `searchTerm=${searchTerm}&`
} }
return await API.get({ return await API.get({

View file

@ -31,6 +31,7 @@ export default class GroupUserFetch extends DataFetch {
try { try {
const res = await this.API.getGroupUsers({ const res = await this.API.getGroupUsers({
id: query.groupId, id: query.groupId,
searchTerm: query.searchTerm,
bookmark: cursor, bookmark: cursor,
}) })