@@ -70,6 +70,12 @@ export class ChoiceModel extends foundry.abstract.DataModel
7070 let option ;
7171 if ( data . documentName == "Item" )
7272 {
73+ let restrictions = this . schema . options . restrictType ;
74+ if ( restrictions ?. length > 0 && ! restrictions . includes ( data . type ) )
75+ {
76+ ui . notifications . error ( "WH.Error.WrongChoiceOptionType" , { localize : true , format : { types : restrictions . join ( ", " ) } } ) ;
77+ throw new Error ( game . i18n . format ( "WH.Error.WrongChoiceOptionType" , { types : restrictions . join ( ", " ) } ) ) ;
78+ }
7379 option = this . _createDocumentOption ( data ) ;
7480 }
7581 else if ( data . documentName == "ActiveEffect" )
@@ -188,7 +194,12 @@ export class ChoiceModel extends foundry.abstract.DataModel
188194 }
189195 else if ( option . type == "placeholder" )
190196 {
191- return foundry . utils . mergeObject ( { name : option . name } , systemConfig ( ) . placeholderItemData ) ;
197+ let data = foundry . utils . mergeObject ( { name : option . name } , systemConfig ( ) . placeholderItemData ) ;
198+ if ( this . schema . options . restrictType ?. length )
199+ {
200+ data . type = this . schema . options . restrictType [ 0 ] ;
201+ }
202+ return data ;
192203 }
193204 else if ( [ "id" , "uuid" ] . includes ( option . idType ) )
194205 {
@@ -390,7 +401,12 @@ export class ChoiceModel extends foundry.abstract.DataModel
390401 return this . _displayOptions ( this . structure ) ;
391402 }
392403
393- _displayOptions ( structure )
404+ get textDisplayWithLinks ( )
405+ {
406+ return this . _displayOptions ( this . structure , { links : true } ) ;
407+ }
408+
409+ _displayOptions ( structure , displayOptions = { } )
394410 {
395411
396412 if ( ! structure )
@@ -400,7 +416,15 @@ export class ChoiceModel extends foundry.abstract.DataModel
400416
401417 if ( structure . type == "option" )
402418 {
403- return this . options . find ( i => i . id == structure . id ) . name ;
419+ let option = this . options . find ( i => i . id == structure . id ) ;
420+ if ( displayOptions . links && option . idType == "uuid" )
421+ {
422+ return `@UUID[${ option . documentId } ]{${ option . name } }` ;
423+ }
424+ else
425+ {
426+ return option . name ;
427+ }
404428 }
405429 else if ( structure . type == "and" || structure . type == "or" )
406430 {
0 commit comments