forked from public/foundryvtt-reve-de-dragon
		
	Ajout de l'Item "faune" pour tables environnement
This commit is contained in:
		
							
								
								
									
										54
									
								
								module/item-faune-sheet.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								module/item-faune-sheet.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| import { EnvironmentSheetHelper } from "./environnement.js"; | ||||
| import { RdDItemSheet } from "./item-sheet.js"; | ||||
| import { RdDUtility } from "./rdd-utility.js"; | ||||
|  | ||||
| export class RdDFauneItemSheet extends RdDItemSheet { | ||||
|  | ||||
|   static get ITEM_TYPE() { return "faune" }; | ||||
|  | ||||
|   static get defaultOptions() { | ||||
|     return EnvironmentSheetHelper.defaultOptions(super.defaultOptions); | ||||
|   } | ||||
|  | ||||
|   setPosition(options = {}) { | ||||
|     return EnvironmentSheetHelper.setPosition(this, super.setPosition(options)); | ||||
|   } | ||||
|  | ||||
|   async getData() { | ||||
|     const formData = await super.getData(); | ||||
|     return await EnvironmentSheetHelper.getData(this, formData); | ||||
|   } | ||||
|  | ||||
|   activateListeners(html) { | ||||
|     super.activateListeners(html); | ||||
|     if (!this.options.editable) return; | ||||
|  | ||||
|     EnvironmentSheetHelper.activateListeners(this, html); | ||||
|  | ||||
|     html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor()); | ||||
|  | ||||
|   } | ||||
|  | ||||
|   async _onDropActor(event, dragData) { | ||||
|     console.log('faune:dropActor', event, dragData) | ||||
|     const actor = fromUuidSync(dragData.uuid); | ||||
|     if (actor?.pack) { | ||||
|       this.item.update({ | ||||
|         'system.actor.pack': actor.pack, | ||||
|         'system.actor.id': actor._id, | ||||
|         'system.actor.name': actor.name | ||||
|       }); | ||||
|     } | ||||
|     else { | ||||
|       ui.notifications.warn(`${actor.name} ne provient pas d'eun compendium. | ||||
|         <br>Choisissez une créature du compendium pour représenter un élément de faune générique`) | ||||
|     } | ||||
|   } | ||||
|   async onDeleteLinkedActor() { | ||||
|     this.item.update({ | ||||
|       'system.actor.pack': '', | ||||
|       'system.actor.id': '', | ||||
|       'system.actor.name': '' | ||||
|     }); | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user