Skip to content

Commit 5fca9bf

Browse files
committed
add & update badges for tag input & tag filter with tag counts
1 parent 8e1c059 commit 5fca9bf

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

frontend/src/components/ui/tag-input.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { customElement, property, query, state } from "lit/decorators.js";
1717
import debounce from "lodash/fp/debounce";
1818

1919
import type { UnderlyingFunction } from "@/types/utils";
20+
import { type WorkflowTags } from "@/types/workflow";
2021
import { dropdown } from "@/utils/css";
2122

2223
export type Tags = string[];
@@ -116,7 +117,7 @@ export class TagInput extends LitElement {
116117
initialTags?: Tags;
117118

118119
@property({ type: Array })
119-
tagOptions: Tags = [];
120+
tagOptions: WorkflowTags = [];
120121

121122
@property({ type: Boolean })
122123
disabled = false;
@@ -259,10 +260,14 @@ export class TagInput extends LitElement {
259260
>
260261
${this.tagOptions
261262
.slice(0, 3)
263+
.filter(({ tag }) => !this.tags.includes(tag))
262264
.map(
263-
(tag) => html`
265+
({ tag, count }) => html`
264266
<sl-menu-item role="option" value=${tag}
265-
>${tag}</sl-menu-item
267+
>${tag}
268+
<btrix-badge pill variant="cyan" slot="suffix"
269+
>${count}</btrix-badge
270+
></sl-menu-item
266271
>
267272
`,
268273
)}

frontend/src/features/archived-items/file-uploader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class FileUploader extends BtrixElement {
7171
private collectionIds: string[] = [];
7272

7373
@state()
74-
private tagOptions: Tags = [];
74+
private tagOptions: WorkflowTags = [];
7575

7676
@state()
7777
private tagsToSave: Tags = [];
@@ -358,7 +358,7 @@ export class FileUploader extends BtrixElement {
358358
private readonly onTagInput = (e: TagInputEvent) => {
359359
const { value } = e.detail;
360360
if (!value) return;
361-
this.tagOptions = this.fuse.search(value).map(({ item }) => item.tag);
361+
this.tagOptions = this.fuse.search(value).map(({ item }) => item);
362362
};
363363

364364
private async fetchTags() {

frontend/src/features/archived-items/item-metadata-editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class CrawlMetadataEditor extends LiteElement {
4747
private includeName = false;
4848

4949
@state()
50-
private tagOptions: Tags = [];
50+
private tagOptions: WorkflowTags = [];
5151

5252
@state()
5353
private tagsToSave: Tags = [];
@@ -160,7 +160,7 @@ export class CrawlMetadataEditor extends LiteElement {
160160
private readonly onTagInput = (e: TagInputEvent) => {
161161
const { value } = e.detail;
162162
if (!value) return;
163-
this.tagOptions = this.fuse.search(value).map(({ item }) => item.tag);
163+
this.tagOptions = this.fuse.search(value).map(({ item }) => item);
164164
};
165165

166166
private async fetchTags() {

frontend/src/features/crawl-workflows/workflow-editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export class WorkflowEditor extends BtrixElement {
262262
private showCrawlerChannels = false;
263263

264264
@state()
265-
private tagOptions: string[] = [];
265+
private tagOptions: WorkflowTags = [];
266266

267267
@state()
268268
private isSubmitting = false;
@@ -2531,7 +2531,7 @@ https://archiveweb.page/images/${"logo.svg"}`}
25312531
private readonly onTagInput = (e: TagInputEvent) => {
25322532
const { value } = e.detail;
25332533
if (!value) return;
2534-
this.tagOptions = this.fuse.search(value).map(({ item }) => item.tag);
2534+
this.tagOptions = this.fuse.search(value).map(({ item }) => item);
25352535
};
25362536

25372537
private async fetchTags() {

frontend/src/features/crawl-workflows/workflow-tag-filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class WorkflowTagFilter extends BtrixElement {
249249
value=${tag.tag}
250250
?checked=${checked}
251251
>${tag.tag}
252-
<btrix-badge variant="high-contrast">${tag.count}</btrix-badge>
252+
<btrix-badge pill variant="cyan">${tag.count}</btrix-badge>
253253
</sl-checkbox>
254254
</li>
255255
`;

0 commit comments

Comments
 (0)