Reimplement "Show Duplicates" button in editor (#1550)

* Add "Show duplicates" to LabelContainer

* Avoid bubbling down the duplicate logic into EditorField

* Move duplicate link into its own slot

to center it between name/description and field-state.

* Revert "Move duplicate link into its own slot"

This reverts commit 3a4511042d.

* Justify dupes within FieldState

to achieve the same result as before while avoiding additional logic within EditorField.

Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>
This commit is contained in:
Matthias Metelka 2021-12-13 05:06:12 +01:00 committed by GitHub
parent 4966f3cc44
commit cc5ba4ed84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -127,7 +127,7 @@ class Editor:
# then load page
self.web.stdHtml(
"", # % tr.editing_show_duplicates(),
"",
css=["css/editor.css"],
js=["js/editor.js"],
context=self,

View file

@ -0,0 +1,25 @@
<!--
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);
text-align: center;
flex-grow: 1;
}
</style>

View file

@ -2,13 +2,15 @@
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<span class="field-state justify-content-between">
<span class="field-state justify-content-end">
<slot />
</span>
<style lang="scss">
.field-state {
display: flex;
justify-content: flex;
flex-grow: 1;
& > :global(*) {
margin-left: 2px;

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 Absolute from "../components/Absolute.svelte";
import Badge from "../components/Badge.svelte";
import DuplicateLink from "./DuplicateLink.svelte";
import DecoratedElements from "./DecoratedElements.svelte";
import RichTextInput from "./RichTextInput.svelte";
@ -299,6 +300,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
: "transparent"}
>
<svelte:fragment slot="field-state">
{#if cols[index] === "dupe"}
<DuplicateLink />
{/if}
<RichTextBadge bind:off={richTextsHidden[index]} />
<PlainTextBadge bind:off={plainTextsHidden[index]} />
{#if stickies}