1
1
import { type ListItem } from "backend/lists.ts" ;
2
2
import { template } from "uix/html/template.ts" ;
3
3
import { Component } from "uix/components/Component.ts" ;
4
- import type { Ref } from "datex-core-legacy/datex_all.ts" ;
5
4
6
- @template ( function ( this : List ) {
7
- const { title, items } = this . properties ;
5
+ @template ( function ( { title, items } ) {
8
6
return (
9
7
< div >
10
8
< div class = "header" >
11
9
< h1 > { title } </ h1 >
12
10
</ div >
13
11
< ol >
14
- { val ( items ) . map ( ( item , index ) => (
12
+ { items . map ( ( item , index ) => (
15
13
< li >
16
14
< input
17
15
type = "checkbox"
@@ -24,12 +22,14 @@ import type { Ref } from "datex-core-legacy/datex_all.ts";
24
22
) ) }
25
23
</ ol >
26
24
< button
25
+ type = "button"
27
26
class = "add-button"
28
27
onclick :frontend = { ( ) => this . dialog . showModal ( ) }
29
28
>
30
29
Add item
31
30
</ button >
32
31
< button
32
+ type = "button"
33
33
class = "remove-button"
34
34
onclick :frontend = { ( ) => this . removeChecked ( ) }
35
35
>
@@ -49,34 +49,30 @@ import type { Ref } from "datex-core-legacy/datex_all.ts";
49
49
max = { 99 }
50
50
/>
51
51
< select id = "type" value = { this . type } >
52
- < option name = { "bottle" } > Bottle</ option >
53
- < option name = { "piece" } > Piece</ option >
54
- < option name = { "whatever" } > Whatever</ option >
52
+ < option name = "bottle" > Bottle</ option >
53
+ < option name = "piece" > Piece</ option >
54
+ < option name = "whatever" > Whatever</ option >
55
55
</ select >
56
- < div id = "add " onclick :frontend = { ( ) => this . addItem ( ) } >
56
+ < button type = "button " onclick :frontend = { ( ) => this . addItem ( ) } >
57
57
Add
58
- </ div >
58
+ </ button >
59
59
</ dialog >
60
60
</ div >
61
61
) ;
62
62
} )
63
- export class List extends Component < { title : string ; items : Ref < ListItem [ ] > } > {
63
+ export class List extends Component < { title : string ; items : ListItem [ ] } > {
64
64
/** references to the DOM elements */
65
- @property
66
- name = "" ;
67
- @property
68
- amount = 1 ;
69
- @property
70
- type = "bottle" ;
71
- @id
72
- dialog ! : HTMLDialogElement ;
65
+ @property name = "" ;
66
+ @property amount = 1 ;
67
+ @property type = "bottle" ;
68
+ @id dialog ! : HTMLDialogElement ;
73
69
74
70
/**
75
71
* Remove all checked items
76
72
*/
77
73
private removeChecked ( ) {
78
74
const items = this . properties . items ;
79
- items . val = val ( items ) . filter ( ( e ) => ! e . checked ) ;
75
+ items . splice ( 0 , items . length , ... items . filter ( ( e ) => ! e . checked ) )
80
76
globalThis . location . reload ( ) ;
81
77
}
82
78
0 commit comments