upd
Browse files
src/lib/components/Piclets/DraggablePicletCard.svelte
CHANGED
|
@@ -50,6 +50,8 @@
|
|
| 50 |
ondragend={handleDragEnd}
|
| 51 |
class="draggable-wrapper"
|
| 52 |
class:dragging={isDragging}
|
|
|
|
|
|
|
| 53 |
>
|
| 54 |
<PicletCard {instance} {size} {showDetails} {onClick} />
|
| 55 |
</div>
|
|
|
|
| 50 |
ondragend={handleDragEnd}
|
| 51 |
class="draggable-wrapper"
|
| 52 |
class:dragging={isDragging}
|
| 53 |
+
role="button"
|
| 54 |
+
tabindex="0"
|
| 55 |
>
|
| 56 |
<PicletCard {instance} {size} {showDetails} {onClick} />
|
| 57 |
</div>
|
src/lib/components/Piclets/RosterSlot.svelte
CHANGED
|
@@ -72,6 +72,8 @@
|
|
| 72 |
ondragleave={handleDragLeave}
|
| 73 |
ondrop={handleDrop}
|
| 74 |
class:drag-over={isDragOver}
|
|
|
|
|
|
|
| 75 |
>
|
| 76 |
{#if piclet}
|
| 77 |
<DraggablePicletCard
|
|
|
|
| 72 |
ondragleave={handleDragLeave}
|
| 73 |
ondrop={handleDrop}
|
| 74 |
class:drag-over={isDragOver}
|
| 75 |
+
role="region"
|
| 76 |
+
aria-label="Roster slot {position + 1}"
|
| 77 |
>
|
| 78 |
{#if piclet}
|
| 79 |
<DraggablePicletCard
|
src/lib/db/piclets.ts
CHANGED
|
@@ -143,6 +143,54 @@ export async function updateRosterPosition(id: number, position: number | undefi
|
|
| 143 |
});
|
| 144 |
}
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
// Delete a PicletInstance
|
| 147 |
export async function deletePicletInstance(id: number): Promise<void> {
|
| 148 |
await db.picletInstances.delete(id);
|
|
|
|
| 143 |
});
|
| 144 |
}
|
| 145 |
|
| 146 |
+
// Move piclet to roster
|
| 147 |
+
export async function moveToRoster(id: number, position: number): Promise<void> {
|
| 148 |
+
// Check if position is already occupied
|
| 149 |
+
const existingPiclet = await db.picletInstances
|
| 150 |
+
.where('rosterPosition')
|
| 151 |
+
.equals(position)
|
| 152 |
+
.and(item => item.isInRoster)
|
| 153 |
+
.first();
|
| 154 |
+
|
| 155 |
+
if (existingPiclet) {
|
| 156 |
+
// Move existing piclet to storage
|
| 157 |
+
await db.picletInstances.update(existingPiclet.id!, {
|
| 158 |
+
isInRoster: false,
|
| 159 |
+
rosterPosition: undefined
|
| 160 |
+
});
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
// Move new piclet to roster
|
| 164 |
+
await db.picletInstances.update(id, {
|
| 165 |
+
isInRoster: true,
|
| 166 |
+
rosterPosition: position
|
| 167 |
+
});
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// Swap roster positions
|
| 171 |
+
export async function swapRosterPositions(id1: number, position1: number, id2: number, position2: number): Promise<void> {
|
| 172 |
+
await db.transaction('rw', db.picletInstances, async () => {
|
| 173 |
+
await db.picletInstances.update(id1, { rosterPosition: position2 });
|
| 174 |
+
await db.picletInstances.update(id2, { rosterPosition: position1 });
|
| 175 |
+
});
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// Move piclet to storage
|
| 179 |
+
export async function moveToStorage(id: number): Promise<void> {
|
| 180 |
+
await db.picletInstances.update(id, {
|
| 181 |
+
isInRoster: false,
|
| 182 |
+
rosterPosition: undefined
|
| 183 |
+
});
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
// Get storage piclets
|
| 187 |
+
export async function getStoragePiclets(): Promise<PicletInstance[]> {
|
| 188 |
+
return await db.picletInstances
|
| 189 |
+
.where('isInRoster')
|
| 190 |
+
.equals(0)
|
| 191 |
+
.toArray();
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
// Delete a PicletInstance
|
| 195 |
export async function deletePicletInstance(id: number): Promise<void> {
|
| 196 |
await db.picletInstances.delete(id);
|