Spaces:
Runtime error
Runtime error
File size: 1,919 Bytes
32f0b26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<script lang="ts">
import Dialog, { Title, Content, Actions } from "@smui/dialog";
import Button, { Label } from "@smui/button";
import Textfield from "@smui/textfield";
import Select, { Option } from "@smui/select";
import { user } from "./stores/cur_user_store.js";
import { users } from "./stores/all_users_store.js";
export let open;
export let cur_user;
let cur_user_tf = cur_user;
let cur_user_sel = cur_user;
let all_users;
users.subscribe((value) => {
all_users = value;
});
function updateUserTextField() {
user.update((value) => cur_user_tf);
if (!all_users.includes(user)) {
all_users = all_users.concat(cur_user_tf);
users.update(all_users);
}
open = false;
}
function updateUserSel() {
user.update((value) => cur_user_sel);
open = false;
}
</script>
<div>
<Dialog
bind:open
aria-labelledby="simple-title"
aria-describedby="simple-content"
>
<!-- Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->
<Title id="simple-title">Select Current User</Title>
<Content id="simple-content">
<Textfield bind:value={cur_user_tf} label="Enter user's name" />
<Select bind:value={cur_user_sel} label="Select Menu">
{#each all_users as u}
<Option value={u}>{u}</Option>
{/each}
</Select>
</Content>
<Actions>
<Button on:click={updateUserTextField}>
<Label>Update from TextField</Label>
</Button>
<Button on:click={updateUserSel}>
<Label>Update from Select</Label>
</Button>
</Actions>
</Dialog>
</div>
<style>
:global(.mdc-dialog__surface) {
height: 300px;
}
</style>
|