+
{
slotItemsNew[item.slot].items.push(item)
})
}
-
+const droppedScript = (e: DragEvent, slot: number) => {
+ if (e.offsetY < -20) {
+ itemStore.moveScript(slot, "top", props.podcastId, props.date)
+ } else {
+ itemStore.moveScript(slot, "bottom", props.podcastId, props.date)
+ }
+}
const exportScript = async () => {
createSlotItem()
doc = new jsPDF("p", "pt", "letter")
diff --git a/src/store/item.ts b/src/store/item.ts
index 38b3495515..748697e753 100644
--- a/src/store/item.ts
+++ b/src/store/item.ts
@@ -207,6 +207,34 @@ export const useItemStore = defineStore("item", {
this.scriptItemList = filteredArray
this.saveData(podcastname, docname)
},
+ async moveScript(
+ slot: number,
+ position: string,
+ podcastname: string,
+ docname: string
+ ) {
+ if (position == "top" && slot !== 7) {
+ this.scriptItemList.map((item) => {
+ if (item.slot === slot) {
+ item.slot = item.slot + 1
+ } else if (item.slot === slot + 1) {
+ item.slot = item.slot - 1
+ }
+ })
+ } else if (slot !== 1) {
+ this.scriptItemList.map((item) => {
+ if (item.slot === slot) {
+ item.slot = item.slot - 1
+ } else if (item.slot === slot - 1) {
+ item.slot = item.slot + 1
+ }
+
+ })
+ }
+
+
+ this.saveData(podcastname, docname)
+ },
async deleteScriptClipField(id: string, podcastname: string, docname: string) {
let selectedIndex = 0
@@ -216,7 +244,7 @@ export const useItemStore = defineStore("item", {
}
})
this.scriptItemList.splice(selectedIndex, 1)
- this.saveData(podcastname, docname)
+ this.saveData(podcastname, docname)
},
connect(podcastname: string, docname: string) {
onSnapshot(doc(db, podcastname, docname), (doc) => {
@@ -224,13 +252,13 @@ export const useItemStore = defineStore("item", {
doc.data()?.slotTitles && doc.data()?.slotTitles.length > 0
? doc.data()?.slotTitles
: Array.from({ length: 7 }, () => "") ??
- Array.from({ length: 7 }, () => "")
+ Array.from({ length: 7 }, () => "")
) as string[]
this.scriptSlotTitleList = (
doc.data()?.scriptSlotTitleList && doc.data()?.scriptSlotTitleList.length > 0
? doc.data()?.scriptSlotTitleList
: Array.from({ length: 7 }, () => "") ??
- Array.from({ length: 7 }, () => "")
+ Array.from({ length: 7 }, () => "")
) as string[]
this.itemList = (doc.data()?.items ?? []) as Item[]
this.scriptItemList = (doc.data()?.script ?? []) as Item[]