Skip to content

Commit

Permalink
Transfer edit fixed currency rate #nz9k0y
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jul 29, 2021
1 parent 64b640e commit 091f3d7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
27 changes: 26 additions & 1 deletion resources/assets/js/views/banking/transfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const app = new Vue({
form: new Form('transfer'),
bulk_action: new BulkAction('transfers'),
show_rate: false,
edit: {
status: false,
form_account: false,
to_account: false,
},

transfer_form: new Form('template'),
template: {
Expand All @@ -48,6 +53,11 @@ const app = new Vue({
return;
}

if (this.edit.status && this.edit.form_account < 2) {
this.edit.form_account++;
return;
}

let from_promise = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
params: {
account_id: from_account_id
Expand Down Expand Up @@ -77,6 +87,11 @@ const app = new Vue({
return;
}

if (this.edit.status && this.edit.to_account < 2) {
this.edit.to_account++;
return;
}

let to_promise = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
params: {
account_id: to_account_id
Expand Down Expand Up @@ -126,5 +141,15 @@ const app = new Vue({
errors: this.transfer_form.errors
};
},
}
},

created() {
if (typeof transfer_edit !== 'undefined' && transfer_edit) {
this.show_rate = true;

this.edit.status = true;
this.edit.form_account = 1;
this.edit.to_account = 1;
}
},
});
28 changes: 22 additions & 6 deletions resources/views/banking/transfers/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,27 @@

{{ Form::selectGroup('to_account_id', trans('transfers.to_account'), 'university', $accounts, $transfer->to_account_id, ['required' => 'required', 'change' => 'onChangeToAccount']) }}

<div class="d-none w-100" :class="[{'d-flex' : show_rate}]">
{!! Form::hidden('from_currency_code', $transfer->from_currency_code, ['id' => 'from_currency_code', 'v-model' => 'form.from_currency_code']) !!}
@if ($transfer->from_currency_code != $transfer->to_currency_code)
<div class="w-100" :class="[show_rate ? 'd-flex' : 'd-none']">
{!! Form::hidden('from_currency_code', $transfer->from_currency_code, ['id' => 'from_currency_code', 'v-model' => 'form.from_currency_code']) !!}

{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', [':disabled' => "form.from_currency_code == '" . setting('default.currency') . "'"], $transfer->from_account_rate) }}
{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', [':disabled' => "form.from_currency_code == '" . setting('default.currency') . "'"], $transfer->from_account_rate) }}

{!! Form::hidden('to_currency_code', $transfer->to_currency_code, ['id' => 'to_currency_code', 'v-model' => 'form.to_currency_code']) !!}
{!! Form::hidden('to_currency_code', $transfer->to_currency_code, ['id' => 'to_currency_code', 'v-model' => 'form.to_currency_code']) !!}

{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', [':disabled' => "form.to_currency_code == '" . setting('default.currency') . "'"], $transfer->to_account_rate) }}
</div>
{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', [':disabled' => "form.to_currency_code == '" . setting('default.currency') . "'"], $transfer->to_account_rate) }}
</div>
@else
<div class="d-none w-100" :class="[{'d-flex' : show_rate}]">
{!! Form::hidden('from_currency_code', $transfer->from_currency_code, ['id' => 'from_currency_code', 'v-model' => 'form.from_currency_code']) !!}

{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', [':disabled' => "form.from_currency_code == '" . setting('default.currency') . "'"], $transfer->from_account_rate) }}

{!! Form::hidden('to_currency_code', $transfer->to_currency_code, ['id' => 'to_currency_code', 'v-model' => 'form.to_currency_code']) !!}

{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', [':disabled' => "form.to_currency_code == '" . setting('default.currency') . "'"], $transfer->to_account_rate) }}
</div>
@endif

{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], $transfer->amount) }}

Expand Down Expand Up @@ -61,5 +73,9 @@
@endsection

@push('scripts_start')
<script type="text/javascript">
var transfer_edit = {{ $transfer->id }};
</script>

<script src="{{ asset('public/js/banking/transfers.js?v=' . version('short')) }}"></script>
@endpush

0 comments on commit 091f3d7

Please sign in to comment.