Browse Source

it is possible to extend configuration types

Raanan Weber 7 years ago
parent
commit
ad20b46773
1 changed files with 15 additions and 4 deletions
  1. 15 4
      Viewer/src/configuration/types/index.ts

+ 15 - 4
Viewer/src/configuration/types/index.ts

@@ -1,19 +1,30 @@
 import { minimalConfiguration } from './minimal';
 import { defaultConfiguration } from './default';
 import { ViewerConfiguration } from '../configuration';
+import * as deepmerge from '../../../assets/deepmerge.min.js';
 
 let getConfigurationType = function (type: string): ViewerConfiguration {
+    let config: ViewerConfiguration;
     switch (type) {
         case 'default':
-            return defaultConfiguration;
+            config = defaultConfiguration;
+            break;
         case 'minimal':
-            return minimalConfiguration;
+            config = minimalConfiguration;
+            break;
         case 'none':
-            return {};
+            config = {};
+            break;
         default:
-            return defaultConfiguration;
+            config = defaultConfiguration;
     }
 
+    if (config.extends) {
+        config = deepmerge(config, getConfigurationType(config.extends));
+    }
+
+    return config;
+
 }
 
 export { getConfigurationType, defaultConfiguration, minimalConfiguration }