Skip to content

Commit bff19fa

Browse files
authored
filter collectiosn when editing (#32)
1 parent 75ca460 commit bff19fa

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/components/editItemModal.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,15 @@ export class EditItemModal extends Modal {
160160
const collectionsGroup = form.createEl("div", { cls: "atmosphere-form-group" });
161161
collectionsGroup.createEl("label", { text: "Collections" });
162162

163+
const searchInput = collectionsGroup.createEl("input", {
164+
type: "text",
165+
cls: "atmosphere-input atmosphere-collection-search",
166+
attr: { placeholder: "Search collections..." },
167+
});
168+
163169
const collectionsList = collectionsGroup.createEl("div", { cls: "atmosphere-collection-list" });
170+
171+
const rows: { el: HTMLElement; name: string }[] = [];
164172
for (const state of this.collectionStates) {
165173
const item = collectionsList.createEl("label", { cls: "atmosphere-collection-item" });
166174

@@ -176,7 +184,16 @@ export class EditItemModal extends Modal {
176184

177185
const sourceIcon = item.createEl("span", { cls: "atmosphere-collection-source-icon" });
178186
setIcon(sourceIcon, state.source === "semble" ? "atmosphere-semble" : "atmosphere-margin");
187+
188+
rows.push({ el: item, name: state.name.toLowerCase() });
179189
}
190+
191+
searchInput.addEventListener("input", () => {
192+
const query = searchInput.value.toLowerCase();
193+
for (const row of rows) {
194+
row.el.style.display = row.name.includes(query) ? "" : "none";
195+
}
196+
});
180197
}
181198

182199
const actions = contentEl.createEl("div", { cls: "atmosphere-modal-actions" });

0 commit comments

Comments
 (0)