Also include budget in currency conversion.

This commit is contained in:
James Cole
2025-07-30 09:59:52 +02:00
parent 6bdff95d87
commit 30da3f4399
7 changed files with 120 additions and 64 deletions

View File

@@ -48,9 +48,19 @@ export default () => ({
}
this.getFreshData();
},
eventListeners: {
['@convert-to-native.window'](event){
console.log('I heard that! (dashboard/budgets)');
this.convertToNative = event.detail;
chartData = null;
this.loadChart();
}
},
drawChart(options) {
if (null !== chart) {
chart.data.datasets = options.data.datasets;
chart.data = options.data;
chart.update();
return;
}
@@ -59,7 +69,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey('ds_bdg_chart', {start: start, end: end});
const cacheKey = getCacheKey('ds_bdg_chart', {convertToNative: this.convertToNative, start: start, end: end});
//const cacheValid = window.store.get('cacheValid');
const cacheValid = false;
let cachedData = window.store.get(cacheKey);

View File

@@ -33,6 +33,17 @@ let afterPromises = false;
export default () => ({
loading: false,
convertToNative: false,
eventListeners: {
['@convert-to-native.window'](event){
console.log('I heard that! (dashboard/categories)');
this.convertToNative = event.detail;
chartData = null;
this.loadChart();
}
},
generateOptions(data) {
currencies = [];
let options = getDefaultChartSettings('column');
@@ -147,7 +158,7 @@ export default () => ({
getFreshData() {
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const cacheKey = getCacheKey('ds_ct_chart', {start: start, end: end});
const cacheKey = getCacheKey('ds_ct_chart', {convertToNative: this.convertToNative, start: start, end: end});
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);

View File

@@ -71,9 +71,10 @@ let index = function () {
return {
convertToNative: false,
saveNativeSettings(event) {
setVariable('convert_to_native', event.currentTarget.checked).then(() => {
console.log('Set convert to native to: ', event.currentTarget.checked);
this.$dispatch('convert-to-native', event.currentTarget.checked);
let target = event.currentTarget || event.target;
setVariable('convert_to_native',target.checked).then(() => {
console.log('Set convert to native to: ', target.checked);
this.$dispatch('convert-to-native', target.checked);
});
},
init() {

View File

@@ -1,4 +1,4 @@
<div class="row mb-2" x-data="budgets">
<div class="row mb-2" x-data="budgets" x-bind="eventListeners">
<div class="col">
<div class="card">
<div class="card-header">

View File

@@ -1,4 +1,4 @@
<div class="row mb-2" x-data="categories">
<div class="row mb-2" x-data="categories" x-bind="eventListeners">
<div class="col">
<div class="card">
<div class="card-header">