Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
arrays are a thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Levett committed Feb 24, 2016
1 parent 9c9e931 commit 175c88f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
23 changes: 16 additions & 7 deletions docs/markdown/configuration.md
@@ -1,4 +1,4 @@
Your application can overwrite any constant listed below by adding it to the `js/override.js` file.
Your application can overwrite any constant listed below by adding it to the `js/override.js` file. You only need to add what you want different than what is in `js/app-config.js`.

## Example
```javascript
Expand All @@ -7,19 +7,28 @@ define(['angular'], function(angular) {
config
.constant('OVERRIDE', {
'FEATURES' : { 'enabled' : true },
'APP_FLAG' : { 'loginOnLoad' : true, 'gaSearchParam' : 'f' }
'APP_FLAG' : { 'loginOnLoad' : true, 'gaSearchParam' : 'f' },
'FOOTER_URLS' : [{ "url" : "http://www.google.com",
"target" : "_blank",
"title" : "Google"
}]
})
return config;
});

```

Alright, lot going on here so lets take a walk through this.
+ Line 1 is just the `requirejs` wrapper, no biggy.
+ Line 2 & 3 are just setting up this module in angular. This will be pulled in during the `/portal/main.js` execution.
+ Line 4 defines the constant "OVERRIDE". This will contain the json that will be overwritten
+ Line 5 is an example override for something in the `FEATURES` category. Each category must be the object name. In this instance that is `FEATURES`. The value is `JSON` and each key is a key shown below of which you wish to override. In this instance we are overwriting `enabled`. By default its set to `false`, but with this config it will now be `true`.
+ Line 6 is an example of changing more than one config in a single category
+ `Line 1` is just the `requirejs` wrapper, no biggy.
+ `Line 2 & 3` are just setting up this module in angular. This will be pulled in during the `/portal/main.js` execution.
+ `Line 4` defines the constant "OVERRIDE". This will contain the json that will be overwritten
+ `Line 5` is an example override for something in the `FEATURES` category. Each category must be the object name. In this instance that is `FEATURES`. The value is `JSON` and each key is a key shown below of which you wish to override. In this instance we are overwriting `enabled`. By default its set to `false`, but with this config it will now be `true`.
+ `Line 6` is an example of changing more than one config in a single category
+ `Line 7-10` is an interesting example. Its an array config category. This will append to the default values. In this case it'll add a footer url for google.

If you have questions please ask.

## The Configuration Options

#### APP_FLAGS
+ `defaultTheme` : This is the default theme you want (see frame-config.js for the array list of themes). Provide an index number to just have simple selection, or set to the string `'group'` to enable group selection. If you do group selection make sure you set the `SERVICE_LOC.groupURL`.
Expand Down
4 changes: 1 addition & 3 deletions uw-frame-components/js/override.js
Expand Up @@ -6,9 +6,7 @@ define(['angular'], function(angular) {
config
//see configuration.md for howto
.constant('OVERRIDE', {
'FEATURES' : {
'enabled' : true
}

})

return config;
Expand Down
16 changes: 11 additions & 5 deletions uw-frame-components/portal/main.js
Expand Up @@ -201,12 +201,18 @@ define([
console.log(new Date() + " : start app-config override");
var count = 0, groups = 0;
for(var i in configsName) {
if(OVERRIDE[configsName[i]]) {
var curConfig = configsName[i];
if(OVERRIDE[curConfig]) {
groups++;
for(var key in configs[i]) {
if(typeof OVERRIDE[configsName[i]][key] !== 'undefined') {
configs[i][key] = OVERRIDE[configsName[i]][key];
count++;
if(Array.isArray(configs[i])){//arrays are special, append
Array.prototype.push.apply(configs[i], OVERRIDE[curConfig]);
count++;
} else {//treat as an object
for(var key in configs[i]) {
if(typeof OVERRIDE[curConfig][key] !== 'undefined') {
configs[i][key] = OVERRIDE[curConfig][key];
count++;
}
}
}
}
Expand Down

0 comments on commit 175c88f

Please sign in to comment.