import { IronswornSettings } from '../../helpers/settings' ; import { SiteDataSource } from '../actortypes' ; import { IronswornVueActorSheet } from '../vueactorsheet' ; export class IronswornSiteSheetV2 extends IronswornVueActorSheet { get siteData ( ) { return this . actor . data as SiteDataSource ; } static get defaultOptions ( ) { return mergeObject ( super . defaultOptions , { classes : [ 'ironsworn' , 'sheet' , 'site' , `theme-${ IronswornSettings . theme }` ] , width : 700 , height : 495 , template : 'systems/foundry-ironsworn/templates/actor/site-v2.hbs' , resizable : false , submitOnClose : true , submitOnChange : true , } ) ; } getData ( ) { let data = super . getData ( ) ; for ( const itemType of CONFIG . IRONSWORN . itemClasses ) { data = itemType . getActorSheetData ( data , this ) ; } data . actor = this . actor . toObject ( false ) ; data . data = data . actor . data ; return data ; } async _onDropItem ( event , data ) { const item = await Item . fromDropData ( data ) ; if ( ! item ) return false ; if ( item . type !== 'progress' ) { return super . _onDropItem ( event , data ) ; } const dropTarget = $ ( event . target as HTMLElement ) . parents ( '.ironsworn__denizen__drop' ) [ 0 ] ; if ( ! dropTarget ) return false ; const idx = parseInt ( dropTarget . dataset . idx || '' ) ; const { denizens } = this . siteData . data ; if ( ! denizens [ idx ] ) return false ; const description = item . pack ? `@Compendium[${ item . pack }.${ item . id }]{${ item . name }}` : item . link ; denizens [ idx ] . description = description ; this . actor . update ( { data : { denizens } } , { render : true } ) ; return true ; } _getHeaderButtons ( ) { return [ { class : 'ironsworn-toggle-edit-mode' , label : 'Edit' , icon : 'fas fa-edit' , onclick : ( e ) => this . _toggleEditMode ( e ) , } , ... super . _getHeaderButtons ( ) , ] ; } _toggleEditMode ( _e ) { const currentValue = this . actor . getFlag ( 'foundry-ironsworn' , 'edit-mode' ) ; this . actor . setFlag ( 'foundry-ironsworn' , 'edit-mode' , ! currentValue ) ; } }