Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 1 | import Feature from '../common/architecture/features/Feature'; |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 2 | import ScriptFilterListProvider from '../common/architecture/scripts/ScriptFilterListProvider'; |
Adrià Vilanova Martínez | 66836fd | 2024-05-04 22:43:06 +0200 | [diff] [blame] | 3 | import ExtraInfoFeature from './extraInfo/extraInfo.feature'; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 4 | |
| 5 | export type ConcreteFeatureClass = { new (): Feature }; |
| 6 | |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 7 | export default class Features extends ScriptFilterListProvider { |
Adrià Vilanova Martínez | 58cc67c | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 8 | private features: ConcreteFeatureClass[] = [ |
Adrià Vilanova Martínez | 66836fd | 2024-05-04 22:43:06 +0200 | [diff] [blame] | 9 | ExtraInfoFeature, |
Adrià Vilanova Martínez | 58cc67c | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 10 | ]; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 11 | private initializedFeatures: Feature[]; |
| 12 | |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 13 | protected getUnfilteredScriptsList() { |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 14 | const features = this.getFeatures(); |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 15 | return features.map((feature) => feature.getScripts()).flat(1); |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | private getFeatures() { |
| 19 | if (this.initializedFeatures === undefined) { |
| 20 | this.initializedFeatures = this.features.map((feature) => new feature()); |
| 21 | } |
| 22 | return this.initializedFeatures; |
| 23 | } |
| 24 | } |