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