Some Change and Fix

Fix upgrade button & Fix Blacklist Check & Change how users search on the blacklist
This commit is contained in:
SahrulGnwn 2022-08-12 18:42:24 +07:00
parent 09138c17c7
commit ffb31ac0ad
4 changed files with 80 additions and 15 deletions

View file

@ -117,9 +117,7 @@ class TicketsController extends Controller
}
public function blacklist() {
$users = User::paginate();
$ticketcategories = TicketCategory::all();
return view("moderator.ticket.blacklist", compact("users", "ticketcategories"));
return view("moderator.ticket.blacklist");
}
public function blacklistAdd(Request $request) {

View file

@ -31,7 +31,7 @@ class TicketsController extends Controller
public function create() {
#check in blacklist
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
if($check->status == "True"){
if($check && $check->status == "True"){
return redirect()->route('ticket.index')->with('error', __("You can't make a ticket because you're on the blacklist for a reason: '" . $check->reason . "', please contact the administrator"));
}
$ticketcategories = TicketCategory::all();
@ -73,7 +73,7 @@ class TicketsController extends Controller
public function reply(Request $request) {
#check in blacklist
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
if($check->status == "True"){
if($check && $check->status == "True"){
return redirect()->route('ticket.index')->with('error', __("You can't reply a ticket because you're on the blacklist for a reason: '" . $check->reason . "', please contact the administrator"));
}
$this->validate($request, array("ticketcomment" => "required"));

View file

@ -69,9 +69,6 @@
</label>
<select id="user_id" style="width:100%" class="custom-select" name="user_id" required
autocomplete="off" @error('user_id') is-invalid @enderror>
@foreach ($users as $user)
<option value="{{$user->id}}" >{{ $user->name }}</option>
@endforeach
</select>
</div>
<div class="form-group ">
@ -112,10 +109,73 @@
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
$('[data-toggle="popover"]').popover();
$('.custom-select').select2();
<script type="application/javascript">
function initUserIdSelect(data) {
function escapeHtml(str) {
var div = document.createElement('div');
div.appendChild(document.createTextNode(str));
return div.innerHTML;
}
$('#user_id').select2({
ajax: {
url: '/admin/users.json',
dataType: 'json',
delay: 250,
data: function (params) {
return {
filter: { email: params.term },
page: params.page,
};
},
processResults: function (data, params) {
return { results: data };
},
cache: true,
},
data: data,
escapeMarkup: function (markup) { return markup; },
minimumInputLength: 2,
templateResult: function (data) {
if (data.loading) return escapeHtml(data.text);
return '<div class="user-block"> \
<img class="img-circle img-bordered-xs" src="' + escapeHtml(data.avatarUrl) + '?s=120" alt="User Image"> \
<span class="username"> \
<a href="#">' + escapeHtml(data.name) +'</a> \
</span> \
<span class="description"><strong>' + escapeHtml(data.email) + '</strong> - ' + escapeHtml(data.username) + '</span> \
</div>';
},
templateSelection: function (data) {
return '<div> \
<span> \
<img class="img-rounded img-bordered-xs" src="' + escapeHtml(data.avatarUrl) + '?s=120" style="height:28px;margin-top:-4px;" alt="User Image"> \
</span> \
<span style="padding-left:5px;"> \
' + escapeHtml(data.name) + ' (<strong>' + escapeHtml(data.email) + '</strong>) \
</span> \
</div>';
}
});
}
$(document).ready(function() {
@if (old('user_id'))
$.ajax({
url: '/admin/users.json?user_id={{ old('user_id') }}',
dataType: 'json',
}).then(function (data) {
initUserIdSelect([ data ]);
});
@else
initUserIdSelect();
@endif
});
</script>
@endsection

View file

@ -251,7 +251,7 @@
<br>
<br>
<form action="{{ route('servers.upgrade', ['server' => $server->id]) }}" method="POST">
<form action="{{ route('servers.upgrade', ['server' => $server->id]) }}" method="POST" class="upgrade-form">
@csrf
<select name="product_upgrade" id="product_upgrade" class="form-input2 form-control">
<option value="">{{__("Select the product")}}</option>
@ -265,7 +265,7 @@
<br> {{_("Server will be automatically restarted once upgraded")}}
</div>
<div class="modal-footer card-body">
<button onclick="this.disabled='true';" type="submit" class="btn btn-primary" style="width: 100%"><strong>{{__("Change Product")}}</strong></button>
<button type="submit" class="btn btn-primary upgrade-once" style="width: 100%"><strong>{{__("Change Product")}}</strong></button>
</div>
</form>
</div>
@ -312,6 +312,13 @@
</div>
</section>
<!-- END CONTENT -->
<script type="text/javascript">
$(".upgrade-form").submit(function (e) {
$(".upgrade-once").attr("disabled", true);
return true;
})
</script>
@endsection