Improves Import to report what was not imported.
parent
8812557607
commit
9dc95f7ff7
|
|
@ -0,0 +1,61 @@
|
||||||
|
const {
|
||||||
|
ApplicationV2,
|
||||||
|
HandlebarsApplicationMixin
|
||||||
|
} = foundry.applications.api
|
||||||
|
|
||||||
|
export class XmlImportReportDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
|
||||||
|
static DEFAULT_OPTIONS = {
|
||||||
|
classes: ['dsa41', 'dialog', 'xmlimport'],
|
||||||
|
tag: "form",
|
||||||
|
position: {
|
||||||
|
width: 320,
|
||||||
|
height: 478
|
||||||
|
},
|
||||||
|
window: {
|
||||||
|
resizable: false,
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
submitOnChange: false,
|
||||||
|
closeOnSubmit: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
static PARTS = {
|
||||||
|
form: {
|
||||||
|
template: 'systems/DSA_4-1/templates/dialog/xml-import-report.hbs',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Actor}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_actor = null
|
||||||
|
_report = null
|
||||||
|
|
||||||
|
constructor(actor, report) {
|
||||||
|
super();
|
||||||
|
this._actor = actor
|
||||||
|
this._report = report
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_configureRenderOptions(options) {
|
||||||
|
super._configureRenderOptions(options)
|
||||||
|
options.window.title = `${this._actor.name} import abgeschlossen`
|
||||||
|
return options
|
||||||
|
}
|
||||||
|
|
||||||
|
async _prepareContext(options) {
|
||||||
|
const context = await super._prepareContext(options)
|
||||||
|
context.report = this._report
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
_onRender(context, options) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -770,7 +770,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
||||||
if (documentClass) {
|
if (documentClass) {
|
||||||
const document = await documentClass.fromDropData(data)
|
const document = await documentClass.fromDropData(data)
|
||||||
|
|
||||||
if (document.type === "Equipment" || document.type === "Advantage" || document.type === "Spell" || document.type === "Liturgy" || document.type === "ActiveEffect" || document.type === "SpecialAbility") {
|
if (document.type === "Equipment" || document.type === "Advantage" || document.type === "Spell" || document.type === "Liturgy" || document.type === "ActiveEffect" || document.type === "SpecialAbility" || document.type === "Skill") {
|
||||||
// No duplication by moving items from one actor to another
|
// No duplication by moving items from one actor to another
|
||||||
|
|
||||||
if ((targetDocument?.name ?? false) === document.name && targetDocument._id !== document._id && await foundry.applications.api.DialogV2.confirm({
|
if ((targetDocument?.name ?? false) === document.name && targetDocument._id !== document._id && await foundry.applications.api.DialogV2.confirm({
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,17 @@ import {Culture} from "../documents/culture.mjs";
|
||||||
import {Species} from "../documents/species.mjs";
|
import {Species} from "../documents/species.mjs";
|
||||||
import {SpecialAbility} from "../documents/specialAbility.mjs";
|
import {SpecialAbility} from "../documents/specialAbility.mjs";
|
||||||
import {Equipment} from "../documents/equipment.mjs";
|
import {Equipment} from "../documents/equipment.mjs";
|
||||||
|
import {XmlImportReportDialog} from "../dialog/xmlImportReportDialog.mjs";
|
||||||
|
|
||||||
export class XmlImport {
|
export class XmlImport {
|
||||||
|
|
||||||
|
#unknownSkills = []
|
||||||
|
#unknownSpells = []
|
||||||
|
#unknownLiturgies = []
|
||||||
|
#unknownItem = []
|
||||||
|
#unknownSpecialAbilities = []
|
||||||
|
#unknownAdvantage = []
|
||||||
|
|
||||||
#months = [
|
#months = [
|
||||||
"Praios",
|
"Praios",
|
||||||
"Rondra",
|
"Rondra",
|
||||||
|
|
@ -88,6 +97,19 @@ export class XmlImport {
|
||||||
let characterJson = this.#mapRawJson(actor, rawJson, options)
|
let characterJson = this.#mapRawJson(actor, rawJson, options)
|
||||||
|
|
||||||
actor.update(characterJson)
|
actor.update(characterJson)
|
||||||
|
|
||||||
|
const sumOfAllUnknowns = this.#unknownSkills.length + this.#unknownSpells.length + this.#unknownLiturgies.length + this.#unknownItem.length + this.#unknownSpecialAbilities.length + this.#unknownAdvantage.length
|
||||||
|
|
||||||
|
if (sumOfAllUnknowns > 0) {
|
||||||
|
const report = []
|
||||||
|
this.#unknownSkills.forEach( i => report.push({name: i, type: "Talent"}))
|
||||||
|
this.#unknownSpells.forEach( i => report.push({name: i, type: "Zauber"}))
|
||||||
|
this.#unknownLiturgies.forEach( i => report.push({name: i, type: "Liturgie"}))
|
||||||
|
this.#unknownItem.forEach( i => report.push({name: i, type: "Gegenstand"}))
|
||||||
|
this.#unknownSpecialAbilities.forEach( i => report.push({name: i, type: "Sonderfertigkeit"}))
|
||||||
|
|
||||||
|
new XmlImportReportDialog(actor, report).render(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -363,6 +385,8 @@ export class XmlImport {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${talentName} not found in items`, error)
|
console.error(`${talentName} not found in items`, error)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.#unknownSkills.push(talentName.trim())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,6 +407,8 @@ export class XmlImport {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${advantageName} not found in items`, error)
|
console.error(`${advantageName} not found in items`, error)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.#unknownAdvantage.push(advantageName.trim())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -401,6 +427,8 @@ export class XmlImport {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${spell} not found in items`, error)
|
console.error(`${spell} not found in items`, error)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.#unknownSpells.push(SCREAMING_NAME.trim())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -418,6 +446,8 @@ export class XmlImport {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${liturgy} not found in items`, error)
|
console.error(`${liturgy} not found in items`, error)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.#unknownLiturgies.push(liturgyName.trim())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -544,6 +574,7 @@ export class XmlImport {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
this.#unknownItem.push(e.modallgemein?.name?.value ?? e.name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -605,6 +636,8 @@ export class XmlImport {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
|
||||||
|
this.#unknownSpecialAbilities.push(specialAbility.name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
grid-template-rows: 32px 1fr 32px;
|
grid-template-rows: 32px 1fr 32px;
|
||||||
gap: 8px 0;
|
gap: 8px 0;
|
||||||
grid-template-areas: "file" "options" "actions";
|
grid-template-areas: "file" "options" "actions";
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
.file-input {
|
.file-input {
|
||||||
grid-area: file;
|
grid-area: file;
|
||||||
|
|
@ -30,6 +31,7 @@
|
||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
grid-area: options;
|
grid-area: options;
|
||||||
|
overflow-x: auto;
|
||||||
|
|
||||||
div {
|
div {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<section>
|
||||||
|
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Folgendes konnte nicht importiert werden</legend>
|
||||||
|
|
||||||
|
<div class="scroll-y">
|
||||||
|
<ul>
|
||||||
|
{{#each report}}
|
||||||
|
<li><em>{{this.type}}</em> {{this.name}}</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</section>
|
||||||
Loading…
Reference in New Issue