OfflinePayment add new and vue issue solved.
This commit is contained in:
		| @@ -11,6 +11,7 @@ use Modules\OfflinePayments\Http\Requests\SettingDelete as DRequest; | ||||
|  | ||||
| class Settings extends Controller | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * Show the form for editing the specified resource. | ||||
|      * | ||||
| @@ -34,34 +35,34 @@ class Settings extends Controller | ||||
|     { | ||||
|         $methods = json_decode(setting('offline-payments.methods'), true); | ||||
|  | ||||
|         if (isset($request['update_code'])) { | ||||
|         if (!empty($request->get('update_code', null))) { | ||||
|             foreach ($methods as $key => $method) { | ||||
|                 if ($method['code'] != $request['update_code']) { | ||||
|                 if ($method['code'] != $request->get('update_code')) { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 $method = explode('.', $request['update_code']); | ||||
|                 $method = explode('.', $request->get('update_code')); | ||||
|  | ||||
|                 $methods[$key] = [ | ||||
|                     'code' => 'offline-payments.' . $request['code'] . '.' . $method[2], | ||||
|                     'name' => $request['name'], | ||||
|                     'customer' => $request['customer'], | ||||
|                     'order' => $request['order'], | ||||
|                     'description' => $request['description'], | ||||
|                     'code' => 'offline-payments.' . $request->get('code') . '.' . $method[2], | ||||
|                     'name' => $request->get('name'), | ||||
|                     'customer' => $request->get('customer'), | ||||
|                     'order' => $request->get('order'), | ||||
|                     'description' => $request->get('description'), | ||||
|                 ]; | ||||
|             } | ||||
|  | ||||
|             $message = trans('messages.success.updated', ['type' => $request['name']]); | ||||
|         } else { | ||||
|             $methods[] = [ | ||||
|                 'code' => 'offline-payments.' . $request['code'] . '.' . (count($methods) + 1), | ||||
|                 'name' => $request['name'], | ||||
|                 'customer' => $request['customer'], | ||||
|                 'order' => $request['order'], | ||||
|                 'description' => $request['description'], | ||||
|                 'code' => 'offline-payments.' . $request->get('code') . '.' . (count($methods) + 1), | ||||
|                 'name' => $request->get('name'), | ||||
|                 'customer' => $request->get('customer'), | ||||
|                 'order' => $request->get('order'), | ||||
|                 'description' => $request->get('description'), | ||||
|             ]; | ||||
|  | ||||
|             $message = trans('messages.success.added', ['type' => $request['name']]); | ||||
|             $message = trans('messages.success.added', ['type' => $request->get('name')]); | ||||
|         } | ||||
|  | ||||
|         setting()->set('offline-payments.methods', json_encode($methods)); | ||||
| @@ -95,7 +96,7 @@ class Settings extends Controller | ||||
|     { | ||||
|         $data = []; | ||||
|  | ||||
|         $code = $request['code']; | ||||
|         $code = $request->get('code'); | ||||
|  | ||||
|         $methods = json_decode(setting('offline-payments.methods'), true); | ||||
|  | ||||
| @@ -132,7 +133,7 @@ class Settings extends Controller | ||||
|      */ | ||||
|     public function destroy(DRequest $request) | ||||
|     { | ||||
|         $code = $request['code']; | ||||
|         $code = $request->get('code'); | ||||
|  | ||||
|         $methods = json_decode(setting('offline-payments.methods'), true); | ||||
|  | ||||
| @@ -156,7 +157,8 @@ class Settings extends Controller | ||||
|  | ||||
|         $message = trans('messages.success.deleted', ['type' => $remove['name']]); | ||||
|  | ||||
|         flash($message)->success(); | ||||
|         // because it show nofitication. | ||||
|         //flash($message)->success(); | ||||
|  | ||||
|         return response()->json([ | ||||
|             'errors' => false, | ||||
|   | ||||
| @@ -12,6 +12,11 @@ import Global from './../../../../../resources/assets/js/mixins/global'; | ||||
|  | ||||
| import Form from './../../../../../resources/assets/js/plugins/form'; | ||||
|  | ||||
| import DashboardPlugin from './../../../../../resources/assets/js/plugins/dashboard-plugin'; | ||||
|  | ||||
| // plugin setup | ||||
| Vue.use(DashboardPlugin); | ||||
|  | ||||
| const app = new Vue({ | ||||
|     el: '#app', | ||||
|  | ||||
| @@ -21,15 +26,7 @@ const app = new Vue({ | ||||
|  | ||||
|     data() { | ||||
|         return { | ||||
|             form: new Form('offline-payments'), | ||||
|             confirm: { | ||||
|                 code: '', | ||||
|                 title: '', | ||||
|                 message: '', | ||||
|                 button_cancel: '', | ||||
|                 button_delete: '', | ||||
|                 show: false | ||||
|             }, | ||||
|             form: new Form('offline-payment'), | ||||
|         } | ||||
|     }, | ||||
|  | ||||
| @@ -58,46 +55,72 @@ const app = new Vue({ | ||||
|  | ||||
|         // Actions > Delete | ||||
|         confirmDelete(code, title, message, button_cancel, button_delete) { | ||||
|             this.confirm.code = code; | ||||
|             this.confirm.title = title; | ||||
|             this.confirm.message = message; | ||||
|             this.confirm.button_cancel = button_cancel; | ||||
|             this.confirm.button_delete = button_delete; | ||||
|             this.confirm.show = true; | ||||
|         }, | ||||
|             let confirm = { | ||||
|                 code: code, | ||||
|                 url: url, | ||||
|                 title: title, | ||||
|                 message: message, | ||||
|                 button_cancel: button_cancel, | ||||
|                 button_delete: button_delete, | ||||
|                 show: true | ||||
|             }; | ||||
|  | ||||
|         cancelDelete() { | ||||
|             this.confirm.code = ''; | ||||
|             this.confirm.title = ''; | ||||
|             this.confirm.message = ''; | ||||
|             this.confirm.show = false; | ||||
|         }, | ||||
|             this.component = Vue.component('add-new-component', (resolve, reject) => { | ||||
|                 resolve({ | ||||
|                     template : '<div id="dynamic-component"><akaunting-modal v-if="confirm.show" :show="confirm.show" :title="confirm.title" :message="confirm.message" :button_cancel="confirm.button_cancel" :button_delete="confirm.button_delete" @confirm="onDelete" @cancel="cancelDelete"></akaunting-modal></div>', | ||||
|  | ||||
|         onDelete() { | ||||
|             axios({ | ||||
|                 method: 'DELETE', | ||||
|                 url: 'settings/delete', | ||||
|                 data: { | ||||
|                     code: this.confirm.code | ||||
|                 } | ||||
|             }) | ||||
|             .then(response => { | ||||
|                 if (response.data.success) { | ||||
|                     if (response.data.redirect) { | ||||
|                         window.location.href = response.data.redirect; | ||||
|                     mixins: [ | ||||
|                         Global | ||||
|                     ], | ||||
|  | ||||
|                     data: function () { | ||||
|                         return { | ||||
|                             confirm: confirm, | ||||
|                         } | ||||
|                     }, | ||||
|  | ||||
|                     methods: { | ||||
|                         // Delete action post | ||||
|                        async onDelete() { | ||||
|                             let promise = Promise.resolve(axios({ | ||||
|                                 method: 'DELETE', | ||||
|                                 url: 'settings/delete', | ||||
|                                 data: { | ||||
|                                     code: this.confirm.code | ||||
|                                 } | ||||
|                             })); | ||||
|  | ||||
|                             promise.then(response => { | ||||
|                                 var type = (response.data.success) ? 'success' : 'warning'; | ||||
|  | ||||
|                                 if (response.data.success) { | ||||
|                                     if (response.data.redirect) { | ||||
|                                         //window.location.href = response.data.redirect; | ||||
|                                     } | ||||
|                  | ||||
|                                     document.getElementById('method-' + this.confirm.code).remove(); | ||||
|  | ||||
|                                     this.confirm.show = false; | ||||
|                                 } | ||||
|  | ||||
|                                 this.$notify({ | ||||
|                                     message: response.data.message, | ||||
|                                     timeout: 5000, | ||||
|                                     icon: 'fas fa-bell', | ||||
|                                     type | ||||
|                                 }); | ||||
|                             }) | ||||
|                             .catch(error => { | ||||
|                                 this.success = false; | ||||
|                             }); | ||||
|                         }, | ||||
|  | ||||
|                         // Close modal empty default value | ||||
|                         cancelDelete() { | ||||
|                             this.confirm.show = false; | ||||
|                         }, | ||||
|                     } | ||||
|  | ||||
|                     document.getElementById('method-' + this.confirm.code).remove(); | ||||
|  | ||||
|                     this.confirm.code = ''; | ||||
|                     this.confirm.title = ''; | ||||
|                     this.confirm.message = ''; | ||||
|  | ||||
|                     this.confirm.show = false; | ||||
|                 } | ||||
|             }) | ||||
|             .catch(error => { | ||||
|                 this.success = false; | ||||
|                 }) | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -11,7 +11,7 @@ | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::open([ | ||||
|                     'id' => 'offline-payments', | ||||
|                     'id' => 'offline-payment', | ||||
|                     'route' => 'offline-payments.settings.update', | ||||
|                     '@submit.prevent' => 'onSubmit', | ||||
|                     '@keydown' => 'form.errors.clear($event.target.name)', | ||||
| @@ -106,17 +106,6 @@ | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <akaunting-modal | ||||
|         :show="confirm.show" | ||||
|         :title="confirm.title" | ||||
|         :message="confirm.message" | ||||
|         :button_cancel="confirm.button_cancel" | ||||
|         :button_delete="confirm.button_delete" | ||||
|         v-if='confirm.show' | ||||
|         @confirm='onDelete' | ||||
|         @cancel="cancelDelete"> | ||||
|     </akaunting-modal> | ||||
| @endsection | ||||
|  | ||||
| @push('scripts_start') | ||||
|   | ||||
| @@ -1,15 +0,0 @@ | ||||
| { | ||||
|     "name": "akaunting/offlinepayment", | ||||
|     "description": "", | ||||
|     "authors": [ | ||||
|         { | ||||
|             "name": "Akaunting", | ||||
|             "email": "info@akaunting.com" | ||||
|         } | ||||
|     ], | ||||
|     "autoload": { | ||||
|         "psr-4": { | ||||
|             "Modules\\OfflinePayment\\": "" | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										14111
									
								
								modules/OfflinePayments/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										14111
									
								
								modules/OfflinePayments/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user