Fix open newly created card and on column change

This commit is contained in:
Brieuc Dubois 2024-01-17 01:14:57 +01:00
parent 4a3d768aa1
commit c39b2d5b26
5 changed files with 13 additions and 9 deletions

View File

@ -4,7 +4,7 @@
import ModalCard from './ModalCard.svelte'; import ModalCard from './ModalCard.svelte';
export let card: Card; export let card: Card;
export let showModal = false; $: showModal = card.showModal;
</script> </script>
<div <div
@ -34,8 +34,8 @@
</div> </div>
{#if showModal} {#if showModal}
<ModalCard {card} bind:showModal /> <ModalCard {card} />
{/if} {:else}{/if}
<style lang="less"> <style lang="less">
.card { .card {

View File

@ -6,7 +6,6 @@
import { cards } from '$lib/types/Card'; import { cards } from '$lib/types/Card';
export let card: Card; export let card: Card;
export let showModal: boolean;
let newTitle: string = card.title; let newTitle: string = card.title;
let newContent: string = card.content; let newContent: string = card.content;
@ -15,7 +14,7 @@
if (card.title !== newTitle || card.content !== newContent) { if (card.title !== newTitle || card.content !== newContent) {
if (!(await card.update(newTitle, newContent))) return; if (!(await card.update(newTitle, newContent))) return;
} }
if (closeModal) showModal = false; if (closeModal) card.showModal = false;
cards.reload(); cards.reload();
} }
@ -37,12 +36,12 @@
<button <button
on:click|once={async () => { on:click|once={async () => {
await card.delete(); await card.delete();
showModal = false; card.showModal = false;
}} }}
> >
<TrashIcon /> <TrashIcon />
</button> </button>
<button on:click|once={() => (showModal = false)}> <button on:click|once={() => (card.showModal = false)}>
<CloseIcon /> <CloseIcon />
</button> </button>
</div> </div>

View File

@ -68,6 +68,8 @@
} }
cards.reload(); cards.reload();
card.showModal = true;
} }
</script> </script>

View File

@ -29,6 +29,8 @@
} }
isOpen = false; isOpen = false;
cards.reload(); cards.reload();
card.showModal = true;
} }
async function createOption() { async function createOption() {

View File

@ -1,10 +1,10 @@
import cardsApi from '$lib/api/cardsApi'; import cardsApi from '$lib/api/cardsApi';
import { toastAlert } from '$lib/utils/toasts';
import { get, writable } from 'svelte/store'; import { get, writable } from 'svelte/store';
import CardTag from './CardTag'; import CardTag from './CardTag';
import Project from './Project'; import Project from './Project';
import { toastAlert } from '$lib/utils/toasts';
import type TagOption from './TagOption';
import type ProjectTag from './ProjectTag'; import type ProjectTag from './ProjectTag';
import type TagOption from './TagOption';
const { subscribe, set, update } = writable([] as Card[]); const { subscribe, set, update } = writable([] as Card[]);
@ -21,6 +21,7 @@ export default class Card {
private _title: string; private _title: string;
private _content: string; private _content: string;
private _cardTags: CardTag[]; private _cardTags: CardTag[];
public showModal: boolean = false;
private constructor( private constructor(
id: number, id: number,