Fix first-start issues

This commit is contained in:
Brieuc Dubois 2024-01-03 01:36:21 +01:00
parent 9d38545179
commit 157cd74826
7 changed files with 52 additions and 38 deletions

View File

@ -7,7 +7,6 @@
export let card: Card;
</script>
<!-- on:dragend={() => currentDraggedCard.set(null)} -->
<div
class="card"
tabindex="0"

View File

@ -4,7 +4,7 @@
export let isOpen = false;
export let choices: { id: number; value: string }[] = [];
export let onChoice = (id: number) => {};
export let currentChoice: number = -1;
export let currentChoice: number;
</script>
<Menu {isOpen}>

View File

@ -6,7 +6,7 @@
import GroupMenu from './groupMenu.svelte';
export let project: Project;
export let currentTagId: number;
export let view: View;
let groupMenuOpen = false;
function getEmptyTags(): TagValue[] {
@ -44,7 +44,7 @@
<div>
<button
on:click={() => (groupMenuOpen = !groupMenuOpen)}
class:defined={$currentView?.primary_tag_id}>Group</button
class:defined={$currentView?.primary_tag_id !== -1}>Group</button
>
<GroupMenu
isOpen={groupMenuOpen}
@ -53,7 +53,7 @@
if (!(await setGroup(id))) return;
groupMenuOpen = false;
}}
currentChoice={currentTagId}
currentChoice={view?.primary_tag_id}
/>
</div>
<div>

View File

@ -25,29 +25,40 @@
{#if project}
<section>
{#if view && $projectTags[view.primary_tag_id] && $cards}
<Header {project} currentTagId={view.primary_tag_id} />
<div class="grid">
{#each $projectTags[view.primary_tag_id].options as option}
{#if view}
<Header {project} {view} />
{#if cards}
<div class="grid">
{#if view.primary_tag_id !== -1}
{#each $projectTags[view.primary_tag_id].options as option}
<Column
{option}
columnCards={$cards.filter((c) =>
c.tags.map((t) => t.option_id).includes(option.id)
)}
projectId={project.id}
/>
{/each}
{/if}
<Column
{option}
columnCards={$cards.filter((c) => c.tags.map((t) => t.option_id).includes(option.id))}
option={{
id: -1,
tag_id: view.primary_tag_id,
value:
view.primary_tag_id !== -1
? `No ${$projectTags[view.primary_tag_id].title}`
: 'No groups'
}}
columnCards={view.primary_tag_id !== -1
? $cards.filter(
(c) => !c.tags.map((t) => t.tag_id).includes(view?.primary_tag_id || -2)
)
: $cards}
projectId={project.id}
editable={false}
/>
{/each}
<Column
option={{
id: -1,
tag_id: view.primary_tag_id,
value: `No ${$projectTags[view.primary_tag_id].title}`
}}
columnCards={$cards.filter(
(c) => !c.tags.map((t) => t.tag_id).includes(view?.primary_tag_id || -2)
)}
projectId={project.id}
editable={false}
/>
</div>
</div>
{/if}
{/if}
</section>
{/if}

View File

@ -6,6 +6,7 @@
import ViewIcon from './icons/viewIcon.svelte';
import projectTags from '../stores/projectTags';
import EditIcon from './icons/editIcon.svelte';
import { get } from 'svelte/store';
export let project: Project;
@ -15,10 +16,10 @@
onMount(async () => {
await views.init(project.id);
if ($views.length > 0) currentView.set($views[0]);
if ($views && $views.length > 0) currentView.set($views[0]);
});
async function newView() {
async function createView() {
if (!$views) return;
const primaryTagId =
@ -35,7 +36,6 @@
}
async function saveView(view: View) {
await tick();
if (!view || !$views.includes(view)) return;
if (viewEditId === view.id && viewEditValue !== view.title) {
if (!(await views.edit(view))) return;
@ -53,10 +53,10 @@
<span id="version">v0.0.1</span>
</div>
<div id="views">
<h2>{project.title}</h2>
{#if views}
<h2>{project.title}</h2>
<ul>
{#each $views as view}
{#each get(views) as view}
<!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
<li
on:click={() => currentView.set(view)}
@ -79,7 +79,7 @@
id="viewTitle-{view.id}"
on:keydown={(e) => {
if (e.key === 'Enter') {
saveView(view);
e.currentTarget.blur();
}
}}
/>
@ -106,12 +106,12 @@
<div class="separator"></div>
<div
id="newView"
on:click={newView}
on:click={createView}
role="button"
tabindex="0"
on:keydown={(e) => {
if (e.key === 'Enter') {
newView();
createView();
}
}}
>

View File

@ -20,10 +20,12 @@ export default {
const tags: { [key: number]: MeTag } = {};
metags.forEach((tag: MeTag) => {
if (tag.options === null) tag.options = [];
tags[tag.id] = tag;
});
if (metags) {
metags.forEach((tag: MeTag) => {
if (tag.options === null) tag.options = [];
tags[tag.id] = tag;
});
}
set(tags);

View File

@ -69,7 +69,9 @@ export const views = (() => {
return false;
}
set(response.data);
if (response.data) {
set(response.data);
}
return true;
};