@@ -12,7 +12,7 @@ export class CompendiumBrowserActionTab extends CompendiumBrowserTab {
1212
1313 /* MiniSearch */
1414 override searchFields = [ "name" , "originalName" ] ;
15- override storeFields = [ "type " , "name " , "img" , "uuid" , "traits" , "source" , "category" , "actionType "] ;
15+ override storeFields = [ "name " , "originalName " , "img" , "uuid" , "domains " ] ;
1616
1717 constructor ( browser : CompendiumBrowser ) {
1818 super ( browser ) ;
@@ -43,34 +43,41 @@ export class CompendiumBrowserActionTab extends CompendiumBrowserTab {
4343 ) ) {
4444 console . debug ( `PF2e System | Compendium Browser | ${ pack . metadata . label } - Loading` ) ;
4545 for ( const actionData of index ) {
46- if ( actionData . type === "action" ) {
47- if ( ! this . hasAllIndexFields ( actionData , indexFields ) ) {
48- console . warn (
49- `Action '${ actionData . name } ' does not have all required data fields. Consider unselecting pack '${ pack . metadata . label } ' in the compendium browser settings.` ,
50- ) ;
51- continue ;
52- }
53- // update icons for any passive actions
54- if ( actionData . system . actionType . value === "passive" ) actionData . img = getActionIcon ( "passive" ) ;
46+ if ( actionData . type !== "action" ) continue ;
47+ if ( ! this . hasAllIndexFields ( actionData , indexFields ) ) {
48+ console . warn (
49+ `Action '${ actionData . name } ' does not have all required data fields. Consider unselecting pack '${ pack . metadata . label } ' in the compendium browser settings.` ,
50+ ) ;
51+ continue ;
52+ }
53+ const domains = new Set < string > ( ) ;
54+ const system = actionData . system ;
55+ // update icons for any passive actions
56+ if ( system . actionType . value === "passive" ) actionData . img = getActionIcon ( "passive" ) ;
57+ domains . add ( `action-type:${ system . actionType . value } ` ) ;
5558
56- // Prepare publication source
57- const { system } = actionData ;
58- const pubSource = String ( system . publication ?. title ?? system . source ?. value ?? "" ) . trim ( ) ;
59- const sourceSlug = sluggify ( pubSource ) ;
60- if ( pubSource ) publications . add ( pubSource ) ;
59+ for ( const trait of system . traits . value ) {
60+ domains . add ( `trait:${ trait . replace ( / ^ h b _ / , "" ) } ` ) ;
61+ }
6162
62- actions . push ( {
63- type : actionData . type ,
64- name : actionData . name ,
65- originalName : actionData . originalName , // Added by Babele
66- img : actionData . img ,
67- uuid : actionData . uuid ,
68- traits : actionData . system . traits . value . map ( ( t : string ) => t . replace ( / ^ h b _ / , "" ) ) ,
69- actionType : actionData . system . actionType . value ,
70- category : actionData . system . category ,
71- source : sourceSlug ,
72- } ) ;
63+ // Prepare publication source
64+ const pubSource = String ( system . publication ?. title ?? system . source ?. value ?? "" ) . trim ( ) ;
65+ const sourceSlug = sluggify ( pubSource ) ;
66+ if ( pubSource ) {
67+ publications . add ( pubSource ) ;
68+ domains . add ( `source:${ sourceSlug } ` ) ;
7369 }
70+
71+ domains . add ( `type:${ actionData . type } ` ) ;
72+ domains . add ( `category:${ system . category } ` ) ;
73+
74+ actions . push ( {
75+ name : actionData . name ,
76+ originalName : actionData . originalName , // Added by Babele
77+ img : actionData . img ,
78+ uuid : actionData . uuid ,
79+ domains,
80+ } ) ;
7481 }
7582 }
7683
@@ -79,56 +86,36 @@ export class CompendiumBrowserActionTab extends CompendiumBrowserTab {
7986
8087 // Set Filters
8188 this . filterData . traits . options = this . generateMultiselectOptions ( CONFIG . PF2E . actionTraits ) ;
82- this . filterData . checkboxes . types . options = this . generateCheckboxOptions ( CONFIG . PF2E . actionTypes ) ;
83- this . filterData . checkboxes . category . options = this . generateCheckboxOptions (
89+ this . filterData . checkboxes . types . options = this . generateOptions ( CONFIG . PF2E . actionTypes ) ;
90+ this . filterData . checkboxes . category . options = this . generateOptions (
8491 R . pick ( CONFIG . PF2E . actionCategories , [ "familiar" ] ) ,
8592 ) ;
8693 this . filterData . source . options = this . generateSourceCheckboxOptions ( publications ) ;
8794
8895 console . debug ( "PF2e System | Compendium Browser | Finished loading actions" ) ;
8996 }
9097
91- protected override filterIndexData ( entry : CompendiumBrowserIndexData ) : boolean {
92- const { checkboxes, source, traits } = this . filterData ;
93-
94- // Types
95- if ( checkboxes . types . selected . length ) {
96- if ( ! checkboxes . types . selected . includes ( entry . actionType ) ) return false ;
97- }
98- // Categories
99- if ( checkboxes . category . selected . length ) {
100- const selected = checkboxes . category . selected ;
101- if ( ! selected . includes ( entry . category ) ) return false ;
102- }
103- // Traits
104- if ( ! this . filterTraits ( entry . traits , traits . selected , traits . conjunction ) ) return false ;
105- // Source
106- if ( source . selected . length ) {
107- if ( ! source . selected . includes ( entry . source ) ) return false ;
108- }
109- return true ;
110- }
111-
11298 protected override prepareFilterData ( ) : ActionFilters {
11399 return {
114100 checkboxes : {
115101 types : {
116102 isExpanded : true ,
117103 label : "PF2E.ActionActionTypeLabel" ,
118- options : { } ,
104+ options : [ ] ,
105+ optionPrefix : "action-type" ,
119106 selected : [ ] ,
120107 } ,
121108 category : {
122109 isExpanded : true ,
123110 label : "PF2E.CompendiumBrowser.Filter.Categories" ,
124- options : { } ,
111+ options : [ ] ,
125112 selected : [ ] ,
126113 } ,
127114 } ,
128115 source : {
129116 isExpanded : false ,
130117 label : "PF2E.CompendiumBrowser.Filter.Source" ,
131- options : { } ,
118+ options : [ ] ,
132119 selected : [ ] ,
133120 } ,
134121 traits : {
0 commit comments