mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-11 12:18:08 +00:00
Fix #11102
This commit is contained in:
@@ -131,6 +131,7 @@ abstract class Controller extends BaseController
|
|||||||
$this->primaryCurrency = null;
|
$this->primaryCurrency = null;
|
||||||
// get shown-intro-preference:
|
// get shown-intro-preference:
|
||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
|
View::share('anonymous', Steam::anonymous());
|
||||||
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||||
$language = Steam::getLanguage();
|
$language = Steam::getLanguage();
|
||||||
$locale = Steam::getLocale();
|
$locale = Steam::getLocale();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ use FireflyIII\Models\Account;
|
|||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Facades\Steam;
|
||||||
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
|
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
@@ -114,6 +115,7 @@ class JavascriptController extends Controller
|
|||||||
'currencyCode' => $currency->code,
|
'currencyCode' => $currency->code,
|
||||||
'currencySymbol' => $currency->symbol,
|
'currencySymbol' => $currency->symbol,
|
||||||
'accountingLocaleInfo' => $accounting,
|
'accountingLocaleInfo' => $accounting,
|
||||||
|
'anonymous' => var_export(Steam::anonymous(), true),
|
||||||
'language' => $lang,
|
'language' => $lang,
|
||||||
'dateRangeTitle' => $dateRange['title'],
|
'dateRangeTitle' => $dateRange['title'],
|
||||||
'locale' => $locale,
|
'locale' => $locale,
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ class Amount
|
|||||||
*/
|
*/
|
||||||
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
|
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
|
||||||
{
|
{
|
||||||
|
$amount = Steam::anonymous() ? '0' : $amount;
|
||||||
$locale = Steam::getLocale();
|
$locale = Steam::getLocale();
|
||||||
$rounded = Steam::bcround($amount, $decimalPlaces);
|
$rounded = Steam::bcround($amount, $decimalPlaces);
|
||||||
$coloured ??= true;
|
$coloured ??= true;
|
||||||
|
|||||||
@@ -627,6 +627,19 @@ class Steam
|
|||||||
return $locale;
|
return $locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function anonymous(): bool // get preference
|
||||||
|
{
|
||||||
|
$singleton = PreferencesSingleton::getInstance();
|
||||||
|
$cached = $singleton->getPreference('anonymous');
|
||||||
|
if (null !== $cached) {
|
||||||
|
return $cached;
|
||||||
|
}
|
||||||
|
$anonymous = app('preferences')->get('anonymous', config('firefly.default_preferences.anonymous', false))->data;
|
||||||
|
$singleton->setPreference('anonymous', $anonymous);
|
||||||
|
|
||||||
|
return $anonymous;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLocaleArray(string $locale): array
|
public function getLocaleArray(string $locale): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ return [
|
|||||||
'darkMode' => 'browser',
|
'darkMode' => 'browser',
|
||||||
'list_length' => 10, // to be removed if v1 is cancelled.
|
'list_length' => 10, // to be removed if v1 is cancelled.
|
||||||
'default_preferences' => [
|
'default_preferences' => [
|
||||||
|
'anonymous' => false,
|
||||||
'frontpageAccounts' => [],
|
'frontpageAccounts' => [],
|
||||||
'listPageSize' => 50,
|
'listPageSize' => 50,
|
||||||
'currencyPreference' => 'EUR',
|
'currencyPreference' => 'EUR',
|
||||||
|
|||||||
@@ -42,13 +42,11 @@ function formatLabel(str, maxwidth) {
|
|||||||
if (concat.length > maxwidth) {
|
if (concat.length > maxwidth) {
|
||||||
sections.push(temp);
|
sections.push(temp);
|
||||||
temp = "";
|
temp = "";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (index === (words.length - 1)) {
|
if (index === (words.length - 1)) {
|
||||||
sections.push(concat);
|
sections.push(concat);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
temp = concat;
|
temp = concat;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,8 +60,7 @@ function formatLabel(str, maxwidth) {
|
|||||||
|
|
||||||
if (item.length < maxwidth) {
|
if (item.length < maxwidth) {
|
||||||
temp = item;
|
temp = item;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sections.push(item);
|
sections.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,9 +95,11 @@ var defaultChartOptions = {
|
|||||||
ticks: {
|
ticks: {
|
||||||
callback: function (tickValue) {
|
callback: function (tickValue) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
if (anonymous) {
|
||||||
|
return accounting.formatMoney(0);
|
||||||
|
}
|
||||||
// use first symbol or null:
|
// use first symbol or null:
|
||||||
return accounting.formatMoney(tickValue);
|
return accounting.formatMoney(tickValue);
|
||||||
|
|
||||||
},
|
},
|
||||||
beginAtZero: true
|
beginAtZero: true
|
||||||
}
|
}
|
||||||
@@ -112,8 +111,11 @@ var defaultChartOptions = {
|
|||||||
callbacks: {
|
callbacks: {
|
||||||
label: function (tooltipItem, data) {
|
label: function (tooltipItem, data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
return data.datasets[tooltipItem.datasetIndex].label + ': ' +
|
var string = accounting.formatMoney(tooltipItem.yLabel, data.datasets[tooltipItem.datasetIndex].currency_symbol);
|
||||||
accounting.formatMoney(tooltipItem.yLabel, data.datasets[tooltipItem.datasetIndex].currency_symbol);
|
if (anonymous) {
|
||||||
|
string = accounting.formatMoney(0);
|
||||||
|
}
|
||||||
|
return data.datasets[tooltipItem.datasetIndex].label + ': ' + string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +127,11 @@ var pieOptionsWithCurrency = {
|
|||||||
label: function (tooltipItem, data) {
|
label: function (tooltipItem, data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var value = data.datasets[0].data[tooltipItem.index];
|
var value = data.datasets[0].data[tooltipItem.index];
|
||||||
return data.labels[tooltipItem.index] + ': ' + accounting.formatMoney(value, data.datasets[tooltipItem.datasetIndex].currency_symbol[tooltipItem.index]);
|
var string = accounting.formatMoney(value, data.datasets[tooltipItem.datasetIndex].currency_symbol[tooltipItem.index]);
|
||||||
|
if (anonymous) {
|
||||||
|
string = accounting.formatMoney(0);
|
||||||
|
}
|
||||||
|
return data.labels[tooltipItem.index] + ': ' + string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -139,7 +145,11 @@ var defaultPieOptions = {
|
|||||||
label: function (tooltipItem, data) {
|
label: function (tooltipItem, data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var value = data.datasets[0].data[tooltipItem.index];
|
var value = data.datasets[0].data[tooltipItem.index];
|
||||||
return data.labels[tooltipItem.index] + ': ' + accounting.formatMoney(value);
|
var string = accounting.formatMoney(value);
|
||||||
|
if (anonymous) {
|
||||||
|
string = accounting.formatMoney(0);
|
||||||
|
}
|
||||||
|
return data.labels[tooltipItem.index] + ': ' + string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -153,7 +163,11 @@ var neutralDefaultPieOptions = {
|
|||||||
label: function (tooltipItem, data) {
|
label: function (tooltipItem, data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var value = data.datasets[0].data[tooltipItem.index];
|
var value = data.datasets[0].data[tooltipItem.index];
|
||||||
return data.labels[tooltipItem.index] + ': ' + accounting.formatMoney(value, '¤');
|
var string = accounting.formatMoney(value, '¤');
|
||||||
|
if(anonymous) {
|
||||||
|
string = accounting.formatMoney(0);
|
||||||
|
}
|
||||||
|
return data.labels[tooltipItem.index] + ': ' + string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ function parseToLocalDates() {
|
|||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
configAccounting(currencySymbol);
|
configAccounting(currencySymbol);
|
||||||
|
|
||||||
// on submit of logout button:
|
// on submit of logout button:
|
||||||
|
|||||||
@@ -17,13 +17,42 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
/** global: token, helpPageTitle */
|
/** global: token, helpPageTitle, anonymous */
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
$('#help').click(showHelp);
|
$('#help').click(showHelp);
|
||||||
|
$('#anonymous').click(changeAnonymity)
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function submitAnonymity(value) {
|
||||||
|
$.ajax({
|
||||||
|
url: 'api/v1/preferences/anonymous',
|
||||||
|
data: JSON.stringify({data: value}),
|
||||||
|
type: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeAnonymity(e) {
|
||||||
|
if (anonymous) {
|
||||||
|
console.log('Will DISABLE.');
|
||||||
|
submitAnonymity(false);
|
||||||
|
alert(anonymous_warning_off_txt);
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
if (!anonymous) {
|
||||||
|
console.log('Will ENABLE.');
|
||||||
|
submitAnonymity(true);
|
||||||
|
alert(anonymous_warning_on_txt);
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function showHelp(e) {
|
function showHelp(e) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var target = $(e.target);
|
var target = $(e.target);
|
||||||
|
|||||||
@@ -235,6 +235,8 @@ return [
|
|||||||
'advanced_options_explain' => 'Some pages in Firefly III have advanced options hidden behind this button. This page doesn\'t have anything fancy here, but do check out the others!',
|
'advanced_options_explain' => 'Some pages in Firefly III have advanced options hidden behind this button. This page doesn\'t have anything fancy here, but do check out the others!',
|
||||||
'here_be_dragons' => 'Hic sunt dracones',
|
'here_be_dragons' => 'Hic sunt dracones',
|
||||||
'bad_date_transaction' => 'Firefly III has detected you have transactions from before the year 1970. Please correct these transactions at your earliest convenience.',
|
'bad_date_transaction' => 'Firefly III has detected you have transactions from before the year 1970. Please correct these transactions at your earliest convenience.',
|
||||||
|
'anonymous_warning_on' => 'For your privacy, all amounts are now displayed as "zero". Warning: text input boxes may still show the original amounts!',
|
||||||
|
'anonymous_warning_off' => 'Amounts will be visible again. Please be mindful of your surroundings.',
|
||||||
|
|
||||||
// Webhooks
|
// Webhooks
|
||||||
'webhooks' => 'Webhooks',
|
'webhooks' => 'Webhooks',
|
||||||
|
|||||||
@@ -267,9 +267,14 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">{{ primaryCurrency.symbol }}</div>
|
<div class="input-group-addon">{{ primaryCurrency.symbol }}</div>
|
||||||
<input type="hidden" name="balance_currency_id" value="{{ primaryCurrency.id }}"/>
|
<input type="hidden" name="balance_currency_id" value="{{ primaryCurrency.id }}"/>
|
||||||
|
{% if not anonymous %}
|
||||||
<input class="form-control budget_amount" data-original="0" data-id="{{ budget.id }}"
|
<input class="form-control budget_amount" data-original="0" data-id="{{ budget.id }}"
|
||||||
data-currency="{{ primaryCurrency.id }}" data-limit="0" value="0" autocomplete="off" min="0" name="amount"
|
data-currency="{{ primaryCurrency.id }}" data-limit="0" value="0" autocomplete="off" min="0" name="amount"
|
||||||
type="number">
|
type="number">
|
||||||
|
{% endif %}
|
||||||
|
{% if anonymous %}
|
||||||
|
---
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<span class="text-danger budget_warning" data-id="{{ budget.id }}" data-budgetLimit="{{ budgetLimit.id }}"
|
<span class="text-danger budget_warning" data-id="{{ budget.id }}" data-budgetLimit="{{ budgetLimit.id }}"
|
||||||
style="display:none;"></span>
|
style="display:none;"></span>
|
||||||
@@ -283,10 +288,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="input-group bl_entry" data-budget-limit-id="{{ budgetLimit.id }}">
|
<div class="input-group bl_entry" data-budget-limit-id="{{ budgetLimit.id }}">
|
||||||
<div class="input-group-addon">{{ budgetLimit.currency_symbol }}</div>
|
<div class="input-group-addon">{{ budgetLimit.currency_symbol }}</div>
|
||||||
|
{% if not anonymous %}
|
||||||
<input class="form-control budget_amount" data-original="{{ budgetLimit.amount }}"
|
<input class="form-control budget_amount" data-original="{{ budgetLimit.amount }}"
|
||||||
data-id="{{ budget.id }}" data-limit="{{ budgetLimit.id }}" value="{{ budgetLimit.amount }}"
|
data-id="{{ budget.id }}" data-limit="{{ budgetLimit.id }}" value="{{ budgetLimit.amount }}"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
min="0" name="amount" type="number">
|
min="0" name="amount" type="number">
|
||||||
|
{% endif %}
|
||||||
|
{% if anonymous %}
|
||||||
|
---
|
||||||
|
{% endif %}
|
||||||
<div class="input-group-btn">
|
<div class="input-group-btn">
|
||||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
|
||||||
aria-expanded="false"><span class="caret"></span></button>
|
aria-expanded="false"><span class="caret"></span></button>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ ranges: ranges
|
|||||||
};
|
};
|
||||||
|
|
||||||
var uid = "{{ uid }}";
|
var uid = "{{ uid }}";
|
||||||
|
var anonymous = {{ anonymous }};
|
||||||
var language = "{{ language|escape }}";
|
var language = "{{ language|escape }}";
|
||||||
var locale = "{{ locale|escape }}";
|
var locale = "{{ locale|escape }}";
|
||||||
var currencyCode = '{{ currencyCode|escape('js') }}';
|
var currencyCode = '{{ currencyCode|escape('js') }}';
|
||||||
@@ -51,6 +52,9 @@ var acc_config_new = {format: accountingConfig};
|
|||||||
var helpPageTitle = "{{ trans('firefly.help_for_this_page')|escape('js') }}";
|
var helpPageTitle = "{{ trans('firefly.help_for_this_page')|escape('js') }}";
|
||||||
var helpPageBody = "{{ trans('firefly.help_for_this_page_body')|escape('js') }}";
|
var helpPageBody = "{{ trans('firefly.help_for_this_page_body')|escape('js') }}";
|
||||||
|
|
||||||
|
var anonymous_warning_on_txt = "{{ trans('firefly.anonymous_warning_on')|escape('js') }}";
|
||||||
|
var anonymous_warning_off_txt= "{{ trans('firefly.anonymous_warning_off')|escape('js') }}";
|
||||||
|
|
||||||
var edit_selected_txt = "{{ trans('firefly.mass_edit')|escape('js') }}";
|
var edit_selected_txt = "{{ trans('firefly.mass_edit')|escape('js') }}";
|
||||||
var edit_bulk_selected_txt = "{{ trans('firefly.bulk_edit')|escape('js') }}";
|
var edit_bulk_selected_txt = "{{ trans('firefly.bulk_edit')|escape('js') }}";
|
||||||
var delete_selected_txt = "{{ trans('firefly.mass_delete')|escape('js') }}";
|
var delete_selected_txt = "{{ trans('firefly.mass_delete')|escape('js') }}";
|
||||||
|
|||||||
@@ -111,7 +111,16 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="navbar-custom-menu">
|
<div class="navbar-custom-menu">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="hidden-sm hidden-xs">
|
||||||
|
<a href="#" id="anonymous">
|
||||||
|
{% if anonymous %}
|
||||||
|
<span class="text-danger fa fa-eye-slash"></span>
|
||||||
|
{% endif %}
|
||||||
|
{% if not anonymous %}
|
||||||
|
<span class="text-success fa fa-eye"></span>
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="hidden-sm hidden-xs">
|
<li class="hidden-sm hidden-xs">
|
||||||
<a href="#" id="help" data-route="{{ original_route_name }}"
|
<a href="#" id="help" data-route="{{ original_route_name }}"
|
||||||
data-extra="{{ objectType|default("") }}">
|
data-extra="{{ objectType|default("") }}">
|
||||||
|
|||||||
Reference in New Issue
Block a user