added fast edit group ux feature

added persian translate
added some comments to code
master
A1Gard 2 days ago
parent d1ef32bb79
commit 59b3405350

@ -34,6 +34,8 @@ class PostController extends XController
['title' => "Detail", 'class' => 'btn-outline-light', 'icon' => 'ri-eye-line'], ['title' => "Detail", 'class' => 'btn-outline-light', 'icon' => 'ri-eye-line'],
'destroy' => 'destroy' =>
['title' => "Remove", 'class' => 'btn-outline-danger delete-confirm', 'icon' => 'ri-close-line'], ['title' => "Remove", 'class' => 'btn-outline-danger delete-confirm', 'icon' => 'ri-close-line'],
'group' =>
['title' => "Edit group", 'class' => 'btn-outline-light edit-group-btn', 'icon' => 'ri-list-check-3'],
]; ];
@ -164,4 +166,33 @@ class PostController extends XController
return parent::restoreing(Post::withTrashed()->where('id', $item)->first()); return parent::restoreing(Post::withTrashed()->where('id', $item)->first());
} }
/*restore**/ /*restore**/
/**
* @param $id Post's id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\View\View
*/
public function groupEdit($id)
{
$post = Post::find($id);
$groups = Group::all(['id', 'name', 'parent_id']);
return view('admin.posts.group-edit', compact('post', 'groups'));
}
/**
* @param Post $item
* @param Request $request
* @return array|\Illuminate\Http\RedirectResponse
*/
public function groupSave(Post $item, Request $request)
{
$item->groups()->sync($request->input('cat'));
logAdmin(__METHOD__, __CLASS__, $item->id);
if ($request->ajax()) {
return ['OK' => true, 'message' => __('Groups saved successfully')];
} else {
return redirect()->back()->with(['message' => __('Groups saved successfully')]);
}
}
} }

@ -226,6 +226,11 @@ class ProductController extends XController
return view('admin.products.category-edit', compact('product', 'cats')); return view('admin.products.category-edit', compact('product', 'cats'));
} }
/**
* @param Product $item
* @param Request $request
* @return array|\Illuminate\Http\RedirectResponse
*/
public function categorySave(Product $item, Request $request) public function categorySave(Product $item, Request $request)
{ {
$item->categories()->sync($request->input('cat')); $item->categories()->sync($request->input('cat'));

@ -10,6 +10,17 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
}); });
document.querySelectorAll('.edit-group-btn')?.forEach(function (el) {
el.setAttribute('href', '#group-category');
el.addEventListener('click', function (e) {
e.preventDefault();
let id = this.closest('tr').querySelector('input.chkbox').getAttribute('value');
const url = document.querySelector('#group-edit-url').value + id;
document.querySelector('#iframe-modal iframe').setAttribute('src', url);
document.querySelector('#iframe-modal').style.display = 'block';
});
});
document.querySelector('#iframe-modal')?.addEventListener('click', function (e) { document.querySelector('#iframe-modal')?.addEventListener('click', function (e) {
if (e.target == this) { if (e.target == this) {

@ -118,6 +118,7 @@
"Catalog": "کاتالوگ", "Catalog": "کاتالوگ",
"Categories": "دسته‌ها", "Categories": "دسته‌ها",
"Categories list": "فهرست دسته‌ها", "Categories list": "فهرست دسته‌ها",
"Categories saved successfully": "دسته ها با موفقیت به روز شدند",
"Category": "دسته", "Category": "دسته",
"Category name": "نام دسته", "Category name": "نام دسته",
"Category slug": "نامک دسته", "Category slug": "نامک دسته",
@ -265,6 +266,7 @@
"Group slug": "نامک سرفصل", "Group slug": "نامک سرفصل",
"Groups": "سرفصل‌ها", "Groups": "سرفصل‌ها",
"Groups list": "فهرست سرفصل‌ها", "Groups list": "فهرست سرفصل‌ها",
"Groups saved successfully": "سرفصل ها با موفقیت به روز شدند",
"Guest": "میهمان", "Guest": "میهمان",
"GuestLogs list": "فهرست لاگ میهمان ها", "GuestLogs list": "فهرست لاگ میهمان ها",
"Height": "قد", "Height": "قد",
@ -320,6 +322,7 @@
"Latest products": "واپسین محصولات", "Latest products": "واپسین محصولات",
"Latitude": "عرض جغرافیایی", "Latitude": "عرض جغرافیایی",
"Leave model ID empty to apply all items": "اگر قصد دارید ارزیابی بر روی تمام موارد مدل اعمال شود آن‌را خالی رها کنید", "Leave model ID empty to apply all items": "اگر قصد دارید ارزیابی بر روی تمام موارد مدل اعمال شود آن‌را خالی رها کنید",
"Like": "پسند",
"Link": "پیوند", "Link": "پیوند",
"Login": "ورود", "Login": "ورود",
"Logout": "خروج", "Logout": "خروج",

@ -0,0 +1,27 @@
@include('components.panel-header')
<div id="panel-preloader">
<div class="loader"></div>
</div>
<input type="hidden" id="panel-dir" @if(langIsRTL(config('app.locale'))) value="rtl" @else value="ltr" @endif>
<form action="{{route('admin.post.group-save',$post->slug)}}" method="post" id="ajax-sync-form">
@csrf
<div class="container pt-4" >
@include('components.err')
<h5>
{{__("Groups")}} [{{$post->title}}]
</h5>
<ul class="nested-ul">
{!!showCatNestedControl($groups,old('cat',isset($post)?$post->groups()->pluck('id')->toArray():[]))!!}
</ul>
</div>
<button class="action-btn circle-btn"
data-bs-toggle="tooltip"
data-bs-placement="top"
data-bs-custom-class="custom-tooltip"
data-bs-title="{{__("Save")}}"
id="categories-save-btn"
>
<i class="ri-save-2-line"></i>
</button>
</form>
@include('components.panel-footer')

@ -8,6 +8,12 @@
{{__("Posts list")}} - {{__("Posts list")}} -
@endsection @endsection
@section('filter') @section('filter')
<input type="hidden" id="group-edit-url" value="{{route('admin.post.group-edit','')}}/">
<div id="iframe-modal">
<div class="container">
<iframe href="#"></iframe>
</div>
</div>
{{-- Other filters --}} {{-- Other filters --}}
@endsection @endsection
@section('bulk') @section('bulk')

@ -182,6 +182,8 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::get('restore/{item}', [\App\Http\Controllers\Admin\PostController::class, 'restore'])->name('restore'); Route::get('restore/{item}', [\App\Http\Controllers\Admin\PostController::class, 'restore'])->name('restore');
Route::post('bulk', [\App\Http\Controllers\Admin\PostController::class, "bulk"])->name('bulk'); Route::post('bulk', [\App\Http\Controllers\Admin\PostController::class, "bulk"])->name('bulk');
Route::get('trashed', [\App\Http\Controllers\Admin\PostController::class, "trashed"])->name('trashed'); Route::get('trashed', [\App\Http\Controllers\Admin\PostController::class, "trashed"])->name('trashed');
Route::get('group/edit/{id}', [\App\Http\Controllers\Admin\PostController::class, 'groupEdit'])->name('group-edit');
Route::post('group/save/{item}', [\App\Http\Controllers\Admin\PostController::class, 'groupSave'])->name('group-save');
}); });
Route::prefix('attachments')->name('attachment.')->group( Route::prefix('attachments')->name('attachment.')->group(
function () { function () {

Loading…
Cancel
Save