diff --git a/src/module/dialog/xmlImportReportDialog.mjs b/src/module/dialog/xmlImportReportDialog.mjs new file mode 100644 index 00000000..5f2d7c26 --- /dev/null +++ b/src/module/dialog/xmlImportReportDialog.mjs @@ -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) { + + } + + +} \ No newline at end of file diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index a4319caf..6cbfdead 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -770,7 +770,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { if (documentClass) { 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 if ((targetDocument?.name ?? false) === document.name && targetDocument._id !== document._id && await foundry.applications.api.DialogV2.confirm({ diff --git a/src/module/xml-import/xml-import.mjs b/src/module/xml-import/xml-import.mjs index 304c68c3..0f324fe2 100644 --- a/src/module/xml-import/xml-import.mjs +++ b/src/module/xml-import/xml-import.mjs @@ -5,8 +5,17 @@ import {Culture} from "../documents/culture.mjs"; import {Species} from "../documents/species.mjs"; import {SpecialAbility} from "../documents/specialAbility.mjs"; import {Equipment} from "../documents/equipment.mjs"; +import {XmlImportReportDialog} from "../dialog/xmlImportReportDialog.mjs"; export class XmlImport { + + #unknownSkills = [] + #unknownSpells = [] + #unknownLiturgies = [] + #unknownItem = [] + #unknownSpecialAbilities = [] + #unknownAdvantage = [] + #months = [ "Praios", "Rondra", @@ -88,6 +97,19 @@ export class XmlImport { let characterJson = this.#mapRawJson(actor, rawJson, options) 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) { console.error(`${talentName} not found in items`, error) } + } else { + this.#unknownSkills.push(talentName.trim()) } } @@ -383,6 +407,8 @@ export class XmlImport { } catch (error) { console.error(`${advantageName} not found in items`, error) } + } else { + this.#unknownAdvantage.push(advantageName.trim()) } } @@ -401,6 +427,8 @@ export class XmlImport { } catch (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) { 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) } }) diff --git a/src/style/organisms/_xml-import-dialog.scss b/src/style/organisms/_xml-import-dialog.scss index 0254be47..d3a81d00 100644 --- a/src/style/organisms/_xml-import-dialog.scss +++ b/src/style/organisms/_xml-import-dialog.scss @@ -9,6 +9,7 @@ grid-template-rows: 32px 1fr 32px; gap: 8px 0; grid-template-areas: "file" "options" "actions"; + height: 100%; .file-input { grid-area: file; @@ -30,6 +31,7 @@ fieldset { grid-area: options; + overflow-x: auto; div { diff --git a/src/templates/dialog/xml-import-report.hbs b/src/templates/dialog/xml-import-report.hbs new file mode 100644 index 00000000..5a0637c2 --- /dev/null +++ b/src/templates/dialog/xml-import-report.hbs @@ -0,0 +1,16 @@ +
+ + +
+ Folgendes konnte nicht importiert werden + +
+
    + {{#each report}} +
  • {{this.type}} {{this.name}}
  • + {{/each}} +
+
+
+ +
\ No newline at end of file