Merge pull request #1 from hgiesel/editor-show-dupes

Avoid bubbling down the duplicate logic into EditorField
This commit is contained in:
Matthias Metelka 2021-12-10 18:06:35 +01:00 committed by GitHub
commit 027c8595a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 17 deletions

View file

@ -0,0 +1,23 @@
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/ftl";
import { bridgeCommand } from "../lib/bridgecommand";
</script>
<a
class="duplicate-link"
href="/#"
tabindex="-1"
on:click={() => bridgeCommand("dupes")}
>
{tr.editingShowDuplicates()}
</a>
<style lang="scss">
.duplicate-link {
color: var(--highlight-color);
}
</style>

View file

@ -28,7 +28,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/ftl";
import EditingArea from "./EditingArea.svelte"; import EditingArea from "./EditingArea.svelte";
import LabelContainer from "./LabelContainer.svelte"; import LabelContainer from "./LabelContainer.svelte";
import LabelDescription from "./LabelDescription.svelte"; import LabelDescription from "./LabelDescription.svelte";
@ -45,7 +44,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let content: Writable<string>; export let content: Writable<string>;
export let field: FieldData; export let field: FieldData;
export let autofocus = false; export let autofocus = false;
export let dupes = false;
export let api: (Partial<EditorFieldAPI> & Destroyable) | undefined = undefined; export let api: (Partial<EditorFieldAPI> & Destroyable) | undefined = undefined;
@ -77,7 +75,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
on:focusout on:focusout
on:click={() => editingArea.focus?.()} on:click={() => editingArea.focus?.()}
> >
<LabelContainer --label-color={dupes ? "var(--flag1-bg)" : "transparent"}> <LabelContainer>
<span> <span>
<LabelName> <LabelName>
{field.name} {field.name}
@ -86,11 +84,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<LabelDescription description={field.description} /> <LabelDescription description={field.description} />
{/if} {/if}
</span> </span>
{#if dupes}
<span class="dupes" on:click={() => globalThis.pycmd("dupes")}
>{tr.editingShowDuplicates()}
</span>
{/if}
<FieldState><slot name="field-state" /></FieldState> <FieldState><slot name="field-state" /></FieldState>
</LabelContainer> </LabelContainer>
<EditingArea <EditingArea
@ -120,12 +113,4 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
box-shadow: 0 0 0 3px var(--focus-shadow); box-shadow: 0 0 0 3px var(--focus-shadow);
} }
} }
.dupes {
cursor: pointer;
color: var(--highlight-fg);
&:hover {
text-decoration: underline;
}
}
</style> </style>

View file

@ -50,6 +50,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Notification from "./Notification.svelte"; import Notification from "./Notification.svelte";
import Absolute from "../components/Absolute.svelte"; import Absolute from "../components/Absolute.svelte";
import Badge from "../components/Badge.svelte"; import Badge from "../components/Badge.svelte";
import DuplicateLink from "./DuplicateLink.svelte";
import DecoratedElements from "./DecoratedElements.svelte"; import DecoratedElements from "./DecoratedElements.svelte";
import RichTextInput from "./RichTextInput.svelte"; import RichTextInput from "./RichTextInput.svelte";
@ -283,7 +284,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{field} {field}
content={fieldStores[index]} content={fieldStores[index]}
autofocus={index === focusTo} autofocus={index === focusTo}
dupes={cols[index] === "dupe"}
api={fields[index]} api={fields[index]}
on:focusin={() => { on:focusin={() => {
$currentField = fields[index]; $currentField = fields[index];
@ -295,8 +295,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
`blur:${index}:${getNoteId()}:${get(fieldStores[index])}`, `blur:${index}:${getNoteId()}:${get(fieldStores[index])}`,
); );
}} }}
--label-color={cols[index] === "dupe"
? "var(--flag1-bg)"
: "transparent"}
> >
<svelte:fragment slot="field-state"> <svelte:fragment slot="field-state">
{#if cols[index] === "dupe"}
<DuplicateLink />
{/if}
<RichTextBadge bind:off={richTextsHidden[index]} /> <RichTextBadge bind:off={richTextsHidden[index]} />
<PlainTextBadge bind:off={plainTextsHidden[index]} /> <PlainTextBadge bind:off={plainTextsHidden[index]} />
{#if stickies} {#if stickies}