feat: add module management view with status, permission, and slug configuration support
This commit is contained in:
@@ -1,33 +1,8 @@
|
||||
@extends('admin.master')
|
||||
@section("title","Modules")
|
||||
@section("desc","Bu sayfada içerik türlerini yönetebilirsiniz")
|
||||
@section("title", "Modules")
|
||||
@section("desc", "Bu sayfada içerik türlerini yönetebilirsiniz")
|
||||
@section('content')
|
||||
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<div class="content">
|
||||
<div class="block">
|
||||
<div class="block-header block-header-default">
|
||||
<h3 class="block-title">{{__('Modules')}}</h3>
|
||||
<div class="block-options">
|
||||
<div class="block-options-item">
|
||||
<a href="{{ url('admin/action/add/types') }}" class="btn btn-default"><i class="fa fa-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="block-content">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover">
|
||||
<tr>
|
||||
<th>{{e2("User No")}}</th>
|
||||
<th>{{e2("Level")}}</th>
|
||||
<th>{{e2("Full Control")}}</th>
|
||||
<th>{{e2("Write")}}</th>
|
||||
<th>{{e2("Read")}}</th>
|
||||
<th>{{e2("Modify")}}</th>
|
||||
</tr>
|
||||
<?php
|
||||
// Specific Permissions List
|
||||
$specificPermissionsList = [
|
||||
@@ -55,196 +30,180 @@
|
||||
'MTO Sync Permission' => 'mto_sync_permission',
|
||||
],
|
||||
];
|
||||
|
||||
$levels = levels();
|
||||
foreach($levels AS $level => $detail) {
|
||||
|
||||
?>
|
||||
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<div class="content">
|
||||
<div class="block block-rounded">
|
||||
<div class="block-header block-header-default p-0">
|
||||
<ul class="nav nav-tabs nav-tabs-block" data-toggle="tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#btabs-modules">
|
||||
<i class="si si-layers mr-1"></i> {{__('Modules')}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#btabs-levels">
|
||||
<i class="si si-users mr-1"></i> {{__('Levels')}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="block-options mr-3">
|
||||
<a href="{{ url('admin/action/add/types') }}" class="btn btn-sm btn-alt-success">
|
||||
<i class="fa fa-plus mr-1"></i> {{__('New Module')}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block-content tab-content overflow-hidden">
|
||||
<!-- Modules Tab -->
|
||||
<div class="tab-pane active" id="btabs-modules" role="tabpanel">
|
||||
<div class="row mb-4">
|
||||
<div class="col-12">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text bg-white border-right-0">
|
||||
<i class="si si-magnifier"></i>
|
||||
</span>
|
||||
</div>
|
||||
<input type="text" name="search" id="search" placeholder="{{e2("Search Module...")}}"
|
||||
class="form-control border-left-0 pl-0 bg-white">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover table-vcenter table-sm custom-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<td>{{$detail[0]}}</td>
|
||||
<td>{{$level}}</td>
|
||||
<td>{{$detail[1]==1 ? "✅" : "❌"}}</td>
|
||||
<td>{{$detail[2]==1 ? "✅" : "❌"}}</td>
|
||||
<td>{{$detail[3]==1 ? "✅" : "❌"}}</td>
|
||||
<td>{{$detail[4]==1 ? "✅" : "❌"}}</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("#search").on("keyup", function() {
|
||||
var value = $(this).val().toLowerCase();
|
||||
$("#types tr").filter(function() {
|
||||
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<input type="text" name="search" id="search" placeholder="{{e2("Search Module...")}}" class="form-control">
|
||||
<table class="table table-striped table-hover table-bordered table-vcenter table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{__("Enabled")}}</th>
|
||||
<th>{{__("Mobile")}}</th>
|
||||
<th>{{__("Icon")}}</th>
|
||||
<th>{{__("Icon Name")}}</th>
|
||||
<th>{{__("Title")}}</th>
|
||||
<th>{{__("Parent")}}</th>
|
||||
<th>{{__("ID")}}</th>
|
||||
<th>{{__("Order")}}</th>
|
||||
<th>{{__("Full Control")}} </th>
|
||||
<th>{{__("Write")}} </th>
|
||||
<th>{{__("Read")}} </th>
|
||||
<th>{{__("Modify")}} </th>
|
||||
<th class="text-center" style="width: 100px;"><i class="fa fa-cog"></i></th>
|
||||
<th class="text-center" style="width: 70px;">{{__("Status")}}</th>
|
||||
<th class="text-center" style="width: 70px;">{{__("Mobile")}}</th>
|
||||
<th class="text-center" style="width: 50px;">{{__("Icon")}}</th>
|
||||
<th>{{__("Module Info")}}</th>
|
||||
<th>{{__("Slug / Parent")}}</th>
|
||||
<th class="text-center" style="width: 80px;">{{__("Order")}}</th>
|
||||
<th>{{__("Permissions")}}</th>
|
||||
<th class="text-center" style="width: 120px;"><i class="fa fa-cog"></i></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="types">
|
||||
@foreach($types AS $a)
|
||||
@foreach($types as $a)
|
||||
<tr>
|
||||
<td>
|
||||
<select name="enabled" table="types" data-id="{{$a->id}}" class="form-control edit">
|
||||
<option value="1" @if($a->enabled) selected @endif>✅</option>
|
||||
<option value="0" @if(!$a->enabled) selected @endif>🟥</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select name="is_mobile" table="types" data-id="{{$a->id}}" class="form-control edit">
|
||||
<option value="1" @if($a->is_mobile) selected @endif>✅</option>
|
||||
<option value="0" @if(!$a->is_mobile) selected @endif>🟥</option>
|
||||
<td class="text-center">
|
||||
<select name="enabled" table="types" data-id="{{$a->id}}"
|
||||
class="form-control form-control-sm edit custom-select-status">
|
||||
<option value="1" @if($a->enabled) selected @endif>✅ Active</option>
|
||||
<option value="0" @if(!$a->enabled) selected @endif>🟥 Passive</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<img src="{{url("assets/icons/". $a->icon .".png")}}" width="24" alt="">
|
||||
<select name="is_mobile" table="types" data-id="{{$a->id}}"
|
||||
class="form-control form-control-sm edit custom-select-status">
|
||||
<option value="1" @if($a->is_mobile) selected @endif>✅ Yes</option>
|
||||
<option value="0" @if(!$a->is_mobile) selected @endif>🟥 No</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="icon-wrapper bg-light p-1 rounded">
|
||||
<img src="{{url("assets/icons/" . $a->icon . ".png")}}" width="24" alt=""
|
||||
class="img-fluid">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<input type="text" name="icon" value="{{$a->icon}}" table="types"data-id="{{$a->id}}" class="icon form-control edit" /></td>
|
||||
<td><input type="text" name="title" value="{{$a->title}}" table="types"data-id="{{$a->id}}" class="title{{$a->id}} form-control edit" /></td>
|
||||
<td><input type="text" name="kid" value="{{$a->kid}}" table="types"data-id="{{$a->id}}" class="title{{$a->id}} form-control edit" /></td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<div class="d-flex flex-column">
|
||||
<input type="text" name="title" value="{{$a->title}}" table="types"
|
||||
data-id="{{$a->id}}"
|
||||
class="form-control form-control-sm edit mb-1 font-w600 title{{$a->id}}"
|
||||
placeholder="Title" />
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<div class="btn btn-default" onclick="$.get('{{url('admin-ajax/slug?title='.$a->breadcrumb)}}'+$('.title{{$a->id}}').val(),function(d){
|
||||
$('.slug{{$a->id}}').val(d).blur();
|
||||
})"><i class="si si-refresh"></i></div>
|
||||
<span
|
||||
class="input-group-text border-right-0 bg-transparent text-muted"><i
|
||||
class="fa fa-image"></i></span>
|
||||
</div>
|
||||
<input type="text" name="slug" value="{{$a->slug}}" table="types"data-id="{{$a->id}}" class="slug{{$a->id}} form-control edit" />
|
||||
<input type="text" name="icon" value="{{$a->icon}}" table="types"
|
||||
data-id="{{$a->id}}"
|
||||
class="form-control form-control-sm edit border-left-0"
|
||||
placeholder="Icon name" />
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td><input type="number" name="s" value="{{$a->s}}" table="types"data-id="{{$a->id}}" class="title{{$a->id}} form-control edit" /></td>
|
||||
|
||||
<td>
|
||||
<div class="level-input">
|
||||
<div class="level-tags">
|
||||
@foreach(explode(',', $a->full_control) as $level)
|
||||
@if($level)
|
||||
<span class="badge badge-pill badge-{{ levelColor($level) }}">{{ intval($level) }}</span>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
<button class="btn btn-sm btn-light edit-levels"
|
||||
data-target="full_control_{{ $a->id }}"
|
||||
data-type="full_control">
|
||||
<i class="fa fa-cog"></i>
|
||||
</button>
|
||||
<input type="hidden"
|
||||
name="full_control"
|
||||
table="types"
|
||||
data-id="{{ $a->id }}"
|
||||
value="{{ $a->full_control }}"
|
||||
class="edit"
|
||||
id="full_control_{{ $a->id }}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="level-input">
|
||||
<div class="level-tags">
|
||||
@foreach(explode(',', $a->write) as $level)
|
||||
@if($level)
|
||||
<span class="badge badge-pill badge-{{ levelColor($level) }}">{{ $level }}</span>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
<button class="btn btn-sm btn-light edit-levels"
|
||||
data-target="write_{{ $a->id }}"
|
||||
data-type="write">
|
||||
<i class="fa fa-cog"></i>
|
||||
<div class="d-flex flex-column">
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-alt-primary"
|
||||
onclick="$.get('{{url('admin-ajax/slug?title=')}}'+$('.title{{$a->id}}').val(),function(d){ $('.slug{{$a->id}}').val(d).blur(); })">
|
||||
<i class="si si-refresh"></i>
|
||||
</button>
|
||||
<input type="hidden"
|
||||
name="write"
|
||||
table="types"
|
||||
data-id="{{ $a->id }}"
|
||||
value="{{ $a->write }}"
|
||||
class="edit"
|
||||
id="write_{{ $a->id }}">
|
||||
</div>
|
||||
<input type="text" name="slug" value="{{$a->slug}}" table="types"
|
||||
data-id="{{$a->id}}" class="slug{{$a->id}} form-control edit"
|
||||
placeholder="Slug" />
|
||||
</div>
|
||||
<input type="text" name="kid" value="{{$a->kid}}" table="types"
|
||||
data-id="{{$a->id}}" class="form-control form-control-sm edit"
|
||||
placeholder="Parent ID" />
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input type="number" name="s" value="{{$a->s}}" table="types" data-id="{{$a->id}}"
|
||||
class="form-control form-control-sm edit text-center" />
|
||||
</td>
|
||||
<td>
|
||||
<div class="level-input">
|
||||
<div class="permissions-container d-flex flex-wrap gap-2">
|
||||
@php
|
||||
$permTypes = [
|
||||
['key' => 'full_control', 'label' => 'Full', 'icon' => 'fa-lock'],
|
||||
['key' => 'write', 'label' => 'Write', 'icon' => 'fa-pencil-alt'],
|
||||
['key' => 'read', 'label' => 'Read', 'icon' => 'fa-eye'],
|
||||
['key' => 'modify', 'label' => 'Mod', 'icon' => 'fa-edit'],
|
||||
];
|
||||
@endphp
|
||||
@foreach($permTypes as $pt)
|
||||
<div class="perm-item mb-2 mr-2">
|
||||
<small class="text-muted d-block mb-1 font-w600"><i
|
||||
class="fa {{ $pt['icon'] }} mr-1"></i>{{ $pt['label'] }}</small>
|
||||
<div class="level-input mini">
|
||||
<div class="level-tags">
|
||||
@foreach(explode(',', $a->read) as $level)
|
||||
@if($level)
|
||||
<span class="badge badge-pill badge-{{ levelColor($level) }}">{{ $level }}</span>
|
||||
@foreach(explode(',', $a->{$pt['key']}) as $level)
|
||||
@if($level !== '')
|
||||
<span
|
||||
class="badge badge-pill badge-{{ levelColor(trim($level)) }}">{{ trim($level) }}</span>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
<button class="btn btn-sm btn-light edit-levels"
|
||||
data-target="read_{{ $a->id }}"
|
||||
data-type="read">
|
||||
<button class="btn btn-xs btn-alt-primary edit-levels"
|
||||
data-target="{{ $pt['key'] }}_{{ $a->id }}"
|
||||
data-type="{{ $pt['key'] }}">
|
||||
<i class="fa fa-cog"></i>
|
||||
</button>
|
||||
<input type="hidden"
|
||||
name="read"
|
||||
table="types"
|
||||
data-id="{{ $a->id }}"
|
||||
value="{{ $a->read }}"
|
||||
class="edit"
|
||||
id="read_{{ $a->id }}">
|
||||
<input type="hidden" name="{{ $pt['key'] }}" table="types"
|
||||
data-id="{{ $a->id }}" value="{{ $a->{$pt['key']} }}" class="edit"
|
||||
id="{{ $pt['key'] }}_{{ $a->id }}">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="level-input">
|
||||
<div class="level-tags">
|
||||
@foreach(explode(',', $a->modify) as $level)
|
||||
@if($level)
|
||||
<span class="badge badge-pill badge-{{ levelColor($level) }}">{{ $level }}</span>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
<button class="btn btn-sm btn-light edit-levels"
|
||||
data-target="modify_{{ $a->id }}"
|
||||
data-type="modify">
|
||||
<i class="fa fa-cog"></i>
|
||||
</button>
|
||||
<input type="hidden"
|
||||
name="modify"
|
||||
table="types"
|
||||
data-id="{{ $a->id }}"
|
||||
value="{{ $a->modify }}"
|
||||
class="edit"
|
||||
id="modify_{{ $a->id }}">
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<div class="btn-group">
|
||||
<a href="{{ url('admin/types/'. $a->slug) }}" class="btn btn-sm btn-secondary">
|
||||
<a href="{{ url('admin/types/' . $a->slug) }}" class="btn btn-sm btn-alt-primary"
|
||||
title="Go to Link">
|
||||
<i class="fa fa-link"></i>
|
||||
</a>
|
||||
<a href="{{ url('admin/types/'. $a->id.'/delete') }}" class="btn btn-sm btn-secondary delete-confirm">
|
||||
<i class="fa fa-times"></i>
|
||||
</a>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-info open-specific-permissions"
|
||||
data-id="{{ $a->id }}"
|
||||
data-title="{{ $a->title }}"
|
||||
<button type="button" class="btn btn-sm btn-alt-info open-specific-permissions"
|
||||
data-id="{{ $a->id }}" data-title="{{ $a->title }}"
|
||||
data-slug="{{ $a->slug }}"
|
||||
data-permissions='{{ setting("type_{$a->id}_specific_permissions") }}'
|
||||
data-mobile-columns='{{ setting("type_{$a->id}_mobile_columns") }}'>
|
||||
data-mobile-columns='{{ setting("type_{$a->id}_mobile_columns") }}'
|
||||
title="Specific Permissions">
|
||||
<i class="fa fa-cogs"></i>
|
||||
</button>
|
||||
<a href="{{ url('admin/types/' . $a->id . '/delete') }}"
|
||||
class="btn btn-sm btn-alt-danger delete-confirm" title="Delete">
|
||||
<i class="fa fa-times"></i>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td style="display: none;" class="module-data">
|
||||
@@ -259,10 +218,67 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="levelModal" tabindex="-1" role="dialog">
|
||||
<!-- Levels Tab -->
|
||||
<div class="tab-pane" id="btabs-levels" role="tabpanel">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover table-vcenter">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th class="text-center" style="width: 100px;">{{e2("Level ID")}}</th>
|
||||
<th>{{e2("Level Name")}}</th>
|
||||
<th class="text-center">{{e2("Full Control")}}</th>
|
||||
<th class="text-center">{{e2("Write")}}</th>
|
||||
<th class="text-center">{{e2("Read")}}</th>
|
||||
<th class="text-center">{{e2("Modify")}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php $levels = levels(); @endphp
|
||||
@foreach($levels as $level => $detail)
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<span class="badge badge-pill badge-secondary p-2">{{$detail[0]}}</span>
|
||||
</td>
|
||||
<td class="font-w600 text-primary">{{$level}}</td>
|
||||
<td class="text-center">
|
||||
@if($detail[1] == 1) <i class="fa fa-check-circle text-success fa-lg"></i> @else <i
|
||||
class="fa fa-times-circle text-danger-light fa-lg"></i> @endif
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if($detail[2] == 1) <i class="fa fa-check-circle text-success fa-lg"></i> @else <i
|
||||
class="fa fa-times-circle text-danger-light fa-lg"></i> @endif
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if($detail[3] == 1) <i class="fa fa-check-circle text-success fa-lg"></i> @else <i
|
||||
class="fa fa-times-circle text-danger-light fa-lg"></i> @endif
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if($detail[4] == 1) <i class="fa fa-check-circle text-success fa-lg"></i> @else <i
|
||||
class="fa fa-times-circle text-danger-light fa-lg"></i> @endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#search").on("keyup", function () {
|
||||
var value = $(this).val().toLowerCase();
|
||||
$("#types tr").filter(function () {
|
||||
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="modal fade" id="levelModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -297,12 +313,9 @@
|
||||
<td>{{$level}}</td>
|
||||
<td class="text-center">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox"
|
||||
class="custom-control-input level-checkbox"
|
||||
id="level_{{$detail[0]}}"
|
||||
value="{{$detail[0]}}">
|
||||
<label class="custom-control-label"
|
||||
for="level_{{$detail[0]}}"></label>
|
||||
<input type="checkbox" class="custom-control-input level-checkbox"
|
||||
id="level_{{$detail[0]}}" value="{{$detail[0]}}">
|
||||
<label class="custom-control-label" for="level_{{$detail[0]}}"></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -317,20 +330,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function levelColor(level) {
|
||||
const colors = {1: 'success', 2: 'primary', 3: 'warning', 4: 'danger'};
|
||||
<script>
|
||||
function levelColor(level) {
|
||||
const colors = { 1: 'success', 2: 'primary', 3: 'warning', 4: 'danger' };
|
||||
return colors[level] || 'secondary';
|
||||
}
|
||||
}
|
||||
|
||||
let currentTarget = null;
|
||||
let currentType = null;
|
||||
let currentModuleData = null;
|
||||
let currentTarget = null;
|
||||
let currentType = null;
|
||||
let currentModuleData = null;
|
||||
|
||||
// Level edit button click handler
|
||||
$(document).on('click', '.edit-levels', function(e) {
|
||||
$(document).on('click', '.edit-levels', function (e) {
|
||||
e.preventDefault();
|
||||
currentTarget = $(this).data('target');
|
||||
currentType = $(this).data('type');
|
||||
@@ -369,7 +382,7 @@ let currentModuleData = null;
|
||||
}
|
||||
});
|
||||
|
||||
function getPermissionTitle(type) {
|
||||
function getPermissionTitle(type) {
|
||||
const titles = {
|
||||
'full_control': 'Full Control',
|
||||
'write': 'Write Permission',
|
||||
@@ -377,14 +390,14 @@ function getPermissionTitle(type) {
|
||||
'modify': 'Modify Permission'
|
||||
};
|
||||
return titles[type] || type;
|
||||
}
|
||||
}
|
||||
|
||||
// Save button click handler
|
||||
$('#saveLevels').click(function() {
|
||||
// Save button click handler
|
||||
$('#saveLevels').click(function () {
|
||||
if (!currentTarget) return;
|
||||
|
||||
const selectedLevels = [];
|
||||
$('.level-checkbox:checked').each(function() {
|
||||
$('.level-checkbox:checked').each(function () {
|
||||
selectedLevels.push(parseInt($(this).val()));
|
||||
});
|
||||
|
||||
@@ -404,17 +417,17 @@ $('#saveLevels').click(function() {
|
||||
});
|
||||
|
||||
$('#levelModal').modal('hide');
|
||||
});
|
||||
});
|
||||
|
||||
// AJAX setup
|
||||
$.ajaxSetup({
|
||||
// AJAX setup
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Edit sınıfına sahip elementlerin değişikliklerini izle
|
||||
$(document).on('change', '.edit', function() {
|
||||
// Edit sınıfına sahip elementlerin değişikliklerini izle
|
||||
$(document).on('change', '.edit', function () {
|
||||
$.post('{{url("admin-ajax/input-edit")}}', {
|
||||
table: $(this).attr("table"),
|
||||
value: $(this).val(),
|
||||
@@ -422,62 +435,116 @@ $(document).on('change', '.edit', function() {
|
||||
name: $(this).attr("name"),
|
||||
_token: '{{ csrf_token() }}'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.level-tags {
|
||||
min-height: 38px;
|
||||
padding: 5px;
|
||||
border: 1px solid #eee;
|
||||
margin-bottom: 5px;
|
||||
border-radius: 4px;
|
||||
<style>
|
||||
.custom-table thead th {
|
||||
text-transform: uppercase;
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.05rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.icon-wrapper {
|
||||
transition: transform 0.2s;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.icon-wrapper:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
.level-tags {
|
||||
min-height: 32px;
|
||||
padding: 3px;
|
||||
border: 1px solid #ebf0f5;
|
||||
margin-bottom: 2px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
.level-tags .badge {
|
||||
margin: 2px;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.level-input {
|
||||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
.level-tags .badge {
|
||||
margin: 1px;
|
||||
font-size: 0.7rem;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.level-input {
|
||||
position: relative;
|
||||
width: 120px;
|
||||
}
|
||||
.level-input .edit-levels {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.level-input.mini {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.level-input .edit-levels {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
right: -5px;
|
||||
top: -5px;
|
||||
z-index: 2;
|
||||
padding: 2px 6px;
|
||||
display: none;
|
||||
}
|
||||
.level-input:hover .edit-levels {
|
||||
display: block;
|
||||
}
|
||||
.level-list {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.form-check-label {
|
||||
padding: 1px 5px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.form-check-label .badge {
|
||||
min-width: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
.modal-dialog {
|
||||
max-width: 700px;
|
||||
}
|
||||
.table td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.custom-control {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.level-input:hover .edit-levels {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.custom-select-status {
|
||||
border-radius: 20px;
|
||||
font-size: 0.8rem;
|
||||
height: 28px !important;
|
||||
padding: 0 10px !important;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-top: none;
|
||||
border-radius: 0 0 8px 8px;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.nav-tabs-block {
|
||||
background: #f8fafc;
|
||||
border-radius: 8px 8px 0 0;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.nav-tabs-block .nav-link {
|
||||
border: none;
|
||||
padding: 15px 25px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.nav-tabs-block .nav-link.active {
|
||||
color: #3b82f6;
|
||||
background: #fff;
|
||||
border-bottom: 2px solid #3b82f6;
|
||||
}
|
||||
|
||||
.gap-2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.font-w600 {
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
<!-- Specific Permissions Modal -->
|
||||
@@ -503,7 +570,8 @@ $(document).on('change', '.edit', function() {
|
||||
<ul class="nav nav-tabs nav-tabs-alt" role="tablist">
|
||||
@foreach($specificPermissionsList as $groupName => $perms)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if($loop->first) active @endif" href="#sp-tab-{{Str::slug($groupName)}}" data-toggle="tab">
|
||||
<a class="nav-link @if($loop->first) active @endif"
|
||||
href="#sp-tab-{{Str::slug($groupName)}}" data-toggle="tab">
|
||||
{{$groupName}}
|
||||
</a>
|
||||
</li>
|
||||
@@ -517,7 +585,8 @@ $(document).on('change', '.edit', function() {
|
||||
|
||||
<div class="block-content tab-content">
|
||||
@foreach($specificPermissionsList as $groupName => $perms)
|
||||
<div class="tab-pane @if($loop->first) active @endif" id="sp-tab-{{Str::slug($groupName)}}" role="tabpanel">
|
||||
<div class="tab-pane @if($loop->first) active @endif"
|
||||
id="sp-tab-{{Str::slug($groupName)}}" role="tabpanel">
|
||||
<table class="table table-vcenter table-hover mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -535,14 +604,11 @@ $(document).on('change', '.edit', function() {
|
||||
<!-- Badges will be inserted here via JS -->
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-light edit-levels"
|
||||
data-target="sp_{{$key}}"
|
||||
data-type="{{$label}}">
|
||||
data-target="sp_{{$key}}" data-type="{{$label}}">
|
||||
<i class="fa fa-cog"></i>
|
||||
</button>
|
||||
<input type="hidden"
|
||||
name="permissions[{{$key}}]"
|
||||
id="sp_{{$key}}"
|
||||
class="sp-input">
|
||||
<input type="hidden" name="permissions[{{$key}}]"
|
||||
id="sp_{{$key}}" class="sp-input">
|
||||
</div>
|
||||
<small class="text-muted d-none">{{$key}}</small>
|
||||
</td>
|
||||
@@ -559,8 +625,10 @@ $(document).on('change', '.edit', function() {
|
||||
</div>
|
||||
<div id="mobileColumnsContainer" style="display:none;">
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" id="mcSelectAll">Select All</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="mcDeselectAll">Deselect All</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary"
|
||||
id="mcSelectAll">Select All</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary"
|
||||
id="mcDeselectAll">Deselect All</button>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-vcenter table-hover mb-0">
|
||||
@@ -575,7 +643,8 @@ $(document).on('change', '.edit', function() {
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mobileColumnsEmpty" style="display:none;" class="text-center py-4 text-muted">
|
||||
<div id="mobileColumnsEmpty" style="display:none;"
|
||||
class="text-center py-4 text-muted">
|
||||
<i class="fa fa-exclamation-circle fa-2x"></i>
|
||||
<p class="mt-2">No columns found for this module.</p>
|
||||
</div>
|
||||
@@ -594,9 +663,9 @@ $(document).on('change', '.edit', function() {
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
window.addEventListener('load', function () {
|
||||
// Open Modal
|
||||
$(document).on('click', '.open-specific-permissions', function() {
|
||||
$(document).on('click', '.open-specific-permissions', function () {
|
||||
var id = $(this).data('id');
|
||||
var title = $(this).data('title');
|
||||
var slug = $(this).data('slug');
|
||||
@@ -616,24 +685,24 @@ window.addEventListener('load', function() {
|
||||
if (typeof currentPerms === 'string') {
|
||||
try {
|
||||
currentPerms = JSON.parse(currentPerms);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("JSON parse error", e);
|
||||
currentPerms = {};
|
||||
}
|
||||
}
|
||||
|
||||
$.each(currentPerms, function(key, value) {
|
||||
$.each(currentPerms, function (key, value) {
|
||||
// Set hidden input value
|
||||
var $input = $('input[name="permissions[' + key + ']"]');
|
||||
$input.val(value);
|
||||
|
||||
// Create badges
|
||||
if(value) {
|
||||
if (value) {
|
||||
var levels = value.toString().split(',');
|
||||
var $tagsContainer = $input.closest('.level-input').find('.level-tags');
|
||||
|
||||
levels.forEach(function(level) {
|
||||
if(level.trim() !== '') {
|
||||
levels.forEach(function (level) {
|
||||
if (level.trim() !== '') {
|
||||
$tagsContainer.append(
|
||||
`<span class="badge badge-pill badge-${levelColor(parseInt(level))}">${level}</span>`
|
||||
);
|
||||
@@ -649,7 +718,7 @@ window.addEventListener('load', function() {
|
||||
if (typeof currentMobileColumns === 'string') {
|
||||
try {
|
||||
savedMobileColumns = JSON.parse(currentMobileColumns);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
savedMobileColumns = [];
|
||||
}
|
||||
} else if (Array.isArray(currentMobileColumns)) {
|
||||
@@ -668,7 +737,7 @@ window.addEventListener('load', function() {
|
||||
url: '{{url("admin-ajax/get-module-columns")}}',
|
||||
type: 'GET',
|
||||
data: { slug: slug },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
$('#mobileColumnsLoading').hide();
|
||||
try {
|
||||
var res = typeof response === 'string' ? JSON.parse(response) : response;
|
||||
@@ -680,21 +749,21 @@ window.addEventListener('load', function() {
|
||||
var finalOrder = [];
|
||||
|
||||
// Add saved ones first
|
||||
savedMobileColumns.forEach(function(col) {
|
||||
savedMobileColumns.forEach(function (col) {
|
||||
if (allDbColumns.indexOf(col) !== -1) {
|
||||
finalOrder.push(col);
|
||||
}
|
||||
});
|
||||
|
||||
// Add remaining ones
|
||||
allDbColumns.forEach(function(col) {
|
||||
allDbColumns.forEach(function (col) {
|
||||
if (finalOrder.indexOf(col) === -1) {
|
||||
finalOrder.push(col);
|
||||
}
|
||||
});
|
||||
|
||||
var html = '';
|
||||
finalOrder.forEach(function(col) {
|
||||
finalOrder.forEach(function (col) {
|
||||
var checked = savedMobileColumns.indexOf(col) !== -1 ? 'checked' : '';
|
||||
html += '<tr class="mc-item" data-col="' + col + '">' +
|
||||
'<td class="text-center mc-handle" style="cursor:move;"><i class="fa fa-arrows-alt text-muted"></i></td>' +
|
||||
@@ -714,10 +783,10 @@ window.addEventListener('load', function() {
|
||||
handle: '.mc-handle',
|
||||
axis: 'y',
|
||||
containment: 'parent',
|
||||
helper: function(e, tr) {
|
||||
helper: function (e, tr) {
|
||||
var $originals = tr.children();
|
||||
var $helper = tr.clone();
|
||||
$helper.children().each(function(index) {
|
||||
$helper.children().each(function (index) {
|
||||
$(this).width($originals.eq(index).width());
|
||||
});
|
||||
return $helper;
|
||||
@@ -728,12 +797,12 @@ window.addEventListener('load', function() {
|
||||
} else {
|
||||
$('#mobileColumnsEmpty').show();
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error('Column parse error', e);
|
||||
$('#mobileColumnsEmpty').show();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
$('#mobileColumnsLoading').hide();
|
||||
$('#mobileColumnsEmpty').show();
|
||||
}
|
||||
@@ -743,29 +812,29 @@ window.addEventListener('load', function() {
|
||||
});
|
||||
|
||||
// Select All / Deselect All for Mobile Columns
|
||||
$('#mcSelectAll').click(function() {
|
||||
$('#mcSelectAll').click(function () {
|
||||
$('.mc-checkbox').prop('checked', true);
|
||||
});
|
||||
$('#mcDeselectAll').click(function() {
|
||||
$('#mcDeselectAll').click(function () {
|
||||
$('.mc-checkbox').prop('checked', false);
|
||||
});
|
||||
|
||||
// Save
|
||||
$('#saveSpecificPermissions').click(function() {
|
||||
$('#saveSpecificPermissions').click(function () {
|
||||
var formData = {};
|
||||
|
||||
// Only take filled inputs
|
||||
$('.sp-input').each(function() {
|
||||
$('.sp-input').each(function () {
|
||||
var val = $(this).val();
|
||||
var name = $(this).attr('name').replace('permissions[', '').replace(']', '');
|
||||
if(val && val.trim() !== '') {
|
||||
if (val && val.trim() !== '') {
|
||||
formData[name] = val;
|
||||
}
|
||||
});
|
||||
|
||||
// Collect selected mobile columns in UI order
|
||||
var selectedColumns = [];
|
||||
$('.mc-item').each(function() {
|
||||
$('.mc-item').each(function () {
|
||||
var $item = $(this);
|
||||
var isChecked = $item.find('.mc-checkbox').is(':checked');
|
||||
if (isChecked) {
|
||||
@@ -784,28 +853,28 @@ window.addEventListener('load', function() {
|
||||
mobile_columns: JSON.stringify(selectedColumns),
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
try {
|
||||
var res = typeof response === 'string' ? JSON.parse(response) : response;
|
||||
if(res.status === 'success') {
|
||||
if (res.status === 'success') {
|
||||
$('#specificPermissionsModal').modal('hide');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('Error: ' + (res.message || 'Unknown error'));
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("Response parse error", e);
|
||||
location.reload(); // Assume success if parse fails but request worked
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
alert('An error occurred while saving.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Delete confirmation
|
||||
$(document).on('click', '.delete-confirm', function(e) {
|
||||
$(document).on('click', '.delete-confirm', function (e) {
|
||||
e.preventDefault();
|
||||
var url = $(this).attr('href');
|
||||
|
||||
@@ -824,5 +893,5 @@ window.addEventListener('load', function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user