OfflinePayment edit payment method.

This commit is contained in:
Cüneyt Şentürk 2021-02-01 00:47:39 +03:00
parent 55081186d8
commit a5e4ee3a4c
3 changed files with 44 additions and 5 deletions

View File

@ -34,13 +34,14 @@ class Settings extends Controller
*/
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']]);

View File

@ -27,6 +27,8 @@ const app = new Vue({
data() {
return {
form: new Form('offline-payment'),
update_code: null,
form_loading: '',
}
},
@ -34,6 +36,8 @@ const app = new Vue({
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', {
@ -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 = '';
});
},

View File

@ -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') }}
@ -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>
@ -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