Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c51f3bcc30 | |||
| b1995a1dce | |||
| 92a5282e36 | |||
| 6e4aba02dc |
6 changed files with 38 additions and 22 deletions
|
|
@ -20,6 +20,8 @@ as well as making it so all of the images load faster on your player's computers
|
|||
|
||||
# Disclaimer:
|
||||
This module is currently in beta testing, as such there may be bugs and missing
|
||||
features. To report bugs or request features you can open an issue on the
|
||||
[Public Issue Tracker](https://git.varify.ca/Foundry/image-tagger/issues) or you
|
||||
can send an email to [hello@varify.ca](mailto:hello@varify.ca).
|
||||
features. To report bugs or request features you can:
|
||||
- open an issue on the
|
||||
[primary issue tracker](https://git.varify.ca/Foundry/image-tagger/issues)
|
||||
- send an email to [hello@varify.ca](mailto:hello@varify.ca)
|
||||
- or, open an issue on [Github](https://github.com/Eldritch-Oliver/Foundry-Image-Tagger/issues/new)
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@
|
|||
"tags": "Tags",
|
||||
"select": "Select",
|
||||
"links": "Links",
|
||||
"sort-by": "Sort By"
|
||||
"sort-by": "Sort By",
|
||||
"page-reset-warning":"Changing any of these will reset your page to 1."
|
||||
},
|
||||
"apps": {
|
||||
"ArtBrowser": {
|
||||
"selected": "{current}/{required} Selected",
|
||||
"upload-image": "Upload Image",
|
||||
"no-results": "No results were found for that search",
|
||||
"select-image": "Select image",
|
||||
"page-reset-warning": "Changing any of these will reset your page to 1."
|
||||
"select-image": "Select image"
|
||||
},
|
||||
"ArtistBrowser": {
|
||||
"sort-options": {
|
||||
|
|
|
|||
|
|
@ -272,6 +272,7 @@ export class ArtBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
event.stopPropagation();
|
||||
const data = (new FormDataExtended(event.currentTarget)).object;
|
||||
this.filters = data;
|
||||
this.#page = 1;
|
||||
this.render({ parts: [`images`] });
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
if (this.#page == page) { return };
|
||||
this.#page = page;
|
||||
if (this.rendered) {
|
||||
await this.render({ parts: [`images`] });
|
||||
await this.render({ parts: [`list`] });
|
||||
return;
|
||||
};
|
||||
return;
|
||||
|
|
@ -152,6 +152,24 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
const allArtists = Object.entries(deepClone(this.#artistDB.data));
|
||||
const allImages = Object.values(this.#imagesDB.data);
|
||||
|
||||
/*
|
||||
This collates all of the image data into the required summary data for the
|
||||
display of the artists. Because this does the collation all in one iteration
|
||||
it is a more performant way of collecting all of the information once the
|
||||
databases get larger
|
||||
*/
|
||||
const summary = {};
|
||||
for (const image of allImages) {
|
||||
for (const artistID of image.artists) {
|
||||
summary[artistID] ??= { count: 0, tags: {} };
|
||||
summary[artistID].count++;
|
||||
for (const tag of image.tags) {
|
||||
summary[artistID].tags[tag] ??= { name: tag, count: 0 };
|
||||
summary[artistID].tags[tag].count++;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
const artists = [];
|
||||
for (const [id, artist] of allArtists) {
|
||||
// Check if it matches the required filters
|
||||
|
|
@ -162,20 +180,8 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
// Populate ephemeral data for rendering
|
||||
artist.id = id;
|
||||
|
||||
let imageCount = 0;
|
||||
let tags = {};
|
||||
|
||||
for (const image of allImages) {
|
||||
if (!image.artists.includes(id)) continue;
|
||||
imageCount++;
|
||||
for (const tag of image.tags) {
|
||||
tags[tag] ??= { name: tag, count: 0 };
|
||||
tags[tag].count++;
|
||||
};
|
||||
};
|
||||
|
||||
artist.imageCount = imageCount;
|
||||
artist.commonTags = Object.values(tags)
|
||||
artist.imageCount = summary[id].count;
|
||||
artist.commonTags = Object.values(summary[id].tags)
|
||||
.sort((a, b) => b.count - a.count)
|
||||
.slice(0, 5);
|
||||
|
||||
|
|
@ -200,6 +206,7 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const data = (new FormDataExtended(event.currentTarget)).object;
|
||||
this.#page = 1;
|
||||
this.filters = data;
|
||||
this.render({ parts: [`list`] });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<form autocomplete="off" class="filters">
|
||||
<p>
|
||||
{{localize "IT.apps.ArtBrowser.page-reset-warning"}}
|
||||
{{localize "IT.common.page-reset-warning"}}
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
<form autocomplete="off" class="filters">
|
||||
<p>
|
||||
{{localize "IT.common.page-reset-warning"}}
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<label for="{{meta.idp}}-name">
|
||||
{{localize "IT.common.name"}}
|
||||
</label>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue