-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Item.js
41 lines (32 loc) · 857 Bytes
/
Item.js
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
import {removeDiacritics} from '@/libs/compare-strings'
import AbstractModel from './AbstractModel'
import List from './List'
class Item extends AbstractModel {
static entity = 'items'
static primaryKey = '_id'
static fields() {
return {
...super.fields(),
_id: this.string(null),
name: this.string(''),
details: this.string(''),
qty: this.number(null).nullable(),
checked: this.boolean(false),
lastCheckedAt: this.attr(null),
createdAt: this.attr(null),
updatedAt: this.attr(null),
listId: this.string(null),
list: this.belongsTo(List, 'listId')
}
}
get sortName() {
return removeDiacritics(this.name).toLowerCase()
}
get search() {
return removeDiacritics(this.name)
}
toggleChecked() {
this.checked = !this.checked
}
}
export default Item