@@ -3,24 +3,36 @@ import { useSortable } from '@vueuse/integrations/useSortable'
3
3
4
4
import { nanoid } from ' nanoid' ;
5
5
6
- import type { Lineup , AppSettings } from ' ~~/types' ;
6
+ import type { Spot , Lineup , AppSettings } from ' ~~/types' ;
7
7
8
8
const lineup = useLocalStorage <Lineup >(' lineup' , {
9
9
id: nanoid (),
10
10
teamName: ' ' ,
11
11
spots: []
12
+ }, {
13
+ mergeDefaults: true
12
14
});
13
15
const appSettings = useLocalStorage <AppSettings >(' app-settings' , {
16
+ isLineupLocked: false ,
14
17
jerseyColor: ' f47373' ,
15
18
jerseyTextColor: ' 000000'
19
+ }, {
20
+ mergeDefaults: true
16
21
});
17
22
18
23
const sortableContainer = ref <HTMLElement | null >(null );
19
24
useSortable (sortableContainer , lineup .value .spots , {
20
25
group: ' spots' ,
21
26
handle: ' .drag-handle' ,
22
- animation: 150
27
+ animation: 150 ,
28
+ onMove : () => ! appSettings .value .isLineupLocked
23
29
});
30
+
31
+ function addSpot(spot : Spot ) {
32
+ if (! appSettings .value .isLineupLocked ) {
33
+ lineup .value .spots .push (spot );
34
+ }
35
+ }
24
36
</script >
25
37
26
38
<template >
@@ -34,6 +46,8 @@ useSortable(sortableContainer, lineup.value.spots, {
34
46
placeholder =" Team Name"
35
47
/>
36
48
49
+ <SettingsLockButton :is-locked =" appSettings.isLineupLocked" @lock =" appSettings.isLineupLocked = true" @unlock =" appSettings.isLineupLocked = false" />
50
+
37
51
<SettingsButton :app-settings =" appSettings" />
38
52
</header >
39
53
@@ -43,6 +57,7 @@ useSortable(sortableContainer, lineup.value.spots, {
43
57
v-for =" spot in lineup.spots"
44
58
:key =" spot.player.id"
45
59
:spot =" spot"
60
+ :is-lineup-locked =" appSettings.isLineupLocked"
46
61
:jersey-color =" appSettings.jerseyColor"
47
62
:jersey-text-color =" appSettings.jerseyTextColor"
48
63
@delete =" lineup.spots = lineup.spots.filter(s => s.player.id !== $event)"
@@ -52,7 +67,7 @@ useSortable(sortableContainer, lineup.value.spots, {
52
67
</div >
53
68
54
69
<footer >
55
- <LineupNewSpot @add =" lineup.spots.push ($event)" />
70
+ <LineupNewSpot @add =" addSpot ($event)" :class = " `${ appSettings.isLineupLocked ? 'collapse' : 'visible' }` " />
56
71
</footer >
57
72
</div >
58
73
</template >
0 commit comments