group items prepared

This commit is contained in:
François-Xavier Guillois
2023-09-01 10:34:16 +02:00
parent bf3dc5e56d
commit 4809606dea
3 changed files with 35 additions and 47 deletions

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 104 KiB

+30 -46
View File
@@ -53,6 +53,10 @@ export class VermineGroupSheet extends VermineActorSheet {
this._prepareItems(context); this._prepareItems(context);
} }
if (actorData.type == 'group') {
this._prepareItems(context);
}
// Add roll data for TinyMCE editors. // Add roll data for TinyMCE editors.
context.rollData = context.actor.getRollData(); context.rollData = context.actor.getRollData();
@@ -85,44 +89,40 @@ export class VermineGroupSheet extends VermineActorSheet {
*/ */
_prepareItems(context) { _prepareItems(context) {
// Initialize containers. // Initialize containers.
const gear = []; const abilities = [];
const features = []; const specialties = [];
const spells = { const backgrounds = [];
0: [], const evolutions = [];
1: [], const traumas = [];
2: [],
3: [],
4: [],
5: [],
6: [],
7: [],
8: [],
9: []
};
// Iterate through items, allocating to containers // Iterate through items, allocating to containers
for (let i of context.items) { for (let i of context.items) {
i.img = i.img || DEFAULT_TOKEN; i.img = i.img || DEFAULT_TOKEN;
// Append to gear. if (i.type === 'ability') {
if (i.type === 'item') { abilities.push(i);
gear.push(i);
} }
// Append to features. else if (i.type === 'specialty') {
else if (i.type === 'feature') { specialties.push(i);
features.push(i);
} }
// Append to spells. else if (i.type === 'background') {
else if (i.type === 'spell') { backgrounds.push(i);
if (i.system.spellLevel != undefined) {
spells[i.system.spellLevel].push(i);
}
} }
else if (i.type === 'evolution') {
evolutions.push(i);
}
else if (i.type === 'trauma') {
traumas.push(i);
}
} }
// Assign and return // Assign and return
context.gear = gear; context.abilities = abilities;
context.features = features; context.specialties = specialties;
context.spells = spells; context.backgrounds = backgrounds;
context.evolutions = evolutions;
context.traumas = traumas;
console.log(context);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -130,7 +130,6 @@ export class VermineGroupSheet extends VermineActorSheet {
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
console.log('evenement de groupe');
// Render the item sheet for viewing/editing prior to the editable check. // Render the item sheet for viewing/editing prior to the editable check.
html.find('.item-edit').click(ev => { html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
@@ -142,27 +141,12 @@ export class VermineGroupSheet extends VermineActorSheet {
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.isEditable) return; if (!this.isEditable) return;
// Add Inventory Item // Add and delete Inventory Item
html.find('.item-create').click(this._onItemCreate.bind(this)); // already configured in parents listeners
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.items.get(li.data("itemId"));
item.delete();
li.slideUp(200, () => this.render(false));
});
// Choose Totem // Choose Totem
html.find('.chooseTotem').click(this._onTotemButton.bind(this)); html.find('.chooseTotem').click(this._onTotemButton.bind(this));
// Active Effect management
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
// Rollable abilities.
html.find('.rollable').click(this._onRoll.bind(this));
// Drag events for macros.
if (this.actor.isOwner) { if (this.actor.isOwner) {
let handler = ev => this._onDragStart(ev); let handler = ev => this._onDragStart(ev);
html.find('li.item').each((i, li) => { html.find('li.item').each((i, li) => {
+5 -1
View File
@@ -32,7 +32,11 @@
</ol> </ol>
</div> </div>
<div> <div>
<h4>{{ localize 'ITEMS.backgrounds'}}</h4> <h4>
<span>{{ localize 'ITEMS.backgrounds'}}</span>
<a class="item-control item-create" title="Create item" data-type="background"><i class="fas fa-plus"></i></a>
</h4>
<ol class="list-item"> <ol class="list-item">
{{#each backgrounds as |item id|}} {{#each backgrounds as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}"> <li class="item flexrow" data-item-id="{{item._id}}">