1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-06-13 13:39:23 -04:00

Add per-user default currency

This commit is contained in:
2017-06-21 21:25:38 -04:00
parent 25b04a4f0f
commit 4e73e8b508
12 changed files with 237 additions and 23 deletions

View File

@ -5,6 +5,7 @@ var ErrorActions = require('./ErrorActions');
var models = require('../models.js');
var Security = models.Security;
var Error = models.Error;
var SecurityType = models.SecurityType;
function searchSecurityTemplates(searchString, searchType) {
return {
@ -23,6 +24,19 @@ function securityTemplatesSearched(searchString, searchType, securities) {
}
}
function fetchCurrencyTemplates() {
return {
type: SecurityTemplateConstants.FETCH_CURRENCIES
}
}
function currencyTemplatesFetched(currencies) {
return {
type: SecurityTemplateConstants.CURRENCIES_FETCHED,
currencies: currencies
}
}
function search(searchString, searchType, limit) {
return function (dispatch) {
dispatch(searchSecurityTemplates(searchString, searchType));
@ -57,6 +71,38 @@ function search(searchString, searchType, limit) {
};
}
function fetchCurrencies() {
return function (dispatch) {
dispatch(fetchCurrencyTemplates());
$.ajax({
type: "GET",
dataType: "json",
url: "securitytemplate/?search=&type=currency",
success: function(data, status, jqXHR) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
dispatch(ErrorActions.serverError(e));
} else if (data.securities == null) {
dispatch(currencyTemplatesFetched(new Array()));
} else {
dispatch(currencyTemplatesFetched(
data.securities.map(function(json) {
var s = new Security();
s.fromJSON(json);
return s;
})));
}
},
error: function(jqXHR, status, error) {
dispatch(ErrorActions.ajaxError(error));
}
});
};
}
module.exports = {
search: search
search: search,
fetchCurrencies: fetchCurrencies
};