[feat] prevent sort when opened
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
import TextAreaInput from "../../UI/GUI/TextAreaInput.svelte";
|
||||
export let value:loreBook
|
||||
export let onRemove: () => void = () => {}
|
||||
export let onClose: () => void = () => {}
|
||||
export let onOpen: () => void = () => {}
|
||||
|
||||
export let idx:number
|
||||
let open = false
|
||||
</script>
|
||||
@@ -19,12 +22,21 @@
|
||||
<button class="endflex valuer border-borderc" on:click={() => {
|
||||
value.secondkey = value.secondkey ?? ''
|
||||
open = !open
|
||||
if(open){
|
||||
onOpen()
|
||||
}
|
||||
else{
|
||||
onClose()
|
||||
}
|
||||
}}>
|
||||
<span>{value.comment.length === 0 ? value.key.length === 0 ? "Unnamed Lore" : value.key : value.comment}</span>
|
||||
</button>
|
||||
<button class="valuer" on:click={async () => {
|
||||
const d = await alertConfirm(language.removeConfirm + value.comment)
|
||||
if(d){
|
||||
if(!open){
|
||||
onClose()
|
||||
}
|
||||
onRemove()
|
||||
}
|
||||
}}>
|
||||
|
||||
@@ -48,6 +48,21 @@
|
||||
}
|
||||
onMount(createStb)
|
||||
|
||||
let opened = 0
|
||||
|
||||
const onOpen = () => {
|
||||
opened += 1
|
||||
if(stb){
|
||||
stb.destroy()
|
||||
}
|
||||
}
|
||||
const onClose = () => {
|
||||
opened -= 1
|
||||
if(opened === 0){
|
||||
createStb()
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
if(stb){
|
||||
stb.destroy()
|
||||
@@ -67,7 +82,7 @@
|
||||
let lore = $DataBase.loreBook[$DataBase.loreBookPage].data
|
||||
lore.splice(i, 1)
|
||||
$DataBase.loreBook[$DataBase.loreBookPage].data = lore
|
||||
}}/>
|
||||
}} onOpen={onOpen} onClose={onClose}/>
|
||||
{/each}
|
||||
{/if}
|
||||
{:else if submenu === 0}
|
||||
@@ -79,7 +94,7 @@
|
||||
let lore = $DataBase.characters[$selectedCharID].globalLore
|
||||
lore.splice(i, 1)
|
||||
$DataBase.characters[$selectedCharID].globalLore = lore
|
||||
}}/>
|
||||
}} onOpen={onOpen} onClose={onClose}/>
|
||||
{/each}
|
||||
{/if}
|
||||
{:else if submenu === 1}
|
||||
@@ -91,7 +106,7 @@
|
||||
let lore = $DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].localLore
|
||||
lore.splice(i, 1)
|
||||
$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].localLore = lore
|
||||
}}/>
|
||||
}} onOpen={onOpen} onClose={onClose}/>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
export let value:customscript
|
||||
export let onRemove: () => void = () => {}
|
||||
export let onClose: () => void = () => {}
|
||||
export let onOpen: () => void = () => {}
|
||||
|
||||
export let idx:number
|
||||
let open = false
|
||||
</script>
|
||||
@@ -18,12 +21,21 @@
|
||||
<div class="flex items-center transition-colors w-full ">
|
||||
<button class="endflex valuer border-borderc" on:click={() => {
|
||||
open = !open
|
||||
if(open){
|
||||
onOpen()
|
||||
}
|
||||
else{
|
||||
onClose()
|
||||
}
|
||||
}}>
|
||||
<span>{value.comment.length === 0 ? 'Unnamed Script' : value.comment}</span>
|
||||
</button>
|
||||
<button class="valuer" on:click={async () => {
|
||||
const d = await alertConfirm(language.removeConfirm + value.comment)
|
||||
if(d){
|
||||
if(!open){
|
||||
onClose()
|
||||
}
|
||||
onRemove()
|
||||
}
|
||||
}}>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
let stb: Sortable = null
|
||||
let ele: HTMLDivElement
|
||||
let sorted = 0
|
||||
let opened = 0
|
||||
const createStb = () => {
|
||||
stb = Sortable.create(ele, {
|
||||
onEnd: async () => {
|
||||
@@ -27,6 +28,20 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onOpen = () => {
|
||||
opened += 1
|
||||
if(stb){
|
||||
stb.destroy()
|
||||
}
|
||||
}
|
||||
const onClose = () => {
|
||||
opened -= 1
|
||||
if(opened === 0){
|
||||
createStb()
|
||||
}
|
||||
}
|
||||
|
||||
onMount(createStb)
|
||||
|
||||
onDestroy(() => {
|
||||
@@ -42,7 +57,7 @@
|
||||
{/if}
|
||||
{#key sorted}
|
||||
{#each value as customscript, i}
|
||||
<RegexData idx={i} bind:value={value[i]} onRemove={() => {
|
||||
<RegexData idx={i} bind:value={value[i]} onOpen={onOpen} onClose={onClose} onRemove={() => {
|
||||
let customscript = value
|
||||
customscript.splice(i, 1)
|
||||
value = customscript
|
||||
|
||||
Reference in New Issue
Block a user