mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
* Added prettier with automatic useage on pre-commit to avoid style breakage * Ran Prettier on the project
123 lines
3.8 KiB
JavaScript
123 lines
3.8 KiB
JavaScript
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
|
|
|
|
// export default class CommunitySheet extends DhpApplicationMixin(ItemSheet) {
|
|
// static documentType = "community";
|
|
|
|
// constructor(options){
|
|
// super(options);
|
|
// }
|
|
|
|
// /** @override */
|
|
// static get defaultOptions() {
|
|
// return foundry.utils.mergeObject(super.defaultOptions, {
|
|
// classes: ["daggerheart", "sheet", "heritage"],
|
|
// width: 600,
|
|
// height: 'auto',
|
|
// dragDrop: [{ dragSelector: null, dropSelector: null }],
|
|
// });
|
|
// }
|
|
|
|
// /** @override */
|
|
// getData() {
|
|
// const context = super.getData();
|
|
|
|
// return context;
|
|
// }
|
|
|
|
// async _handleAction(action, event, button) {
|
|
// switch(action){
|
|
// case 'editAbility':
|
|
// this.editAbility(button);
|
|
// break;
|
|
// case 'deleteAbility':
|
|
// this.deleteAbility(event);
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
// async editAbility(button){
|
|
// const feature = await fromUuid(button.dataset.ability);
|
|
// feature.sheet.render(true);
|
|
// }
|
|
|
|
// async deleteAbility(event){
|
|
// event.preventDefault();
|
|
// event.stopPropagation();
|
|
// await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== event.currentTarget.dataset.ability) })
|
|
// }
|
|
|
|
// async _onDrop(event) {
|
|
// const data = TextEditor.getDragEventData(event);
|
|
// const item = await fromUuid(data.uuid);
|
|
// if(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
|
|
// await this.object.update({ "system.abilities": [...this.item.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
|
|
|
const { ItemSheetV2 } = foundry.applications.sheets;
|
|
export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
|
|
static DEFAULT_OPTIONS = {
|
|
tag: 'form',
|
|
id: 'daggerheart-community',
|
|
classes: ['daggerheart', 'sheet', 'heritage'],
|
|
position: { width: 600 },
|
|
actions: {
|
|
editAbility: this.editAbility,
|
|
deleteAbility: this.deleteAbility
|
|
},
|
|
form: {
|
|
handler: this.updateForm,
|
|
submitOnChange: true,
|
|
closeOnSubmit: false
|
|
},
|
|
dragDrop: [{ dragSelector: null, dropSelector: null }]
|
|
};
|
|
|
|
static PARTS = {
|
|
form: {
|
|
id: 'feature',
|
|
template: 'systems/daggerheart/templates/sheets/community.hbs'
|
|
}
|
|
};
|
|
|
|
async _prepareContext(_options) {
|
|
const context = await super._prepareContext(_options);
|
|
context.document = this.document;
|
|
|
|
return context;
|
|
}
|
|
|
|
static async updateForm(event, _, formData) {
|
|
await this.document.update(formData.object);
|
|
this.render();
|
|
}
|
|
|
|
static async editAbility(_, button) {
|
|
const feature = await fromUuid(button.dataset.ability);
|
|
feature.sheet.render(true);
|
|
}
|
|
|
|
static async deleteAbility(event, button) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
await this.item.update({
|
|
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability)
|
|
});
|
|
}
|
|
|
|
async _onDrop(event) {
|
|
const data = TextEditor.getDragEventData(event);
|
|
const item = await fromUuid(data.uuid);
|
|
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
|
|
await this.document.update({
|
|
'system.abilities': [
|
|
...this.document.system.abilities,
|
|
{ img: item.img, name: item.name, uuid: item.uuid }
|
|
]
|
|
});
|
|
}
|
|
}
|
|
}
|