Skip to content

Commit

Permalink
OfflinePayment edit payment method.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jan 31, 2021
1 parent 5508118 commit a5e4ee3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/OfflinePayments/Http/Controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ public function edit()
*/
public function update(Request $request)
{
$code_exists = true;
$methods = json_decode(setting('offline-payments.methods'), true);
if(array_search($request->update_code, array_column($methods, 'code')) == false) {
$request->merge(['code_exists' => false]);
}else{
$request->merge(['code_exists' => true]);

if (array_search($request->update_code, array_column($methods, 'code')) == false) {
$code_exists = false;
}
if (!empty($request->get('update_code')) && $request->get('code_exists') == true) {

if (!empty($request->get('update_code')) && $code_exists == true) {
$payment_method = $this->dispatch(new UpdatePaymentMethod($request));

$message = trans('messages.success.updated', ['type' => $payment_method['name']]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ const app = new Vue({
data() {
return {
form: new Form('offline-payment'),
update_code: null,
form_loading: '',
}
},

methods:{
onEdit(event) {
var code = event.target.dataset.code;

this.form_loading = '<span class="form-loading-bar"><span class="form-loading-spin"><i class="fa fa-spinner fa-spin"></i></span></span>';

this.form.loading = true;

axios.post('offline-payments/settings/get', {
Expand All @@ -46,10 +50,13 @@ const app = new Vue({
this.form.order = response.data.data.order;
this.form.description = response.data.data.description;
this.form.update_code = response.data.data.update_code;
this.update_code = response.data.data.update_code;
this.form.loading = false;
this.form_loading = '';
})
.catch(error => {
this.form.loading = false;
this.form_loading = '';
});
},

Expand Down
31 changes: 31 additions & 0 deletions modules/OfflinePayments/Resources/views/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
]) !!}

<div class="card-body">
<div id="form-loading" class="active" v-if="form_loading" v-html="form_loading"></div>

<div class="row">
{{ Form::textGroup('name', trans('general.name'), 'money-check', ['required' => 'required'], null, 'col-md-12') }}

Expand Down Expand Up @@ -92,6 +94,7 @@
'title' => trans('general.delete'),
'data-code' => $item->code,
'id' => 'delete-' . $item->code,
':disabled' => "update_code == '" . $item->code . "'",
'@click' => 'confirmDelete("' . $item->code . '", "' . trans('general.delete') . ' ' . trans_choice('offline-payments::general.methods', 1) . '", "' . trans('general.delete_confirm', ['name' => '<strong>' . $item->name . '</strong>', 'type' => mb_strtolower(trans('offline-payments::general.name'))]) . '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")',
]) !!}
</div>
Expand All @@ -111,3 +114,31 @@
@push('scripts_start')
<script src="{{ asset('modules/OfflinePayments/Resources/assets/js/offline-payments.min.js?v=' . module_version('offline-payments')) }}"></script>
@endpush

@push('stylesheet')
<style type="text/css">
#form-loading.active, #delete-loading.active {
font-size: 35px;
position: absolute;
z-index: 500;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: rgb(136, 136, 136);
opacity: 0.2;
-moz-border-radius-bottomleft: 1px;
-moz-border-radius-bottomright: 1px;
border-bottom-left-radius: 1px;
border-bottom-right-radius: 1px;
}
.form-loading-spin {
font-size: 100px;
position: absolute;
margin: auto;
color: #fff;
padding: 73% 37%;
}
</style>
@endpush

0 comments on commit a5e4ee3

Please sign in to comment.