Merge branch 'master' into ai/issue-79
All checks were successful
Test / test (push) Successful in 2s
All checks were successful
Test / test (push) Successful in 2s
This commit is contained in:
@@ -8,6 +8,7 @@ import { emitter } from '~/services/Emitter';
|
||||
import { BuildColorMenu } from '~/services/EntryColors';
|
||||
import { BuildItemRows } from '~/services/ItemFolders';
|
||||
import Server, { getBaseUrl } from '~/services/Server';
|
||||
import { DisplayToast } from '~/services/Toaster';
|
||||
import { ClearWindow, CreateWindow, GetFirstWindowId } from '~/services/Windows';
|
||||
import { HideContextMenu, ShowContextMenu } from '~/services/ContextMenu';
|
||||
import { ACTOR_DRAG_TYPE } from '~/services/MapTokens';
|
||||
@@ -29,6 +30,9 @@ const entryFolders = { actor: ref([]), item: ref([]), map: ref([]) };
|
||||
const collapsedFolderIds = ref([]);
|
||||
const loadingNotes = ref(false);
|
||||
const loadingEntries = ref(false);
|
||||
// An import of the whole linked world takes a moment, and clicking the row again while
|
||||
// it runs must not start a second one.
|
||||
const importingFoundry = ref(false);
|
||||
const notesError = ref('');
|
||||
const entriesError = ref('');
|
||||
const sidebarCollapsed = ref(false);
|
||||
@@ -309,6 +313,35 @@ function editMap(map) {
|
||||
CreateWindow('create_map', { campaign: campaignId.value, entry: map });
|
||||
}
|
||||
|
||||
// The one sidebar action that asks the linked world instead of the campaign's own rows
|
||||
// (Syndria98/dragonroll#77): the backend reads what the Foundry bridge is showing and
|
||||
// writes every actor or item of it through the writers a sync push uses, so the rows
|
||||
// the campaign already has are written over and only the world's new ones are made.
|
||||
// The list is read back once the answer is in, so whatever arrived is on screen, and
|
||||
// the toast says how the world landed.
|
||||
async function forceImportFromFoundry(entityType) {
|
||||
const section = sectionForTarget(entityType);
|
||||
if (!campaignId.value || !section || importingFoundry.value) return;
|
||||
|
||||
importingFoundry.value = true;
|
||||
try {
|
||||
const response = await Server().post('/foundry/import', { campaign: campaignId.value, kind: section });
|
||||
if (response.data.status !== 'ok') {
|
||||
DisplayToast('red', t(response.data.msg || 'campaigns.foundry-import.error'), 3000);
|
||||
return;
|
||||
}
|
||||
DisplayToast('green', t('campaigns.foundry-import.done', {
|
||||
imported: response.data.imported ?? 0,
|
||||
updated: response.data.updated ?? 0
|
||||
}), 3000);
|
||||
await fetchCampaignEntries(section);
|
||||
} catch (error) {
|
||||
DisplayToast('red', t('campaigns.foundry-import.error'), 3000);
|
||||
} finally {
|
||||
importingFoundry.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function showEntryMenu(entry, entityType) {
|
||||
const list = entryLists[entityType];
|
||||
const menuItems = [];
|
||||
@@ -328,6 +361,18 @@ function showEntryMenu(entry, entityType) {
|
||||
});
|
||||
}
|
||||
|
||||
// The actor and item lists mirror a linked Foundry world, so their rows also offer
|
||||
// to pull the whole world over: this row is not sent or fetched on its own, the
|
||||
// section's whole list is imported and the rows already in it are only updated.
|
||||
if (entityType === 'actor' || entityType === 'item') {
|
||||
menuItems.push({ divider: true });
|
||||
menuItems.push({
|
||||
name: t('campaigns.foundry-import.run'),
|
||||
icon: '/icons/iconoir/regular/import.svg',
|
||||
action: () => { HideContextMenu(); forceImportFromFoundry(entityType); }
|
||||
});
|
||||
}
|
||||
|
||||
// Rows of every section can be filed into a folder of their own list, like a note
|
||||
// into a folder of the note tree.
|
||||
menuItems.push({
|
||||
|
||||
@@ -62,7 +62,12 @@ async function Load(dir, offset = 0) {
|
||||
? { ...page, files: [...listing.value.files, ...page.files] }
|
||||
: page;
|
||||
} catch (requestError) {
|
||||
error.value = t('foundry.errors.icons-unavailable');
|
||||
// The route answers every real failure with an i18n key in `msg`, but
|
||||
// axios rejects a non-2xx response, so this catch would otherwise blame
|
||||
// the bridge for anything at all — a campaign without a world address,
|
||||
// a folder that went missing. Read the reason off the response and say
|
||||
// that instead (Syndria98/dragonroll#74).
|
||||
error.value = t(requestError.response?.data?.msg || 'foundry.errors.icons-unavailable');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@
|
||||
"rename": "Canvia el nom", "color": "Color", "default": "Per defecte", "delete": "Suprimeix la carpeta",
|
||||
"move-to": "Mou a carpeta...", "root": "Arrel"
|
||||
},
|
||||
"foundry-import": {
|
||||
"run": "Força la importació des del Foundry",
|
||||
"done": "Importat del Foundry: {imported} nous, {updated} actualitzats.",
|
||||
"error": "No s'ha pogut importar des del món del Foundry vinculat."
|
||||
},
|
||||
"states": {
|
||||
"loading": "Carregant...", "loading-notes": "Carregant notes...", "empty-notes": "Encara no hi ha notes en aquesta campanya.",
|
||||
"empty-actors": "Encara no hi ha actors ni personatges.", "empty-items": "Encara no hi ha objectes en aquesta campanya.",
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
"actor-already-synced": "Un altre actor d'aquesta campanya ja està sincronitzat amb aquell actor del Foundry.",
|
||||
"item-already-synced": "Un altre objecte d'aquesta campanya ja està sincronitzat amb aquell objecte del Foundry.",
|
||||
"icons-unavailable": "Les icones del Foundry no són disponibles: el seu bridge no està configurat o ara mateix no hi arriba.",
|
||||
"icons-no-world-url": "Aquesta campanya no té adreça del món del Foundry. Definiu-la als ajustos de la campanya, a la pestanya d'integracions."
|
||||
"icons-no-world-url": "Aquesta campanya no té adreça del món del Foundry. Definiu-la als ajustos de la campanya, a la pestanya d'integracions.",
|
||||
"import-not-linked": "Aquesta campanya no té cap món del Foundry vinculat. Connecteu-ne un als ajustos de la campanya, a la pestanya d'integracions.",
|
||||
"import-unavailable": "Les dades del Foundry no són disponibles: el seu bridge no està configurat, ara mateix no hi arriba o el seu món encara no ha publicat res.",
|
||||
"import-world-mismatch": "El bridge del Foundry està mostrant un món diferent del que aquesta campanya té vinculat."
|
||||
},
|
||||
"icons": {
|
||||
"path": "Carpeta d'icones",
|
||||
|
||||
@@ -53,6 +53,11 @@
|
||||
"rename": "Rename", "color": "Color", "default": "Default", "delete": "Delete folder",
|
||||
"move-to": "Move to folder...", "root": "Root"
|
||||
},
|
||||
"foundry-import": {
|
||||
"run": "Force import from Foundry",
|
||||
"done": "Imported from Foundry: {imported} new, {updated} updated.",
|
||||
"error": "Unable to import from the linked Foundry world."
|
||||
},
|
||||
"states": {
|
||||
"loading": "Loading...", "loading-notes": "Loading notes...", "empty-notes": "No notes in this campaign yet.",
|
||||
"empty-actors": "No actors or characters yet.", "empty-items": "No items in this campaign yet.",
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
"actor-already-synced": "Another actor in this campaign is already synced with that Foundry actor.",
|
||||
"item-already-synced": "Another item in this campaign is already synced with that Foundry item.",
|
||||
"icons-unavailable": "Foundry's icons are not available: its bridge is not set up, or it cannot be reached right now.",
|
||||
"icons-no-world-url": "This campaign has no Foundry world address. Set it under campaign settings, in the Integrations tab."
|
||||
"icons-no-world-url": "This campaign has no Foundry world address. Set it under campaign settings, in the Integrations tab.",
|
||||
"import-not-linked": "This campaign has no Foundry world linked to it. Connect one under campaign settings, in the Integrations tab.",
|
||||
"import-unavailable": "Foundry's data is not available: its bridge is not set up, it cannot be reached right now, or its world has not published anything yet.",
|
||||
"import-world-mismatch": "The Foundry bridge is showing another world than the one this campaign is linked to."
|
||||
},
|
||||
"icons": {
|
||||
"path": "Icon folder",
|
||||
|
||||
@@ -49,6 +49,11 @@
|
||||
"rename": "Renombrar", "color": "Color", "default": "Por defecto", "delete": "Eliminar carpeta",
|
||||
"move-to": "Mover a carpeta...", "root": "Raíz"
|
||||
},
|
||||
"foundry-import": {
|
||||
"run": "Forzar importación desde Foundry",
|
||||
"done": "Importado desde Foundry: {imported} nuevos, {updated} actualizados.",
|
||||
"error": "No se ha podido importar desde el mundo de Foundry vinculado."
|
||||
},
|
||||
"states": {
|
||||
"loading": "Cargando...", "loading-notes": "Cargando notas...", "empty-notes": "Aún no hay notas en esta campaña.",
|
||||
"empty-actors": "Aún no hay actores ni personajes.", "empty-items": "Aún no hay objetos en esta campaña.",
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
"actor-already-synced": "Otro actor de esta campaña ya está sincronizado con ese actor de Foundry.",
|
||||
"item-already-synced": "Otro objeto de esta campaña ya está sincronizado con ese objeto de Foundry.",
|
||||
"icons-unavailable": "Los iconos de Foundry no están disponibles: su bridge no está configurado o no es accesible ahora.",
|
||||
"icons-no-world-url": "Esta campaña no tiene dirección del mundo de Foundry. Defínala en los ajustes de la campaña, en la pestaña de integraciones."
|
||||
"icons-no-world-url": "Esta campaña no tiene dirección del mundo de Foundry. Defínala en los ajustes de la campaña, en la pestaña de integraciones.",
|
||||
"import-not-linked": "Esta campaña no tiene ningún mundo de Foundry vinculado. Conecte uno en los ajustes de la campaña, en la pestaña de integraciones.",
|
||||
"import-unavailable": "Los datos de Foundry no están disponibles: su bridge no está configurado, no es accesible ahora o su mundo todavía no ha publicado nada.",
|
||||
"import-world-mismatch": "El bridge de Foundry está mostrando un mundo distinto del que esta campaña tiene vinculado."
|
||||
},
|
||||
"icons": {
|
||||
"path": "Carpeta de iconos",
|
||||
|
||||
Reference in New Issue
Block a user