Migrates Specialabilities and Liturgies to DocumentV2
parent
962fc482a8
commit
f505a233df
12
src/main.mjs
12
src/main.mjs
|
|
@ -117,20 +117,20 @@ Hooks.once("init", () => {
|
||||||
label: 'DSA41.AusruestungLabels.Item'
|
label: 'DSA41.AusruestungLabels.Item'
|
||||||
})
|
})
|
||||||
foundry.documents.collections.Items.registerSheet('dsa41.liturgy', LiturgySheet, {
|
foundry.documents.collections.Items.registerSheet('dsa41.liturgy', LiturgySheet, {
|
||||||
types: ["SpecialAbility"],
|
|
||||||
makeDefault: true,
|
|
||||||
label: 'DSA41.SpecialAbilityLabels.Item'
|
|
||||||
})
|
|
||||||
foundry.documents.collections.Items.registerSheet('dsa41.specialAbility', SpecialAbilitySheet, {
|
|
||||||
types: ["Liturgy"],
|
types: ["Liturgy"],
|
||||||
makeDefault: true,
|
makeDefault: true,
|
||||||
label: 'DSA41.LiturgyLabels.Item'
|
label: 'DSA41.LiturgyLabels.Item'
|
||||||
})
|
})
|
||||||
|
foundry.documents.collections.Items.registerSheet('dsa41.specialAbility', SpecialAbilitySheet, {
|
||||||
|
types: ["SpecialAbility"],
|
||||||
|
makeDefault: true,
|
||||||
|
label: 'DSA41.SpecialAbilityLabels.Item'
|
||||||
|
})
|
||||||
|
|
||||||
foundry.documents.collections.Items.registerSheet('dsa41.activeEffect', ActiveEffectSheet, {
|
foundry.documents.collections.Items.registerSheet('dsa41.activeEffect', ActiveEffectSheet, {
|
||||||
types: ['ActiveEffect'],
|
types: ['ActiveEffect'],
|
||||||
makeDefault: true,
|
makeDefault: true,
|
||||||
label: 'DSA41.ActiveEffectLabels.ActiveFfect'
|
label: 'DSA41.ActiveEffectLabels.ActiveEffect'
|
||||||
})
|
})
|
||||||
|
|
||||||
game.settings.register('DSA_4-1', 'optional_trefferzonen', {
|
game.settings.register('DSA_4-1', 'optional_trefferzonen', {
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,62 @@
|
||||||
export class LiturgySheet extends foundry.appv1.sheets.ItemSheet {
|
const {DocumentSheetV2, HandlebarsApplicationMixin} = foundry.applications.api
|
||||||
/**@override */
|
|
||||||
static get defaultOptions() {
|
export class LiturgySheet extends HandlebarsApplicationMixin(DocumentSheetV2) {
|
||||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
|
||||||
classes: ['dsa41', 'sheet', 'item', 'liturgy'],
|
/** @inheritDoc */
|
||||||
width: 520,
|
static DEFAULT_OPTIONS = {
|
||||||
height: 480,
|
position: {width: 520, height: 480},
|
||||||
|
classes: ['dsa41', 'sheet', 'item', 'liturgy'],
|
||||||
|
tag: 'form',
|
||||||
|
form: {
|
||||||
|
submitOnChange: true,
|
||||||
|
closeOnSubmit: false,
|
||||||
|
handler: LiturgySheet.#onSubmitForm
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static TABS = {
|
||||||
|
sheet: {
|
||||||
tabs: [
|
tabs: [
|
||||||
{
|
{id: 'json', group: 'sheet', label: 'JSON'},
|
||||||
navSelector: '.sheet-tabs',
|
|
||||||
contentSelector: '.sheet-body',
|
|
||||||
initial: 'description',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
initial: 'json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
static PARTS = {
|
||||||
|
form: {
|
||||||
|
template: `systems/DSA_4-1/templates/item/liturgy/main-sheet.hbs`
|
||||||
|
},
|
||||||
|
json: {
|
||||||
|
template: `systems/DSA_4-1/templates/item/liturgy/tab-json.hbs`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle form submission
|
||||||
|
* @this {EquipmentSheet}
|
||||||
|
* @param {SubmitEvent} event
|
||||||
|
* @param {HTMLFormElement} form
|
||||||
|
* @param {FormDataExtended} formData
|
||||||
|
*/
|
||||||
|
static async #onSubmitForm(event, form, formData) {
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
await this.document.update(formData.object) // Note: formData.object
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
get template() {
|
async _prepareContext(options) {
|
||||||
return `systems/DSA_4-1/templates/item/item-liturgy-sheet.hbs`;
|
const context = await super._prepareContext(options);
|
||||||
}
|
|
||||||
|
|
||||||
/** @override */
|
const liturgyData = context.document;
|
||||||
getData() {
|
|
||||||
// Retrieve the data structure from the base sheet. You can inspect or log
|
|
||||||
// the context variable to see the structure, but some key properties for
|
|
||||||
// sheets are the actor object, the data object, whether or not it's
|
|
||||||
// editable, the items array, and the effects array.
|
|
||||||
const context = super.getData();
|
|
||||||
|
|
||||||
// Use a safe clone of the actor data for further operations.
|
|
||||||
const liturgyData = context.data;
|
|
||||||
|
|
||||||
// Add the actor's data to context.data for easier access, as well as flags.
|
|
||||||
context.system = liturgyData.system;
|
context.system = liturgyData.system;
|
||||||
context.flags = liturgyData.flags;
|
context.flags = liturgyData.flags;
|
||||||
context.json = JSON.stringify(liturgyData);
|
context.json = JSON.stringify(liturgyData);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
|
||||||
super.activateListeners(html);
|
|
||||||
|
|
||||||
// Everything below here is only needed if the sheet is editable
|
|
||||||
if (this.isEditable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,62 @@
|
||||||
export class SpecialAbilitySheet extends foundry.appv1.sheets.ItemSheet {
|
const {DocumentSheetV2, HandlebarsApplicationMixin} = foundry.applications.api
|
||||||
/**@override */
|
|
||||||
static get defaultOptions() {
|
export class SpecialAbilitySheet extends HandlebarsApplicationMixin(DocumentSheetV2) {
|
||||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
|
||||||
classes: ['dsa41', 'sheet', 'item', 'specialability'],
|
/** @inheritDoc */
|
||||||
width: 520,
|
static DEFAULT_OPTIONS = {
|
||||||
height: 480,
|
position: {width: 520, height: 480},
|
||||||
|
classes: ['dsa41', 'sheet', 'item', 'specialability'],
|
||||||
|
tag: 'form',
|
||||||
|
form: {
|
||||||
|
submitOnChange: true,
|
||||||
|
closeOnSubmit: false,
|
||||||
|
handler: SpecialAbilitySheet.#onSubmitForm
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static TABS = {
|
||||||
|
sheet: {
|
||||||
tabs: [
|
tabs: [
|
||||||
{
|
{id: 'json', group: 'sheet', label: 'JSON'},
|
||||||
navSelector: '.sheet-tabs',
|
|
||||||
contentSelector: '.sheet-body',
|
|
||||||
initial: 'description',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
initial: 'json'
|
||||||
}
|
|
||||||
|
|
||||||
/** @override */
|
|
||||||
get template() {
|
|
||||||
return `systems/DSA_4-1/templates/item/item-special-ability-sheet.hbs`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @override */
|
|
||||||
getData() {
|
|
||||||
// Retrieve the data structure from the base sheet. You can inspect or log
|
|
||||||
// the context variable to see the structure, but some key properties for
|
|
||||||
// sheets are the actor object, the data object, whether or not it's
|
|
||||||
// editable, the items array, and the effects array.
|
|
||||||
const context = super.getData();
|
|
||||||
|
|
||||||
// Use a safe clone of the actor data for further operations.
|
|
||||||
const advantageData = context.data;
|
|
||||||
|
|
||||||
// Add the actor's data to context.data for easier access, as well as flags.
|
|
||||||
context.system = advantageData.system;
|
|
||||||
context.flags = advantageData.flags;
|
|
||||||
context.json = JSON.stringify(advantageData.system, null, 4);
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
activateListeners(html) {
|
|
||||||
super.activateListeners(html);
|
|
||||||
|
|
||||||
// Everything below here is only needed if the sheet is editable
|
|
||||||
if (!this.isEditable) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
static PARTS = {
|
||||||
|
form: {
|
||||||
|
template: `systems/DSA_4-1/templates/item/specialability/main-sheet.hbs`
|
||||||
|
},
|
||||||
|
json: {
|
||||||
|
template: `systems/DSA_4-1/templates/item/specialability/tab-json.hbs`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle form submission
|
||||||
|
* @this {EquipmentSheet}
|
||||||
|
* @param {SubmitEvent} event
|
||||||
|
* @param {HTMLFormElement} form
|
||||||
|
* @param {FormDataExtended} formData
|
||||||
|
*/
|
||||||
|
static async #onSubmitForm(event, form, formData) {
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
await this.document.update(formData.object) // Note: formData.object
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
async _prepareContext(options) {
|
||||||
|
const context = await super._prepareContext(options);
|
||||||
|
|
||||||
|
const specialabilityData = context.document;
|
||||||
|
|
||||||
|
context.system = specialabilityData.system;
|
||||||
|
context.flags = specialabilityData.flags;
|
||||||
|
context.json = JSON.stringify(specialabilityData);
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
<form class="{{cssClass}} {{actor.type}} flexcol" autocomplete="off">
|
|
||||||
|
|
||||||
{{!-- Sheet Tab Navigation --}}
|
|
||||||
<nav class="sheet-tabs tabs" style="flex: 0" data-group="primary">
|
|
||||||
<a class="item" data-tab="json">JSON</a>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
{{!-- Sheet Body --}}
|
|
||||||
<section class="sheet-body" style="flex: 1">
|
|
||||||
<div class="tab json" data-group="primary" data-tab="json">
|
|
||||||
<pre style="overflow: auto; white-space: normal; position: relative; top: 8px; bottom: 8px; left: 8px; right: 8px">{{json}}</pre>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</form>
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<div>
|
||||||
|
<!-- TODO Add this sheet with meaningful options -->
|
||||||
|
Alveranische Baustelle, bitte gehen Sie weiter, hier gibt es nichts zu sehen.
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<section class="tab {{tabs.json.id}} {{tabs.json.cssClass}}"
|
||||||
|
data-tab="{{tabs.json.id}}"
|
||||||
|
data-group="{{tabs.json.group}}">
|
||||||
|
|
||||||
|
<pre style="overflow: auto; white-space: normal; position: relative; top: 8px; bottom: 8px; left: 8px; right: 8px">{{json}}</pre>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<div>
|
||||||
|
<!-- TODO Add this sheet with meaningful options -->
|
||||||
|
Sonderfertigkeiten bitte sei Besonders und Fertig
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<section class="tab {{tabs.json.id}} {{tabs.json.cssClass}}"
|
||||||
|
data-tab="{{tabs.json.id}}"
|
||||||
|
data-group="{{tabs.json.group}}">
|
||||||
|
|
||||||
|
<pre style="overflow: auto; white-space: normal; position: relative; top: 8px; bottom: 8px; left: 8px; right: 8px">{{json}}</pre>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
Loading…
Reference in New Issue