Skip to content

Commit

Permalink
Store: Updated configstore to get list of applications
Browse files Browse the repository at this point in the history
  • Loading branch information
danesparza committed Apr 9, 2016
1 parent 4682ba7 commit 2542882
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
21 changes: 19 additions & 2 deletions js/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ var MainApp = (function (_Component) {
// Set initial state:
this.state = {
configItems: [],
currentEditConfigItem: {}
currentEditConfigItem: {},
applications: []
};

// Bind our events:
Expand Down Expand Up @@ -674,7 +675,8 @@ var MainApp = (function (_Component) {
key: '_onChange',
value: function _onChange() {
this.setState({
configItems: _storesConfigStore2['default'].getConfigItems()
configItems: _storesConfigStore2['default'].getConfigItems(),
applications: _storesConfigStore2['default'].getApplications()
});
}
}, {
Expand Down Expand Up @@ -960,6 +962,21 @@ var ConfigStore = (function (_Store) {
value: function getConfigItems() {
return this.configitems;
}
}, {
key: 'getApplications',
value: function getApplications() {
var applications = [];

// Cycle through and get the list of applications:
applications = this.configitems.map(function (item) {
return item.application;
});
applications = applications.filter(function (v, i) {
return applications.indexOf(v) == i;
});

return applications;
}
}, {
key: '__onDispatch',
value: function __onDispatch(action) {
Expand Down
6 changes: 4 additions & 2 deletions js/components/MainApp.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class MainApp extends Component {
// Set initial state:
this.state = {
configItems: [],
currentEditConfigItem: {}
currentEditConfigItem: {},
applications: []
};

// Bind our events:
Expand Down Expand Up @@ -146,7 +147,8 @@ class MainApp extends Component {

_onChange() {
this.setState({
configItems: ConfigStore.getConfigItems()
configItems: ConfigStore.getConfigItems(),
applications: ConfigStore.getApplications()
});
}

Expand Down
10 changes: 10 additions & 0 deletions js/stores/ConfigStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ class ConfigStore extends Store {
return this.configitems;
}

getApplications() {
let applications = [];

// Cycle through and get the list of applications:
applications = this.configitems.map(function(item) { return item.application; });
applications = applications.filter(function(v,i) { return applications.indexOf(v) == i; });

return applications;
}

__onDispatch(action) {

switch(action.actionType) {
Expand Down

0 comments on commit 2542882

Please sign in to comment.