Skip to content

Commit 2542882

Browse files
committed
Store: Updated configstore to get list of applications
1 parent 4682ba7 commit 2542882

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

js/bundle.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ var MainApp = (function (_Component) {
586586
// Set initial state:
587587
this.state = {
588588
configItems: [],
589-
currentEditConfigItem: {}
589+
currentEditConfigItem: {},
590+
applications: []
590591
};
591592

592593
// Bind our events:
@@ -674,7 +675,8 @@ var MainApp = (function (_Component) {
674675
key: '_onChange',
675676
value: function _onChange() {
676677
this.setState({
677-
configItems: _storesConfigStore2['default'].getConfigItems()
678+
configItems: _storesConfigStore2['default'].getConfigItems(),
679+
applications: _storesConfigStore2['default'].getApplications()
678680
});
679681
}
680682
}, {
@@ -960,6 +962,21 @@ var ConfigStore = (function (_Store) {
960962
value: function getConfigItems() {
961963
return this.configitems;
962964
}
965+
}, {
966+
key: 'getApplications',
967+
value: function getApplications() {
968+
var applications = [];
969+
970+
// Cycle through and get the list of applications:
971+
applications = this.configitems.map(function (item) {
972+
return item.application;
973+
});
974+
applications = applications.filter(function (v, i) {
975+
return applications.indexOf(v) == i;
976+
});
977+
978+
return applications;
979+
}
963980
}, {
964981
key: '__onDispatch',
965982
value: function __onDispatch(action) {

js/components/MainApp.react.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class MainApp extends Component {
2929
// Set initial state:
3030
this.state = {
3131
configItems: [],
32-
currentEditConfigItem: {}
32+
currentEditConfigItem: {},
33+
applications: []
3334
};
3435

3536
// Bind our events:
@@ -146,7 +147,8 @@ class MainApp extends Component {
146147

147148
_onChange() {
148149
this.setState({
149-
configItems: ConfigStore.getConfigItems()
150+
configItems: ConfigStore.getConfigItems(),
151+
applications: ConfigStore.getApplications()
150152
});
151153
}
152154

js/stores/ConfigStore.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ class ConfigStore extends Store {
1414
return this.configitems;
1515
}
1616

17+
getApplications() {
18+
let applications = [];
19+
20+
// Cycle through and get the list of applications:
21+
applications = this.configitems.map(function(item) { return item.application; });
22+
applications = applications.filter(function(v,i) { return applications.indexOf(v) == i; });
23+
24+
return applications;
25+
}
26+
1727
__onDispatch(action) {
1828

1929
switch(action.actionType) {

0 commit comments

Comments
 (0)