sets up frontend side of updating users
This commit is contained in:
parent
42e23b05e6
commit
1d9a0b9b0d
|
@ -1,4 +1,6 @@
|
|||
<script>
|
||||
import { createEventDispatcher } from "svelte"
|
||||
const dispatch = createEventDispatcher()
|
||||
import { Input, Select, Button } from "@budibase/bbui"
|
||||
export let user
|
||||
</script>
|
||||
|
@ -9,7 +11,7 @@
|
|||
<option value="ADMIN">Admin</option>
|
||||
<option value="POWER_USER">Power User</option>
|
||||
</Select>
|
||||
<Button on:click>Edit</Button>
|
||||
<Button on:click={() => dispatch('save', user)}>Edit</Button>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -25,6 +25,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Update user!
|
||||
async function updateUser(event) {
|
||||
const response = await api.put(`/api/users`, event.detail)
|
||||
const users = await response.json()
|
||||
backendUiStore.update(state => {
|
||||
state.users = users
|
||||
return state
|
||||
})
|
||||
fetchUsersPromise = fetchUsers()
|
||||
}
|
||||
|
||||
// Get users
|
||||
async function fetchUsers() {
|
||||
const response = await api.get(`/api/users`)
|
||||
|
@ -67,7 +78,7 @@
|
|||
<ul>
|
||||
{#each users as user}
|
||||
<li>
|
||||
<UserRow {user} />
|
||||
<UserRow {user} on:save={updateUser} />
|
||||
</li>
|
||||
{:else}
|
||||
<li>No Users found</li>
|
||||
|
@ -89,7 +100,7 @@
|
|||
display: grid;
|
||||
grid-gap: 12px;
|
||||
border-radius: 5px;
|
||||
background-color: var(--light-grey);
|
||||
background-color: var(--grey-2);
|
||||
padding: 12px 12px 18px 12px;
|
||||
}
|
||||
.background.create {
|
||||
|
|
Loading…
Reference in New Issue