mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Remove special treatment of last tag
This commit is contained in:
parent
e80e6ff34b
commit
e68f874c80
1 changed files with 22 additions and 34 deletions
|
@ -19,6 +19,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
let tags = initialNames.map((name) => attachId(name));
|
let tags = initialNames.map((name) => attachId(name));
|
||||||
|
|
||||||
|
function isFirst(index: number): boolean {
|
||||||
|
return index === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLast(index: number): boolean {
|
||||||
|
return index === tags.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
function addEmptyTag(): void {
|
function addEmptyTag(): void {
|
||||||
if (tags[tags.length - 1].name.length === 0) {
|
if (tags[tags.length - 1].name.length === 0) {
|
||||||
tags[tags.length - 1].active = true;
|
tags[tags.length - 1].active = true;
|
||||||
|
@ -111,18 +119,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}
|
}
|
||||||
|
|
||||||
async function moveToNextTag(index: number): Promise<void> {
|
async function moveToNextTag(index: number): Promise<void> {
|
||||||
if (index === tags.length - 2) {
|
if (isLast(index)) {
|
||||||
|
addEmptyTag();
|
||||||
return;
|
return;
|
||||||
// TODO
|
|
||||||
} else if (index === tags.length - 1) {
|
|
||||||
tags[index].active = false;
|
|
||||||
tags = tags;
|
|
||||||
|
|
||||||
await tick();
|
|
||||||
/* focusNewInput(); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tags[index].active = false;
|
|
||||||
tags[index + 1].active = true;
|
tags[index + 1].active = true;
|
||||||
tags = tags;
|
tags = tags;
|
||||||
|
|
||||||
|
@ -143,7 +144,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let:destroyAutocomplete
|
let:destroyAutocomplete
|
||||||
>
|
>
|
||||||
{#each tags as tag, index (tag.id)}
|
{#each tags as tag, index (tag.id)}
|
||||||
{#if index !== tags.length - 1}
|
|
||||||
<Tag
|
<Tag
|
||||||
bind:name={tag.name}
|
bind:name={tag.name}
|
||||||
bind:active={tag.active}
|
bind:active={tag.active}
|
||||||
|
@ -156,18 +156,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
on:tagmoveprevious={() => moveToPreviousTag(index)}
|
on:tagmoveprevious={() => moveToPreviousTag(index)}
|
||||||
on:tagmovenext={() => moveToNextTag(index)}
|
on:tagmovenext={() => moveToNextTag(index)}
|
||||||
/>
|
/>
|
||||||
{:else}
|
|
||||||
<Tag
|
|
||||||
bind:name={tag.name}
|
|
||||||
bind:active={tag.active}
|
|
||||||
bind:blink={tag.blink}
|
|
||||||
on:tagupdate={() => addTagAt(index)}
|
|
||||||
on:tagadd={() => insertTagAt(index)}
|
|
||||||
on:tagjoinprevious={() => joinWithPreviousTag(index)}
|
|
||||||
on:tagmoveprevious={() => moveToPreviousTag(index)}
|
|
||||||
on:tagmovenext={() => moveToNextTag(index)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Reference in a new issue