corrected object tag properties
This commit is contained in:
@@ -22,8 +22,9 @@ export class ItemSheetL5r5e extends ItemSheet {
|
||||
sheetData.data.techniquesList = game.l5r5e.HelpersL5r5e.getTechniquesList();
|
||||
|
||||
// Prepare Properties (id => object)
|
||||
if (sheetData.data.properties) {
|
||||
sheetData.data.propertiesList = sheetData.data.properties.map((e) => game.items.get(e));
|
||||
sheetData.data.propertiesList = [];
|
||||
if (Array.isArray(sheetData.data.properties)) {
|
||||
sheetData.data.propertiesList = sheetData.data.properties.map((e) => game.items.get(e.id));
|
||||
}
|
||||
|
||||
return sheetData;
|
||||
@@ -89,23 +90,23 @@ export class ItemSheetL5r5e extends ItemSheet {
|
||||
}
|
||||
|
||||
// Ok add item
|
||||
this._addProperty(item.id);
|
||||
this._addProperty(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a property to the current item
|
||||
* @private
|
||||
*/
|
||||
_addProperty(id) {
|
||||
_addProperty(item) {
|
||||
let props = this.entity.data.data.properties || [];
|
||||
if (!Array.isArray(props)) {
|
||||
props = [];
|
||||
}
|
||||
if (props.includes(id)) {
|
||||
if (props.findIndex((p) => p.id === item.id) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
props.push(id);
|
||||
props.push({ id: item.id, name: item.name });
|
||||
|
||||
this.entity.update({
|
||||
data: {
|
||||
@@ -120,12 +121,12 @@ export class ItemSheetL5r5e extends ItemSheet {
|
||||
*/
|
||||
_deleteProperty(id) {
|
||||
let props = this.entity.data.data.properties || [];
|
||||
if (!Array.isArray(props) || !props.includes(id)) {
|
||||
if (!Array.isArray(props) || props.findIndex((p) => p.id === id) === -1) {
|
||||
return;
|
||||
}
|
||||
this.entity.update({
|
||||
data: {
|
||||
properties: props.filter((e) => e !== id),
|
||||
properties: props.filter((p) => p.id !== id),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,5 +8,10 @@
|
||||
<li class="item-edit" title="{{localize 'l5r5e.global.edit'}}"><i class="fas fa-edit"></i></li>
|
||||
<li class="item-delete" title="{{localize 'l5r5e.global.delete'}}"><i class="fas fa-trash"></i></li>
|
||||
</ul>
|
||||
<div class="item-description">{{{ item.data.properties }}}</div>
|
||||
<div class="item-properties">
|
||||
{{#each item.data.properties as |property id|}}
|
||||
{{{ property.name }}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="item-description">{{{ item.data.description }}}</div>
|
||||
</li>
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
<fieldset>
|
||||
<legend class="text-block-header">{{ localize 'l5r5e.properties' }}</legend>
|
||||
<!-- TODO data.properties a faire en dnd avec les items de type "property" -->
|
||||
{{> 'systems/l5r5e/templates/items/property/properties.html' properties=data.propertiesList }}
|
||||
</fieldset>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
<li class="item-edit" title="{{localize 'l5r5e.global.edit'}}"><i class="fas fa-edit"></i></li>
|
||||
<li class="item-delete" title="{{localize 'l5r5e.global.delete'}}"><i class="fas fa-trash"></i></li>
|
||||
</ul>
|
||||
<div class="item-properties">
|
||||
{{#each item.data.properties as |property id|}}
|
||||
{{{ property.name }}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="item-description">{{{ item.data.description }}}</div>
|
||||
<div class="item-properties">{{{ item.data.properties }}}</div>
|
||||
</li>
|
||||
@@ -33,28 +33,18 @@
|
||||
{{!-- Sheet Tab Navigation --}}
|
||||
<nav class="sheet-tabs tabs" data-group="primary">
|
||||
<a class="item" data-tab="description">Description</a>
|
||||
<a class="item" data-tab="attributes">Attributes</a>
|
||||
<a class="item" data-tab="properties">Properties</a>
|
||||
</nav>
|
||||
{{!-- Description Tab --}}
|
||||
<article class="tab flexcol" data-group="primary" data-tab="description">
|
||||
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
|
||||
</article>
|
||||
{{!-- Attributes Tab --}}
|
||||
<article class="tab attributes" data-group="primary" data-tab="attributes">
|
||||
<ul class="attributes-header flexrow">
|
||||
<li class="attribute-key">Attribute Key</li>
|
||||
<li class="attribute-value">Value</li>
|
||||
<li class="attribute-label">Label</li>
|
||||
<li class="attribute-dtype">Data Type</li>
|
||||
<li class="attribute-control" data-action="create" title="{{ localize 'l5r5e.add' }}"><i class="fas fa-plus"></i></li>
|
||||
</ul>
|
||||
<ol class="attributes-list">
|
||||
<fieldset>
|
||||
<legend class="text-block-header">{{ localize 'l5r5e.properties' }}</legend>
|
||||
<!-- TODO data.properties a faire en dnd avec les items de type "property" -->
|
||||
</fieldset>
|
||||
<!--{{#each data.attributes as |attr key|}} {{/each}}-->
|
||||
</ol>
|
||||
{{!-- properties Tab --}}
|
||||
<article class="tab properties" data-group="primary" data-tab="properties">
|
||||
<fieldset>
|
||||
<legend class="text-block-header">{{ localize 'l5r5e.properties' }}</legend>
|
||||
{{> 'systems/l5r5e/templates/items/property/properties.html' properties=data.propertiesList }}
|
||||
</fieldset>
|
||||
</article>
|
||||
</section>
|
||||
</form>
|
||||
|
||||
@@ -7,5 +7,10 @@
|
||||
<li class="item-edit" title="{{localize 'l5r5e.global.edit'}}"><i class="fas fa-edit"></i></li>
|
||||
<li class="item-delete" title="{{localize 'l5r5e.global.delete'}}"><i class="fas fa-trash"></i></li>
|
||||
</ul>
|
||||
<div class="item-description">{{{ item.data.properties }}}</div>
|
||||
<div class="item-properties">
|
||||
{{#each item.data.properties as |property id|}}
|
||||
{{{ property.name }}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="item-description">{{{ item.data.description }}}</div>
|
||||
</li>
|
||||
Reference in New Issue
Block a user