From bd9ffe1abe51ebb136dd09dd87600b56b874ef3d Mon Sep 17 00:00:00 2001 From: Shanti Infosoft <105204781+ArindamReact@users.noreply.github.com> Date: Thu, 1 Sep 2022 01:01:25 +0530 Subject: [PATCH] SCRIPT: Ability to rearrange order of stories #490 (#533) * not done * stable * sonar issue fixed --- src/pages/Home.vue | 18 +++++++++--------- src/store/item.ts | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/pages/Home.vue b/src/pages/Home.vue index f40c522699..ed2a657347 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -182,14 +182,8 @@ /> -
-
+
+
{ 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[]