Working on 0.8.x

- Finished the dialog for add new item on title and other advancements
- some documentation update
This commit is contained in:
Vlyan
2021-05-22 22:10:54 +02:00
parent 53f04e6cef
commit 90ccfd1d68
20 changed files with 167 additions and 51 deletions

View File

@@ -31,7 +31,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
/**
* Subscribe to events from the sheet.
* @param html HTML content of the sheet.
* @param {jQuery} html HTML content of the sheet.
*/
activateListeners(html) {
super.activateListeners(html);

View File

@@ -50,7 +50,7 @@ export class ItemPatternSheetL5r5e extends ItemSheetL5r5e {
/**
* Subscribe to events from the sheet.
* @param html HTML content of the sheet.
* @param {jQuery} html HTML content of the sheet.
*/
activateListeners(html) {
super.activateListeners(html);

View File

@@ -82,7 +82,8 @@ export class ItemSheetL5r5e extends ItemSheet {
/**
* Subscribe to events from the sheet.
* @param html HTML content of the sheet.
* @param {jQuery} html HTML content of the sheet.
* @override
*/
activateListeners(html) {
super.activateListeners(html);
@@ -112,7 +113,7 @@ export class ItemSheetL5r5e extends ItemSheet {
/**
* Create drag-and-drop workflow handlers for this Application
* @return An array of DragDrop handlers
* @return {DragDrop[]} An array of DragDrop handlers
*/
_createDragDropHandlers() {
return [
@@ -160,6 +161,7 @@ export class ItemSheetL5r5e extends ItemSheet {
/**
* Add a property to the current item
* @param {Item} item
* @private
*/
_addProperty(item) {
@@ -222,19 +224,19 @@ export class ItemSheetL5r5e extends ItemSheet {
/**
* Add a embed item
* @param event
* @param {Event} event
* @private
*/
_addSubItem(event) {
event.preventDefault();
event.stopPropagation();
const itemId = $(event.currentTarget).data("item-id");
console.log("TODO _addSubItem", itemId); // TODO _addSubItem
console.warn("L5R5E | TODO ItemSheetL5r5e._addSubItem()", itemId); // TODO _addSubItem Currently not used, title override it
}
/**
* Add a embed item
* @param event
* @param {Event} event
* @private
*/
_editSubItem(event) {
@@ -249,7 +251,7 @@ export class ItemSheetL5r5e extends ItemSheet {
/**
* Delete a embed item
* @param event
* @param {Event} event
* @private
*/
_deleteSubItem(event) {

View File

@@ -81,7 +81,7 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
/**
* Subscribe to events from the sheet.
* @param html HTML content of the sheet.
* @param {jQuery} html HTML content of the sheet.
*/
activateListeners(html) {
super.activateListeners(html);
@@ -96,4 +96,30 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
html.find(`.item-edit`).on("click", this._editSubItem.bind(this));
html.find(`.item-delete`).on("click", this._deleteSubItem.bind(this));
}
/**
* Display a dialog to choose what Item to add, and add it on this Item
* @param {Event} event
* @return {Promise<void>}
* @private
*/
async _addSubItem(event) {
// Show Dialog
const selectedType = await game.l5r5e.HelpersL5r5e.showSubItemDialog(["advancement", "technique"]);
// Create the new Item
const itemId = await this.document.addEmbedItem(
new game.l5r5e.ItemL5r5e({
name: game.i18n.localize(`ITEM.Type${selectedType.capitalize()}`),
type: selectedType,
img: `${CONFIG.l5r5e.paths.assets}icons/items/${selectedType}.svg`,
})
);
// Get the store object and display it
const item = this.document.items.get(itemId);
if (item) {
item.sheet.render(true);
}
}
}