mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Sync "convert to native"
This commit is contained in:
@@ -44,11 +44,22 @@ export default () => ({
|
||||
chartOptions: null,
|
||||
switchConvertToNative() {
|
||||
this.convertToNative = !this.convertToNative;
|
||||
setVariable('convertToNative', this.convertToNative);
|
||||
setVariable('convert_to_native', this.convertToNative);
|
||||
},
|
||||
localCacheKey(type) {
|
||||
return 'ds_accounts_' + type;
|
||||
},
|
||||
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! it is now ' + event.detail);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
doSomeReload() {
|
||||
console.log('doSomeReload');
|
||||
},
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
@@ -273,8 +284,11 @@ export default () => ({
|
||||
|
||||
init() {
|
||||
// console.log('accounts init');
|
||||
Promise.all([getVariable('viewRange', '1M'), getVariable('convertToNative', false), getVariable('language', 'en_US'),
|
||||
getConfiguration('cer.enabled', false)
|
||||
Promise.all([
|
||||
getVariable('viewRange', '1M'), // 0
|
||||
getVariable('convert_to_native', false), // 1
|
||||
getVariable('language', 'en_US'), // 2
|
||||
getConfiguration('cer.enabled', false) // 3
|
||||
]).then((values) => {
|
||||
//console.log('accounts after promises');
|
||||
this.convertToNative = values[1] && values[3];
|
||||
@@ -296,7 +310,7 @@ export default () => ({
|
||||
this.loadChart();
|
||||
this.loadAccounts();
|
||||
});
|
||||
window.store.observe('convertToNative', () => {
|
||||
window.store.observe('convert_to_native', () => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -153,7 +153,7 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('boxes init');
|
||||
// TODO can be replaced by "getVariables"
|
||||
Promise.all([getVariable('viewRange'), getVariable('convertToNative', false)]).then((values) => {
|
||||
Promise.all([getVariable('viewRange'), getVariable('convert_to_native', false)]).then((values) => {
|
||||
// console.log('boxes after promises');
|
||||
afterPromises = true;
|
||||
this.convertToNative = values[1];
|
||||
@@ -167,7 +167,7 @@ export default () => ({
|
||||
this.boxData = null;
|
||||
this.loadBoxes();
|
||||
});
|
||||
window.store.observe('convertToNative', (newValue) => {
|
||||
window.store.observe('convert_to_native', (newValue) => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -123,8 +123,6 @@ export default () => ({
|
||||
for (const i in data) {
|
||||
if (data.hasOwnProperty(i)) {
|
||||
let current = data[i];
|
||||
console.log('Now at');
|
||||
console.log(current);
|
||||
// // convert to EUR yes no?
|
||||
let label = current.label + ' (' + current.currency_code + ')';
|
||||
options.data.labels.push(label);
|
||||
@@ -159,7 +157,7 @@ export default () => ({
|
||||
|
||||
|
||||
init() {
|
||||
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
afterPromises = true;
|
||||
if (false === this.loading) {
|
||||
@@ -176,7 +174,7 @@ export default () => ({
|
||||
this.loadChart();
|
||||
}
|
||||
});
|
||||
window.store.observe('convertToNative', (newValue) => {
|
||||
window.store.observe('convert_to_native', (newValue) => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -183,7 +183,7 @@ export default () => ({
|
||||
},
|
||||
init() {
|
||||
// console.log('categories init');
|
||||
Promise.all([getVariable('convertToNative', false),]).then((values) => {
|
||||
Promise.all([getVariable('convert_to_native', false),]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
afterPromises = true;
|
||||
this.loadChart();
|
||||
@@ -195,7 +195,7 @@ export default () => ({
|
||||
this.chartData = null;
|
||||
this.loadChart();
|
||||
});
|
||||
window.store.observe('convertToNative', (newValue) => {
|
||||
window.store.observe('convert_to_native', (newValue) => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -46,7 +46,8 @@ import {
|
||||
} from "chart.js";
|
||||
import 'chartjs-adapter-date-fns';
|
||||
import {showInternalsButton} from "../../support/page-settings/show-internals-button.js";
|
||||
import {showWizardButton} from "../../support/page-settings/show-wizard-button.js";
|
||||
import {setVariable} from "../../store/set-variable.js";
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
|
||||
// register things
|
||||
Chart.register({
|
||||
@@ -66,7 +67,25 @@ Chart.register({
|
||||
Legend
|
||||
});
|
||||
|
||||
let index = function () {
|
||||
return {
|
||||
convertToNative: false,
|
||||
saveNativeSettings(event) {
|
||||
setVariable('convert_to_native', event.currentTarget.checked);
|
||||
this.$dispatch('convert-to-native', event.currentTarget.checked);
|
||||
console.log('saveNativeSettings + dispatch.');
|
||||
},
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
console.log('convert_to_native: ' + this.convertToNative);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const comps = {
|
||||
index,
|
||||
dates,
|
||||
boxes,
|
||||
accounts,
|
||||
|
@@ -129,7 +129,7 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('piggies init');
|
||||
apiData = [];
|
||||
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
|
||||
afterPromises = true;
|
||||
this.convertToNative = values[0];
|
||||
@@ -144,7 +144,7 @@ export default () => ({
|
||||
apiData = [];
|
||||
this.loadPiggyBanks();
|
||||
});
|
||||
window.store.observe('convertToNative', (newValue) => {
|
||||
window.store.observe('convert_to_native', (newValue) => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -94,6 +94,7 @@ function getObjectName(type, name, direction, code) {
|
||||
if ('category' === type && null === name && 'out' === direction) {
|
||||
return translations.unknown_category + ' (' + translations.out + (convertToNative ? ', ' + code + ')' : ')');
|
||||
}
|
||||
|
||||
// account 4x
|
||||
if ('account' === type && null === name && 'in' === direction) {
|
||||
return translations.unknown_source + (convertToNative ? ' (' + code + ')' : '');
|
||||
@@ -348,9 +349,13 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('sankey init');
|
||||
transactions = [];
|
||||
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
convertToNative = values[0];
|
||||
|
||||
this.convertToNative = false;
|
||||
convertToNative = false;
|
||||
|
||||
// some translations:
|
||||
translations.all_money = i18next.t('firefly.all_money');
|
||||
translations.category = i18next.t('firefly.category');
|
||||
@@ -378,7 +383,7 @@ export default () => ({
|
||||
this.transactions = [];
|
||||
this.loadChart();
|
||||
});
|
||||
window.store.observe('convertToNative', (newValue) => {
|
||||
window.store.observe('convert_to_native', (newValue) => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -305,7 +305,7 @@ export default () => ({
|
||||
},
|
||||
|
||||
init() {
|
||||
Promise.all([getVariable('convertToNative', false)]).then((values) => {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
afterPromises = true;
|
||||
|
||||
@@ -323,7 +323,7 @@ export default () => ({
|
||||
this.startSubscriptions();
|
||||
}
|
||||
});
|
||||
window.store.observe('convertToNative', (newValue) => {
|
||||
window.store.observe('convert_to_native', (newValue) => {
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ export function setVariable(name, value = null) {
|
||||
// preference does not exist (yet).
|
||||
// POST it
|
||||
let poster = (new Post);
|
||||
poster.post(name, value).then((response) => {
|
||||
poster.post(name, value).then((response) => {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -21,6 +21,14 @@
|
||||
import {format} from "date-fns";
|
||||
|
||||
export default function (amount, currencyCode) {
|
||||
if( (typeof amount !== 'number' && typeof amount !== 'string') || isNaN(amount)) {
|
||||
console.warn('format-money: amount is not a number:', amount);
|
||||
return '';
|
||||
}
|
||||
if(typeof currencyCode !== 'string' || currencyCode.length !== 3) {
|
||||
console.warn('format-money: currencyCode is not a valid ISO 4217 code:', currencyCode);
|
||||
return '';
|
||||
}
|
||||
let locale = window.__localeId__.replace('_', '-');
|
||||
|
||||
return Intl.NumberFormat(locale, {
|
||||
|
Reference in New Issue
Block a user