mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-06-13 13:39:23 -04:00
Add initial UI for user-editable securities
This commit is contained in:
@ -4,7 +4,9 @@ var UserReducer = require('./UserReducer');
|
||||
var SessionReducer = require('./SessionReducer');
|
||||
var AccountReducer = require('./AccountReducer');
|
||||
var SecurityReducer = require('./SecurityReducer');
|
||||
var SecurityTemplateReducer = require('./SecurityTemplateReducer');
|
||||
var SelectedAccountReducer = require('./SelectedAccountReducer');
|
||||
var SelectedSecurityReducer = require('./SelectedSecurityReducer');
|
||||
var ErrorReducer = require('./ErrorReducer');
|
||||
|
||||
module.exports = Redux.combineReducers({
|
||||
@ -12,6 +14,8 @@ module.exports = Redux.combineReducers({
|
||||
session: SessionReducer,
|
||||
accounts: AccountReducer,
|
||||
securities: SecurityReducer,
|
||||
securityTemplates: SecurityTemplateReducer,
|
||||
selectedAccount: SelectedAccountReducer,
|
||||
selectedSecurity: SelectedSecurityReducer,
|
||||
error: ErrorReducer
|
||||
});
|
||||
|
33
js/reducers/SecurityTemplateReducer.js
Normal file
33
js/reducers/SecurityTemplateReducer.js
Normal file
@ -0,0 +1,33 @@
|
||||
var assign = require('object-assign');
|
||||
|
||||
var SecurityTemplateConstants = require('../constants/SecurityTemplateConstants');
|
||||
var UserConstants = require('../constants/UserConstants');
|
||||
|
||||
var SecurityType = require('../models').SecurityType;
|
||||
|
||||
module.exports = function(state = {search: "", type: 0, templates: [], searchNumber: 0}, action) {
|
||||
switch (action.type) {
|
||||
case SecurityTemplateConstants.SEARCH_SECURITY_TEMPLATES:
|
||||
return {
|
||||
search: action.searchString,
|
||||
type: action.searchType,
|
||||
templates: []
|
||||
};
|
||||
case SecurityTemplateConstants.SECURITY_TEMPLATES_SEARCHED:
|
||||
if ((action.searchString != state.search) || (action.searchType != state.type))
|
||||
return state;
|
||||
return {
|
||||
search: action.searchString,
|
||||
type: action.searchType,
|
||||
templates: action.securities
|
||||
};
|
||||
case UserConstants.USER_LOGGEDOUT:
|
||||
return {
|
||||
search: "",
|
||||
type: 0,
|
||||
templates: []
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
23
js/reducers/SelectedSecurityReducer.js
Normal file
23
js/reducers/SelectedSecurityReducer.js
Normal file
@ -0,0 +1,23 @@
|
||||
var SecurityConstants = require('../constants/SecurityConstants');
|
||||
var UserConstants = require('../constants/UserConstants');
|
||||
|
||||
module.exports = function(state = -1, action) {
|
||||
switch (action.type) {
|
||||
case SecurityConstants.SECURITIES_FETCHED:
|
||||
for (var i = 0; i < action.securities.length; i++) {
|
||||
if (action.securities[i].SecurityId == state)
|
||||
return state;
|
||||
}
|
||||
return -1;
|
||||
case SecurityConstants.SECURITY_REMOVED:
|
||||
if (action.securityId == state)
|
||||
return -1;
|
||||
return state;
|
||||
case SecurityConstants.SECURITY_SELECTED:
|
||||
return action.securityId;
|
||||
case UserConstants.USER_LOGGEDOUT:
|
||||
return -1;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user