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'
|
||||
})
|
||||
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"],
|
||||
makeDefault: true,
|
||||
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, {
|
||||
types: ['ActiveEffect'],
|
||||
makeDefault: true,
|
||||
label: 'DSA41.ActiveEffectLabels.ActiveFfect'
|
||||
label: 'DSA41.ActiveEffectLabels.ActiveEffect'
|
||||
})
|
||||
|
||||
game.settings.register('DSA_4-1', 'optional_trefferzonen', {
|
||||
|
|
|
|||
|
|
@ -1,50 +1,62 @@
|
|||
export class LiturgySheet extends foundry.appv1.sheets.ItemSheet {
|
||||
/**@override */
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ['dsa41', 'sheet', 'item', 'liturgy'],
|
||||
width: 520,
|
||||
height: 480,
|
||||
const {DocumentSheetV2, HandlebarsApplicationMixin} = foundry.applications.api
|
||||
|
||||
export class LiturgySheet extends HandlebarsApplicationMixin(DocumentSheetV2) {
|
||||
|
||||
/** @inheritDoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
position: {width: 520, height: 480},
|
||||
classes: ['dsa41', 'sheet', 'item', 'liturgy'],
|
||||
tag: 'form',
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
handler: LiturgySheet.#onSubmitForm
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
static TABS = {
|
||||
sheet: {
|
||||
tabs: [
|
||||
{
|
||||
navSelector: '.sheet-tabs',
|
||||
contentSelector: '.sheet-body',
|
||||
initial: 'description',
|
||||
},
|
||||
{id: 'json', group: 'sheet', label: 'JSON'},
|
||||
],
|
||||
});
|
||||
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 */
|
||||
get template() {
|
||||
return `systems/DSA_4-1/templates/item/item-liturgy-sheet.hbs`;
|
||||
}
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
/** @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();
|
||||
const liturgyData = context.document;
|
||||
|
||||
// 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.flags = liturgyData.flags;
|
||||
context.json = JSON.stringify(liturgyData);
|
||||
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 {
|
||||
/**@override */
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ['dsa41', 'sheet', 'item', 'specialability'],
|
||||
width: 520,
|
||||
height: 480,
|
||||
const {DocumentSheetV2, HandlebarsApplicationMixin} = foundry.applications.api
|
||||
|
||||
export class SpecialAbilitySheet extends HandlebarsApplicationMixin(DocumentSheetV2) {
|
||||
|
||||
/** @inheritDoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
position: {width: 520, height: 480},
|
||||
classes: ['dsa41', 'sheet', 'item', 'specialability'],
|
||||
tag: 'form',
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
handler: SpecialAbilitySheet.#onSubmitForm
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
static TABS = {
|
||||
sheet: {
|
||||
tabs: [
|
||||
{
|
||||
navSelector: '.sheet-tabs',
|
||||
contentSelector: '.sheet-body',
|
||||
initial: 'description',
|
||||
},
|
||||
{id: 'json', group: 'sheet', label: '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) {
|
||||
|
||||
initial: 'json'
|
||||
}
|
||||
}
|
||||
|
||||
/** @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