Skip to content

Firefly III: a personal finances manager

Fix ability to change the currency.

James Colec599336c6a99
diff --git a/app/View/Components/Form/Alpine/TransactionCurrency.php b/app/View/Components/Form/Alpine/TransactionCurrency.php
new file mode 100644
index 0000000000..896a526b24
--- /dev/null
+++ b/app/View/Components/Form/Alpine/TransactionCurrency.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace FireflyIII\View\Components\Form\Alpine;
+
+use Closure;
+use Illuminate\Contracts\View\View;
+use Illuminate\View\Component;
+
+class TransactionCurrency extends Component
+{
+ public string $value;
+ /**
+ * Create a new component instance.
+ */
+ public function __construct(string $value)
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * Get the view / contents that represent the component.
+ */
+ public function render(): View|Closure|string
+ {
+ return view('components.form.alpine.transaction-currency');
+ }
+}
diff --git a/resources/assets/v3/js/pages/administrations/edit.js b/resources/assets/v3/js/pages/administrations/edit.js
index ff4b567d88..84601acba0 100644
--- a/resources/assets/v3/js/pages/administrations/edit.js
+++ b/resources/assets/v3/js/pages/administrations/edit.js
@@ -18,11 +18,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-// CSS
import '../../boot/bootstrap.js';
import sidebar from '../../pages/shared/sidebar.js';
import dates from '../shared/dates.js';
import i18next from "i18next";
+import Get from '../../api/model/currency/get.js';
let edit = function () {
return {
@@ -32,6 +32,7 @@ let edit = function () {
title: '',
currency_id: 0,
},
+ currencies: [],
errors: {
title: [],
currency_id: [],
@@ -58,6 +59,16 @@ let edit = function () {
};
this.pageTitle = this.administration.title;
});
+ const params = {page:1, limit:1337};
+ (new Get).list(params).then((response => {
+ this.currencies = response.data.data.map((currency) => {
+ return {
+ id: currency.id,
+ code: currency.attributes.code,
+ name: currency.attributes.name,
+ };
+ });
+ }));
},
submit: function (e) {
// reset messages
diff --git a/resources/views/administrations/edit.blade.php b/resources/views/administrations/edit.blade.php
index 4298bddd73..9a6566b0e8 100644
--- a/resources/views/administrations/edit.blade.php
+++ b/resources/views/administrations/edit.blade.php
@@ -49,11 +49,10 @@
</div>
<div class="card-body">
<x-form.alpine.title value="administration.title" />
+ <x-form.alpine.transaction-currency value="administration.currency_id" />
TODO currency
- <Title :value=administration.title :error="errors.title" v-on:input="administration.title = $event"></Title>
-
<UserGroupCurrency :value=administration.currency_id :error="errors.currency_id"
v-on:input="administration.currency_id = $event"></UserGroupCurrency>
</div>
diff --git a/resources/views/components/form/alpine/transaction-currency.blade.php b/resources/views/components/form/alpine/transaction-currency.blade.php
new file mode 100644
index 0000000000..96d3afb761
--- /dev/null
+++ b/resources/views/components/form/alpine/transaction-currency.blade.php
@@ -0,0 +1,29 @@
+<div class="mb-3">
+ <div class="row">
+ <label for="form_transaction_currency_id" class="col-sm-3 col-form-label has-validation">{{ __('form.transaction_currency_id') }}</label>
+ <div class="col-sm-9">
+ <div class="input-group has-validation">
+ <select id="form_transaction_currency_id"
+ ref="transaction_currency_id"
+ x-model={{ $value }}
+ name="transaction_currency_id"
+ @input="handleInput"
+ x-bind:class="{'form-select': true, 'is-invalid': errors.currency_id.length > 0}"
+ >
+ <template x-for="currency in currencies" :key="currency.id">
+ <option :value="currency.id" x-text="currency.name"></option>
+ </template>
+ </select>
+ </div>
+ </div>
+ </div>
+ <template x-for="error in errors.currency_id">
+ <div class="row">
+ <div class="col-sm-9 offset-sm-3">
+ <ul class="list-unstyled">
+ <li class="text-danger" x-text="error"></li>
+ </ul>
+ </div>
+ </div>
+ </template>
+</div>