Skip to content

Filter imports by list of item#177

Open
darthbeep wants to merge 4 commits into
TheGiddyLimit:developmentfrom
darthbeep:feature/list-importer
Open

Filter imports by list of item#177
darthbeep wants to merge 4 commits into
TheGiddyLimit:developmentfrom
darthbeep:feature/list-importer

Conversation

@darthbeep
Copy link
Copy Markdown

Allows you to filter what imports are shown by a list of items when importing.

Comment thread js/5etools-importer.js
})

// Filters to match names and sources on the list
x = importList
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

junk line(?)

Comment thread js/5etools-importer.js
$btnImport.on("click", () => {

function filterList () {
const toSearch = $winText.val().toLowerCase().replaceAll(`"`, "").split("\n");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$winText.val().toLowerCase().replaceAll(", "").split("\n"); ->

$winText.val().toLowerCase().replaceAll(`"`, "").split("\n").map(it => it.trim()).filter(Boolean);

Comment thread js/5etools-importer.js
$btnImport.on("click", () => {

function filterList () {
const toSearch = $winText.val().toLowerCase().replaceAll(`"`, "").split("\n");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have quotes in the input, we should respect them; e.g. "Namedcreature, Bringer of Fun","QWE" should be parsed as name=Namedcreature, Bringer of Fun source=QWE; currently this parses it as name=Namedcreature source=Bringer of Fun?

some generic CSV parsing ought to do the trick; should be simple enough to put in a utility function for it and call it good

Comment thread js/5etools-importer.js
"name": items[0].trim(),
"source": items.length > 1 ? items[1].trim() : null,
// Some categories list their source in this format
"altsource": items.length > 1 ? `src[${items[1].trim()}]`: null,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make everything uniformly use one style, then remove this workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants