| 289 | return this.filterDataByState(data, state, isFolder); | 289 | return this.filterDataByState(data, state, isFolder); |
| 290 | } | 290 | } |
| 291 | | 291 | |
| | 292 | /** |
| | 293 | * Filters an array of entities based on a tri-state filter value. |
| | 294 | * SELECTED keeps entities where filterFunc returns true; EXCLUDED removes them; UNDEFINED returns data unchanged. |
| | 295 | * @param {any[]} data The data to filter |
| | 296 | * @param {FilterState|string} state The tri-state filter value (SELECTED, EXCLUDED, or UNDEFINED) |
| | 297 | * @param {Function} filterFunc A predicate function applied to each entity |
| | 298 | * @param {object} [options] Options object |
| | 299 | * @param {boolean} [options.includeFolders=false] If true, entities with type 'tag' always pass through |
| | 300 | * @returns {any[]} The filtered data |
| | 301 | */ |
| 292 | filterDataByState(data, state, filterFunc, { includeFolders = false } = {}) { | 302 | filterDataByState(data, state, filterFunc, { includeFolders = false } = {}) { |
| 293 | if (isFilterState(state, FILTER_STATES.SELECTED)) { | 303 | if (isFilterState(state, FILTER_STATES.SELECTED)) { |
| 294 | return data.filter(entity => filterFunc(entity) || (includeFolders && entity.type == 'tag')); | 304 | return data.filter(entity => filterFunc(entity) || (includeFolders && entity.type == 'tag')); |