From 82504300cdf22f9ba6b44ad67ea5607505e667a3 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Sat, 22 Jun 2024 22:34:19 +0330 Subject: [PATCH] fixed ckeditor change bug --- app/Http/Controllers/Admin/ProductController.php | 2 +- resources/js/panel/editor-handle.js | 9 ++++++--- resources/js/panel/product-upload-controller.js | 1 + .../admin/products/sub-pages/product-step1.blade.php | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 9a4ea14..f51586d 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -59,7 +59,7 @@ class ProductController extends XController $product->excerpt = $request->input('excerpt'); $product->stock_status = $request->input('stock_status'); $product->price = $request->input('price',0); - $product->buy_price = $request->input('bye_price',0); + $product->buy_price = $request->input('buy_price',0); if (!$request->has('quantity')) { $product->price = $request->input('price',0); diff --git a/resources/js/panel/editor-handle.js b/resources/js/panel/editor-handle.js index 275db12..3654606 100644 --- a/resources/js/panel/editor-handle.js +++ b/resources/js/panel/editor-handle.js @@ -1,7 +1,8 @@ -document.addEventListener('readystatechange',function () { +window.addEventListener('load',function () { let dirx = 'ltr'; + let editors = {}; document.querySelectorAll('.ckeditorx')?.forEach(function (el) { - CKEDITOR.replace(el.getAttribute('name'), { + editors[el.getAttribute('name')] = CKEDITOR.replace(el.getAttribute('name'), { filebrowserUploadUrl: xupload, filebrowserUploadMethod: 'form', contentsLangDirection: dirx, @@ -10,6 +11,8 @@ document.addEventListener('readystatechange',function () { // WIP: need font and color like website CKEDITOR.addCss('.cke_editable { background-color: #212529; color: white }'); - + editors[el.getAttribute('name')].on('change', function (evt) { + el.value = evt.editor.getData(); + }); }); }); diff --git a/resources/js/panel/product-upload-controller.js b/resources/js/panel/product-upload-controller.js index 0bcf92b..edf4460 100644 --- a/resources/js/panel/product-upload-controller.js +++ b/resources/js/panel/product-upload-controller.js @@ -98,6 +98,7 @@ document.addEventListener('DOMContentLoaded', () => { if (res.data.link !== undefined) { this.setAttribute('action', res.data.link); } + $toast.info(res.data.message); if (document.querySelector('#price-amount').value.trim() !== '') { window.location.reload(); } diff --git a/resources/views/admin/products/sub-pages/product-step1.blade.php b/resources/views/admin/products/sub-pages/product-step1.blade.php index 8616ca9..169afdc 100644 --- a/resources/views/admin/products/sub-pages/product-step1.blade.php +++ b/resources/views/admin/products/sub-pages/product-step1.blade.php @@ -31,7 +31,7 @@ {{__('Base price')}} - @@ -41,14 +41,14 @@ {{__('Purchase price')}} -
{{-- data-url="{{route('props.list','')}}/"--}}