Merge branch 'master' of https://github.com/Geriano/laravel-inertia-vite-template
This commit is contained in:
105
app/Http/Controllers/TranslationController.php
Normal file
105
app/Http/Controllers/TranslationController.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Inertia\Inertia;
|
||||
use Throwable;
|
||||
|
||||
class TranslationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function path()
|
||||
{
|
||||
return lang_path(app()->getLocale() . '.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return Inertia::render('Translation/Index')->with([
|
||||
'translations' => $this->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'key' => 'required|string',
|
||||
'value' => 'required|string',
|
||||
]);
|
||||
|
||||
$all = $this->all();
|
||||
$all[$request->key] = $request->value;
|
||||
|
||||
try {
|
||||
File::put($this->path(), json_encode(
|
||||
$all, JSON_PRETTY_PRINT
|
||||
));
|
||||
|
||||
return redirect()->back()->with('success', __(
|
||||
'`:key` has been translated to `:value`', [
|
||||
'key' => $request->key,
|
||||
'value' => $request->value,
|
||||
],
|
||||
));
|
||||
} catch (Throwable $e) {
|
||||
return redirect()->back()->with('error', __(
|
||||
$e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(string $locale = 'id')
|
||||
{
|
||||
app()->setLocale($locale);
|
||||
|
||||
return $this->all() ?: '{}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
private function all()
|
||||
{
|
||||
return File::exists($this->path()) ? json_decode(File::get($this->path()), true) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $locale
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function register(Request $request, string $locale = 'id')
|
||||
{
|
||||
$request->validate([
|
||||
'text' => 'required|string',
|
||||
]);
|
||||
|
||||
app()->setLocale($locale);
|
||||
|
||||
$all = $this->all();
|
||||
|
||||
if (!array_key_exists($request->text, $all)) {
|
||||
$all[$request->text] = $request->text;
|
||||
}
|
||||
|
||||
return File::put($this->path(), json_encode(
|
||||
$all, JSON_PRETTY_PRINT
|
||||
));
|
||||
}
|
||||
}
|
||||
40
app/functions.php
Normal file
40
app/functions.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
if (! function_exists('__')) {
|
||||
/**
|
||||
* Translate the given message.
|
||||
*
|
||||
* @param string|null $key
|
||||
* @param array $replace
|
||||
* @param string|null $locale
|
||||
* @return string|array|null
|
||||
*/
|
||||
function __($key = null, $replace = [], $locale = null)
|
||||
{
|
||||
$allDefinedTranslation = function () {
|
||||
$path = lang_path(app()->getLocale() . '.json');
|
||||
|
||||
return File::exists($path) ? json_decode(File::get($path), true) : [];
|
||||
};
|
||||
|
||||
if (is_null($key)) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
if (is_string($key)) {
|
||||
$all = $allDefinedTranslation();
|
||||
|
||||
if (!array_key_exists($key, $all)) {
|
||||
$all[$key] = $key;
|
||||
|
||||
$path = lang_path(app()->getLocale() . '.json');
|
||||
|
||||
File::put($path, json_encode($all, JSON_PRETTY_PRINT));
|
||||
}
|
||||
}
|
||||
|
||||
return trans($key, $replace, $locale);
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
'timezone' => 'Asia/Jakarta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -82,7 +82,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
'locale' => 'id',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -108,7 +108,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
'faker_locale' => 'id_ID',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -108,6 +108,17 @@ class MenuSeeder extends Seeder
|
||||
])->get(['id'])
|
||||
);
|
||||
|
||||
$translation = $builtin->childs()->create([
|
||||
'name' => 'translation',
|
||||
'route_or_url' => 'superuser.translation.index',
|
||||
'icon' => 'language',
|
||||
'position' => 5,
|
||||
'deleteable' => false,
|
||||
'actives' => [
|
||||
'superuser.translation.*',
|
||||
],
|
||||
]);
|
||||
|
||||
$activities = Menu::create([
|
||||
'name' => 'activities',
|
||||
'icon' => 'address-card',
|
||||
|
||||
@@ -20,6 +20,8 @@ if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php'))
|
||||
require $maintenance;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../app/functions.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|
||||
@@ -13,10 +13,14 @@ const link = route().has(menu.route_or_url) ? route(menu.route_or_url) : menu.ro
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Link :href="link" class="w-full px-4 py-3" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${active && 'bg-slate-800'} pl-${padding !== 0 && padding}`">
|
||||
<Link
|
||||
:href="link"
|
||||
:class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${active && 'bg-slate-800'} pl-${padding !== 0 && padding}`"
|
||||
class="w-full px-4 py-3"
|
||||
>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Icon :name="menu.icon" />
|
||||
<p class="uppercase font-semibold">{{ menu.name }}</p>
|
||||
<p class="uppercase font-semibold">{{ __(menu.name) }}</p>
|
||||
</div>
|
||||
</Link>
|
||||
</template>
|
||||
@@ -43,10 +43,14 @@ const open = ref(active ? true : false)
|
||||
|
||||
<template>
|
||||
<div class="w-full flex flex-col">
|
||||
<button @click.prevent="open = ! open" class="w-full p-4" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${open && 'dark:bg-gray-800'} pl-${padding !== 0 && padding}`">
|
||||
<button
|
||||
@click.prevent="open = ! open"
|
||||
:class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${open && 'dark:bg-gray-800'} pl-${padding !== 0 && padding}`"
|
||||
class="w-full p-4"
|
||||
>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Icon :name="menu.icon" />
|
||||
<p class="uppercase font-semibold w-full text-left">{{ menu.name }}</p>
|
||||
<p class="uppercase font-semibold w-full text-left">{{ __(menu.name) }}</p>
|
||||
<Icon name="caret-left" class="transition-all ease-in-out duration-150" :class="open && '-rotate-90'" />
|
||||
</div>
|
||||
</button>
|
||||
|
||||
@@ -1,65 +1,196 @@
|
||||
<script setup>
|
||||
import { getCurrentInstance, ref, onMounted } from 'vue';
|
||||
import DashboardLayout from '@/Layouts/DashboardLayout.vue';
|
||||
import Card from '@/Components/Card.vue';
|
||||
import Icon from '@/Components/Icon.vue';
|
||||
import Builder from '@/Components/DataTable/Builder.vue';
|
||||
import Th from '@/Components/DataTable/Th.vue';
|
||||
|
||||
const self = getCurrentInstance()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DashboardLayout title="Login Activity">
|
||||
<DashboardLayout
|
||||
:title="__('login activities')"
|
||||
>
|
||||
<Card class="bg-white dark:bg-gray-700 dark:text-gray-200">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 bg-gray-200 dark:bg-gray-800 p-2">
|
||||
<p class="lowercase first-letter:capitalize font-semibold">login activities</p>
|
||||
<p class="lowercase first-letter:capitalize font-semibold">
|
||||
{{ __('login activities') }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<Builder :url="route('api.v1.superuser.activity.login')">
|
||||
<Builder
|
||||
:url="route('api.v1.superuser.activity.login')"
|
||||
>
|
||||
<template #thead="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th class="border p-2 text-center" :table="table" :sort="false">no</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="users.name">name</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="users.username">username</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="login_activities.ip_address">ip address</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="login_activities.browser">browser</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="login_activities.platform">platform</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="login_activities.created_at">at</Th>
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border p-2 text-center"
|
||||
>
|
||||
{{ __('no') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="users.name"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('name') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="users.username"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('username') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="login_activities.ip_address"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('ip address') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="login_activities.browser"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('browser') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="login_activities.platform"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('platform') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="login_activities.created_at"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('at') }}
|
||||
</Th>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template #tfoot="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th class="border p-2 text-center" :table="table" :sort="false">no</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">name</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">username</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">ip address</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">browser</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">platform</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">at</Th>
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border p-2 text-center"
|
||||
>
|
||||
{{ __('no') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('name') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('username') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('ip address') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('browser') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('platform') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('at') }}
|
||||
</Th>
|
||||
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template #tbody="{ data }">
|
||||
<transition-group
|
||||
<TransitionGroup
|
||||
enterActiveClass="transition-all duration-100"
|
||||
leaveActiveClass="transition-all duration-50"
|
||||
enterFromClass="opacity-0 -scale-y-100"
|
||||
leaveToClass="opacity-0 -scale-y-100">
|
||||
<tr v-for="(activity, i) in data" :key="i" class="dark:hover:bg-gray-600 dark:border-gray-800 transition-all duration-300">
|
||||
<td class="px-2 py-1 border border-inherit text-center">{{ i + 1 }}</td>
|
||||
<td class="px-2 py-1 border border-inherit uppercase">{{ activity.name }}</td>
|
||||
<td class="px-2 py-1 border border-inherit uppercase">{{ activity.username }}</td>
|
||||
<td class="px-2 py-1 border border-inherit uppercase">{{ activity.ip_address }}</td>
|
||||
<td class="px-2 py-1 border border-inherit uppercase">{{ activity.browser }}</td>
|
||||
<td class="px-2 py-1 border border-inherit uppercase">{{ activity.platform }}</td>
|
||||
<td class="px-2 py-1 border border-inherit uppercase">{{ new Date(activity.created_at).toLocaleString('id') }}</td>
|
||||
leaveToClass="opacity-0 -scale-y-100"
|
||||
>
|
||||
<tr
|
||||
v-for="(activity, i) in data"
|
||||
:key="i"
|
||||
class="dark:hover:bg-gray-600 dark:border-gray-800 transition-all duration-300"
|
||||
>
|
||||
<td class="px-2 py-1 border border-inherit text-center">
|
||||
{{ i + 1 }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ activity.name }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ activity.username }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ activity.ip_address }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ __(activity.browser) }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ __(activity.platform) }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ new Date(activity.created_at).toLocaleString('id') }}
|
||||
</td>
|
||||
</tr>
|
||||
</transition-group>
|
||||
</TransitionGroup>
|
||||
</template>
|
||||
</Builder>
|
||||
</template>
|
||||
|
||||
@@ -41,8 +41,8 @@ const fetch = async () => {
|
||||
menus.value = response.data
|
||||
} catch (e) {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you want to try again?',
|
||||
text: `${e}`,
|
||||
title: __('are you want to try again') + '?',
|
||||
text: __(`${e}`),
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
showCloseButton: true,
|
||||
@@ -105,8 +105,8 @@ const update = () => {
|
||||
|
||||
const destroy = async menu => {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you sure want to delete?',
|
||||
text: 'You can\'t recover it after deleted',
|
||||
title: __('are you sure want to delete') + '?',
|
||||
text: __('you can\'t recover it after deleted'),
|
||||
icon: 'question',
|
||||
showCloseButton: true,
|
||||
showCancelButton: true,
|
||||
@@ -143,26 +143,41 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<style src="@/multiselect.css"></style>
|
||||
|
||||
<template>
|
||||
<DashboardLayout title="Menu">
|
||||
<DashboardLayout
|
||||
:title="__('menu')"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 p-2 bg-gray-200 dark:bg-gray-800">
|
||||
<ButtonGreen v-if="can('create menu')" @click.prevent="form.id = null; show()">
|
||||
<ButtonGreen
|
||||
v-if="can('create menu')"
|
||||
@click.prevent="form.id = null; show()"
|
||||
>
|
||||
<Icon name="plus" />
|
||||
<p class="uppercase font-semibold">create</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __('create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div class="flex flex-col space-y-1 p-2">
|
||||
<Nested :menus="menus" :edit="edit" :destroy="destroy" :save="save" />
|
||||
<Nested
|
||||
:menus="menus"
|
||||
:edit="edit"
|
||||
:destroy="destroy"
|
||||
:save="save"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Card>
|
||||
|
||||
<Modal :show="open">
|
||||
<form @submit.prevent="submit" class="w-full max-w-xl sm:max-w-5xl h-fit rounded-md shadow-xl">
|
||||
<form
|
||||
@submit.prevent="submit"
|
||||
class="w-full max-w-xl sm:max-w-5xl h-fit rounded-md shadow-xl"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 p-2 justify-end bg-gray-200 dark:bg-gray-800">
|
||||
@@ -174,33 +189,53 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex flex-col space-y-2 p-4">
|
||||
<div class="flex flex-col space-y-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="name" class="lowercase first-letter:capitalize w-1/3">name</label>
|
||||
<Input v-model="form.name" type="text" name="name" placeholder="name" required autofocus />
|
||||
<label for="name" class="lowercase first-letter:capitalize w-1/3">
|
||||
{{ __('name') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.name"
|
||||
:placeholder="__('name')"
|
||||
type="text"
|
||||
name="name"
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.name" />
|
||||
<InputError
|
||||
:error="form.errors.name"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col space-y-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="route_or_url" class="lowercase first-letter:capitalize w-1/3">route name or url</label>
|
||||
<label for="route_or_url" class="lowercase first-letter:capitalize w-1/3">
|
||||
{{ __('route name or url') }}
|
||||
</label>
|
||||
|
||||
<Select
|
||||
v-model="form.route_or_url"
|
||||
:options="routes"
|
||||
:searchable="true"
|
||||
:createOption="true"
|
||||
:value="form.route_or_url"
|
||||
ref="route_or_url"
|
||||
|
||||
placeholder="route name or url" />
|
||||
:placeholder="__('route name or url')"
|
||||
ref="route_or_url"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.route_or_url" />
|
||||
<InputError
|
||||
:error="form.errors.route_or_url"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col space-y-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="actives" class="lowercase first-letter:capitalize w-1/3">actives</label>
|
||||
<label for="actives" class="lowercase first-letter:capitalize w-1/3">
|
||||
{{ __('actives') }}
|
||||
</label>
|
||||
|
||||
<Select
|
||||
v-model="form.actives"
|
||||
:options="[...routes, ...form.actives.filter(active => ! routes.includes(active))]"
|
||||
@@ -208,10 +243,10 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
:closeOnSelect="false"
|
||||
:clearOnSelect="false"
|
||||
:createTag="true"
|
||||
mode="tags"
|
||||
:placeholder="__('actives')"
|
||||
ref="actives"
|
||||
|
||||
placeholder="actives" />
|
||||
mode="tags"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.actives" />
|
||||
@@ -219,38 +254,55 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="permissions" class="lowercase first-letter:capitalize w-1/3">permissions</label>
|
||||
<label for="permissions" class="lowercase first-letter:capitalize w-1/3">
|
||||
{{ __('permissions') }}
|
||||
</label>
|
||||
|
||||
<Select
|
||||
v-model="form.permissions"
|
||||
:options="permissions.map(p => ({
|
||||
label: p.name,
|
||||
label: __(p.name),
|
||||
value: p.id,
|
||||
}))"
|
||||
:searchable="true"
|
||||
:closeOnSelect="false"
|
||||
:clearOnSelect="false"
|
||||
mode="tags"
|
||||
:placeholder="__('permissions')"
|
||||
ref="permissions"
|
||||
|
||||
placeholder="permissions" />
|
||||
mode="tags"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.permissions" />
|
||||
<InputError
|
||||
:error="form.errors.permissions"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-2">
|
||||
<label class="flex-none lowercase first-letter:capitalize w-1/4">icon</label>
|
||||
<label class="flex-none lowercase first-letter:capitalize w-1/4">
|
||||
{{ __('icon') }}
|
||||
</label>
|
||||
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<p class="text-3xl">
|
||||
<Icon :name="form.icon" class="dark:text-white" />
|
||||
<Icon
|
||||
:name="form.icon"
|
||||
class="dark:text-white"
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p class="text-sm uppercase">{{ form.icon }}</p>
|
||||
<p class="text-sm uppercase">
|
||||
{{ form.icon }}
|
||||
</p>
|
||||
|
||||
<ButtonBlue @click.prevent="icon = true" type="button">
|
||||
<ButtonBlue
|
||||
@click.prevent="icon = true"
|
||||
type="button"
|
||||
>
|
||||
<Icon name="edit" />
|
||||
<p class="uppercase font-semibold">change</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __('change') }}
|
||||
</p>
|
||||
</ButtonBlue>
|
||||
</div>
|
||||
</div>
|
||||
@@ -261,7 +313,9 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex items-center justify-end space-x-2 bg-gray-200 dark:bg-gray-800 py-1 px-2">
|
||||
<ButtonGreen type="submit">
|
||||
<Icon name="check" />
|
||||
<p class="uppercase font-semibold">{{ form.id ? 'update' : 'create' }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(form.id ? 'update' : 'create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
@@ -273,14 +327,29 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100 w-full max-w-xl sm:max-w-5xl max-h-96 overflow-auto">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 p-2 justify-end bg-gray-200 dark:bg-gray-800 sticky top-0 left-0">
|
||||
<input type="search" v-model="search" class="py-1 w-full bg-white dark:bg-transparent rounded-md text-sm uppercase" placeholder="search something">
|
||||
<Icon @click.prevent="icon = false" name="times" class="px-2 py-1 bg-gray-300 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 rounded-md transition-all cursor-pointer" />
|
||||
<input
|
||||
v-model="search"
|
||||
:placeholder="__('search something')"
|
||||
type="search"
|
||||
class="py-1 w-full bg-white dark:bg-transparent rounded-md text-sm uppercase"
|
||||
>
|
||||
<Icon
|
||||
@click.prevent="icon = false"
|
||||
name="times"
|
||||
class="px-2 py-1 bg-gray-300 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 rounded-md transition-all cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div class="flex-wrap p-4">
|
||||
<Icon v-for="(icx, i) in icons.filter(icx => icx.includes(search.trim().toLocaleLowerCase()))" :key="i" @click.prevent="form.icon = icx; icon = false" :name="icx" class="m-1 text-5xl px-2 py-1 text-gray-800 bg-gray-200 hover:bg-gray-100 dark:text-white dark:bg-gray-600 dark:hover:bg-gray-700 rounded-md cursor-pointer transition-all" />
|
||||
<Icon
|
||||
v-for="(icx, i) in icons.filter(icx => icx.includes(search.trim().toLocaleLowerCase()))"
|
||||
:key="i"
|
||||
@click.prevent="form.icon = icx; icon = false"
|
||||
:name="icx"
|
||||
class="m-1 text-5xl px-2 py-1 text-gray-800 bg-gray-200 hover:bg-gray-100 dark:text-white dark:bg-gray-600 dark:hover:bg-gray-700 rounded-md cursor-pointer transition-all"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Card>
|
||||
|
||||
@@ -30,8 +30,8 @@ const fetch = async () => {
|
||||
permissions.value = response.data
|
||||
} catch (e) {
|
||||
const response = await Swal.fire({
|
||||
title: 'Do you want to try again?',
|
||||
text: `${e}`,
|
||||
title: __('do you want to try again') + '?',
|
||||
text: __(`${e}`),
|
||||
icon: 'error',
|
||||
showCancelButton: true,
|
||||
showCloseButton: true,
|
||||
@@ -77,8 +77,8 @@ const update = () => form.patch(route('superuser.permission.update', form.id), {
|
||||
|
||||
const destroy = async permission => {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'You can\'t restore it after deleted',
|
||||
title: __('are you sure') + '?',
|
||||
text: __('you can\'t restore it after deleted'),
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
})
|
||||
@@ -101,13 +101,18 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DashboardLayout title="Permission">
|
||||
<DashboardLayout
|
||||
:title="__('permission')"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-slate-700 shadow-md">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 bg-gray-200 dark:bg-gray-800 p-2">
|
||||
<ButtonGreen v-if="can('create permission')" @click.prevent="form.id = null; show()">
|
||||
<ButtonGreen
|
||||
v-if="can('create permission')"
|
||||
@click.prevent="form.id = null; show()"
|
||||
>
|
||||
<Icon name="plus" />
|
||||
<p class="font-semibold uppercase">create</p>
|
||||
<p class="font-semibold uppercase">{{ __('create') }}</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
@@ -115,37 +120,65 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<template #body>
|
||||
<div class="flex flex-col space-y-2 p-4 h-screen max-h-96 overflow-auto">
|
||||
<div class="flex items-center justify-end space-x-2 text-sm dark:text-gray-100 px-4">
|
||||
<input v-model="search" type="search" class="bg-transparent w-full max-w-sm rounded-md placeholder:capitalize py-1" placeholder="search">
|
||||
<input
|
||||
v-model="search"
|
||||
:placeholder="__('search')"
|
||||
type="search"
|
||||
class="bg-transparent w-full max-w-sm rounded-md placeholder:capitalize py-1"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="flex-wrap px-4 pb-2 dark:bg-gray-700 dark:text-gray-100 rounded-b-md">
|
||||
<transition-group
|
||||
enterActiveClass="transition-all duration-300"
|
||||
leaveActiveClass="transition-all duration-300"
|
||||
enterFromClass="opacity-0 -translate-y-100"
|
||||
leaveToClass="opacity-0 -translate-y-100">
|
||||
<div v-for="(permission, i) in permissions.filter(p => p.name?.toLowerCase().includes(search?.trim().toLowerCase()))" :key="i" class="inline-block bg-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-900 transition-all duration-300 border dark:border-gray-700 dark:hover:border-gray-800 rounded-md m-[2px] px-3 py-1">
|
||||
<TransitionGroup
|
||||
enterActiveClass="transition-all duration-300"
|
||||
leaveActiveClass="transition-all duration-300"
|
||||
enterFromClass="opacity-0 -translate-y-100"
|
||||
leaveToClass="opacity-0 -translate-y-100"
|
||||
>
|
||||
<div
|
||||
v-for="(permission, i) in permissions.filter(p => p.name?.toLowerCase().includes(search?.trim().toLowerCase()))"
|
||||
:key="i"
|
||||
class="inline-block bg-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-900 transition-all duration-300 border dark:border-gray-700 dark:hover:border-gray-800 rounded-md m-[2px] px-3 py-1"
|
||||
>
|
||||
<div class="flex items-center space-x-2 text-sm">
|
||||
<p class="uppercase">{{ permission.name }}</p>
|
||||
<p class="uppercase">
|
||||
{{ __(permission.name) }}
|
||||
</p>
|
||||
|
||||
<div class="flex items-center space-x-1">
|
||||
<Icon v-if="can('update permission')" @click.prevent="edit(permission)" name="pen" class="px-2 py-1 rounded cursor-pointer text-white bg-blue-600 hover:bg-blue-700 transition-all" />
|
||||
<Icon v-if="can('delete permission')" @click.prevent="destroy(permission)" name="trash" class="px-2 py-1 rounded cursor-pointer text-white bg-red-600 hover:bg-red-700 transition-all" />
|
||||
<Icon
|
||||
v-if="can('update permission')"
|
||||
@click.prevent="edit(permission)"
|
||||
name="pen"
|
||||
class="px-2 py-1 rounded cursor-pointer text-white bg-blue-600 hover:bg-blue-700 transition-all"
|
||||
/>
|
||||
|
||||
<Icon
|
||||
v-if="can('delete permission')"
|
||||
@click.prevent="destroy(permission)"
|
||||
name="trash"
|
||||
class="px-2 py-1 rounded cursor-pointer text-white bg-red-600 hover:bg-red-700 transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition-group>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Card>
|
||||
|
||||
<Modal :show="open">
|
||||
<form @submit.prevent="submit" class="w-full max-w-xl h-fit shadow-xl">
|
||||
<form
|
||||
@submit.prevent="submit"
|
||||
class="w-full max-w-xl h-fit shadow-xl"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100 border dark:border-gray-700">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 justify-end bg-gray-200 dark:bg-gray-800 dark:text-gray-50 p-2">
|
||||
<Close @click.prevent="close" />
|
||||
<Close
|
||||
@click.prevent="close"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -153,11 +186,22 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex flex-col space-y-4 p-4">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="name" class="lowercase first-letter:capitalize flex-none w-1/4">name</label>
|
||||
<Input v-model="form.name" type="text" placeholder="name" required autofocus />
|
||||
<label for="name" class="lowercase first-letter:capitalize flex-none w-1/4">
|
||||
{{ __('name') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.name"
|
||||
:placeholder="__('name')"
|
||||
type="text"
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.name" />
|
||||
<InputError
|
||||
:error="form.errors.name"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -166,7 +210,9 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex items-center space-x-2 justify-end bg-gray-200 dark:bg-gray-800 text-white px-2 py-1">
|
||||
<ButtonGreen type="submit">
|
||||
<Icon name="check" />
|
||||
<p class="uppercase font-semibold">{{ form.id ? 'update' : 'create' }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(form.id ? 'update' : 'create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -41,7 +41,7 @@ const close = () => {
|
||||
|
||||
const detach = async (role, permission) => {
|
||||
const response = await Swal.fire({
|
||||
title: 'are you sure?',
|
||||
title: __('are you sure') + '?',
|
||||
icon: 'question',
|
||||
showCloseButton: true,
|
||||
showCancelButton: true,
|
||||
@@ -78,8 +78,8 @@ const update = () => {
|
||||
|
||||
const destroy = async role => {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'You can\'t restore it after deleted',
|
||||
title: __('are you sure') + '?',
|
||||
text: __('you can\'t restore it after deleted'),
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
showCloseButton: true,
|
||||
@@ -103,73 +103,178 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<style src="@/multiselect.css"></style>
|
||||
|
||||
<template>
|
||||
<DashboardLayout title="Role">
|
||||
<DashboardLayout
|
||||
:title="__('role')"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 p-2 bg-gray-200 dark:bg-gray-800">
|
||||
<ButtonGreen v-if="can('create role')" @click.prevent="form.id = null; show()">
|
||||
<ButtonGreen
|
||||
v-if="can('create role')"
|
||||
@click.prevent="form.id = null; show()"
|
||||
>
|
||||
<Icon name="plus" />
|
||||
<p class="uppercase font-semibold">create</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __('create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div class="flex flex-col space-y-2">
|
||||
<Builder ref="table" :url="route('api.v1.superuser.role.paginate')">
|
||||
<Builder
|
||||
:url="route('api.v1.superuser.role.paginate')"
|
||||
ref="table"
|
||||
>
|
||||
<template #thead="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th class="border px-3 py-2 text-center" :table="table" :sort="false">no</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="name">name</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">permissions</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">action</Th>
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center"
|
||||
>
|
||||
{{ __('no') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="name"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('name') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('permissions') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('#') }}
|
||||
</Th>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template #tfoot="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th class="border px-3 py-2 text-center" :table="table" :sort="false">no</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">name</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">permissions</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">action</Th>
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center"
|
||||
>
|
||||
{{ __('no') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('name') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('permissions') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('#') }}
|
||||
</Th>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template #tbody="{ data, processing, empty, refresh }">
|
||||
<TransitionGroup enterActiveClass="transition-all duration-200" leaveActiveClass="transition-all duration-200" enterFromClass="opacity-0 -scale-y-100" leaveToClass="opacity-0 -scale-y-100">
|
||||
<TransitionGroup
|
||||
enterActiveClass="transition-all duration-200"
|
||||
leaveActiveClass="transition-all duration-200"
|
||||
enterFromClass="opacity-0 -scale-y-100"
|
||||
leaveToClass="opacity-0 -scale-y-100"
|
||||
>
|
||||
<template v-if="empty">
|
||||
<tr>
|
||||
<td class="text-5xl text-center p-4" colspan="1000">
|
||||
<p class="lowercase first-letter:capitalize font-semibold">there are no data available</p>
|
||||
<p class="lowercase first-letter:capitalize font-semibold">
|
||||
{{ __('there are no data available') }}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<tr v-for="(role, i) in data" :key="i" class="dark:hover:bg-gray-600 transition-all duration-300" :class="processing && 'bg-gray-800'">
|
||||
<td class="px-2 py-1 border dark:border-gray-800 text-center">{{ i + 1 }}</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ role.name }}</td>
|
||||
<tr
|
||||
v-for="(role, i) in data"
|
||||
:key="i"
|
||||
:class="processing && 'bg-gray-800'"
|
||||
class="dark:hover:bg-gray-600 transition-all duration-300"
|
||||
>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 text-center">
|
||||
{{ i + 1 }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ __(role.name) }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800">
|
||||
<div class="flex-wrap">
|
||||
<div v-for="(permission, j) in role.permissions" :key="j" class="inline-block bg-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-900 border dark:border-gray-700 dark:hover:border-gray-800 rounded-md px-3 py-1 m-[1px] text-sm">
|
||||
<div
|
||||
v-for="(permission, j) in role.permissions"
|
||||
:key="j"
|
||||
class="inline-block bg-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-900 border dark:border-gray-700 dark:hover:border-gray-800 rounded-md px-3 py-1 m-[1px] text-sm"
|
||||
>
|
||||
<div class="flex items-center justify-between space-x-2">
|
||||
<p class="uppercase font-semibold">{{ permission.name }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(permission.name) }}
|
||||
</p>
|
||||
|
||||
<Icon @click.prevent="detach(role, permission, refresh)" v-if="can('update role')" name="times" class="px-2 py-1 rounded-md bg-red-500 dark:bg-gray-700 transition-all hover:bg-red-600 text-white cursor-pointer" />
|
||||
<Icon
|
||||
v-if="can('update role')"
|
||||
@click.prevent="detach(role, permission, refresh)"
|
||||
name="times"
|
||||
class="px-2 py-1 rounded-md bg-red-500 dark:bg-gray-700 transition-all hover:bg-red-600 text-white cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800">
|
||||
<div class="flex items-center space-x-2">
|
||||
<ButtonBlue v-if="can('update role')" @click.prevent="edit(role)">
|
||||
<ButtonBlue
|
||||
v-if="can('update role')"
|
||||
@click.prevent="edit(role)"
|
||||
>
|
||||
<Icon name="edit" />
|
||||
<p class="uppercase">edit</p>
|
||||
<p class="uppercase">
|
||||
{{ __('edit') }}
|
||||
</p>
|
||||
</ButtonBlue>
|
||||
|
||||
<ButtonRed v-if="can('delete role')" @click.prevent="destroy(role)">
|
||||
<ButtonRed
|
||||
v-if="can('delete role')"
|
||||
@click.prevent="destroy(role)"
|
||||
>
|
||||
<Icon name="trash" />
|
||||
<p class="uppercase">delete</p>
|
||||
<p class="uppercase">
|
||||
{{ __('delete') }}
|
||||
</p>
|
||||
</ButtonRed>
|
||||
</div>
|
||||
</td>
|
||||
@@ -183,7 +288,10 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
</Card>
|
||||
|
||||
<Modal :show="open">
|
||||
<form @submit.prevent="submit" class="w-full max-w-xl h-fit shadow-xl">
|
||||
<form
|
||||
@submit.prevent="submit"
|
||||
class="w-full max-w-xl h-fit shadow-xl"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-end bg-gray-200 dark:bg-gray-800 p-2">
|
||||
@@ -195,20 +303,35 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex flex-col space-y-4 p-4">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="name" class="w-1/3 lowercase first-letter:capitalize">name</label>
|
||||
<Input v-model="form.name" type="text" name="name" placeholder="name" required autofocus />
|
||||
<label for="name" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('name') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.name"
|
||||
:placeholder="__('name')"
|
||||
type="text"
|
||||
name="name"
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.name" />
|
||||
<InputError
|
||||
:error="form.errors.name"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="permissions" class="w-1/3 lowercase first-letter:capitalize">permissions</label>
|
||||
<label for="permissions" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('permissions') }}
|
||||
</label>
|
||||
|
||||
<Select
|
||||
v-model="form.permissions"
|
||||
:options="permissions.map(p => ({
|
||||
label: p.name,
|
||||
label: __(p.name),
|
||||
value: p.id,
|
||||
}))"
|
||||
:searchable="true"
|
||||
@@ -216,10 +339,13 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
:closeOnSelect="false"
|
||||
class="uppercase"
|
||||
placeholder="permissions"
|
||||
mode="tags" />
|
||||
mode="tags"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.permissions" />
|
||||
<InputError
|
||||
:error="form.errors.permissions"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -228,7 +354,9 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex items-center justify-end space-x-2 bg-gray-200 dark:bg-gray-800 px-2 py-1">
|
||||
<ButtonGreen type="submit">
|
||||
<Icon name="check" />
|
||||
<p class="uppercase font-semibold">{{ form.id ? 'update' : 'create' }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(form.id ? 'update' : 'create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -72,8 +72,8 @@ const update = () => {
|
||||
|
||||
const destroy = async user => {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'You can\'t restore it after deleted',
|
||||
title: __('are you sure') + '?',
|
||||
text: __('you can\'t restore it after deleted'),
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
showCloseButton: true,
|
||||
@@ -90,8 +90,8 @@ const submit = () => form.id ? update() : store()
|
||||
|
||||
const detachPermission = async (user, permission) => {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'You can re adding it on edit page',
|
||||
title: __('are you sure') + '?',
|
||||
text: __('you can re adding it on edit page'),
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
showCloseButton: true,
|
||||
@@ -106,8 +106,8 @@ const detachPermission = async (user, permission) => {
|
||||
|
||||
const detachRole = async (user, role) => {
|
||||
const response = await Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'You can re adding it on edit page',
|
||||
title: __('are you sure') + '?',
|
||||
text: __('you can re adding it on edit page'),
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
showCloseButton: true,
|
||||
@@ -130,101 +130,322 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<style src="@/multiselect.css"></style>
|
||||
|
||||
<template>
|
||||
<DashboardLayout title="User">
|
||||
<DashboardLayout
|
||||
:title="__('user')"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 p-2 bg-gray-200 dark:bg-gray-800">
|
||||
<ButtonGreen v-if="can('create user')" @click.prevent="form.id = null; show()">
|
||||
<ButtonGreen
|
||||
v-if="can('create user')"
|
||||
@click.prevent="form.id = null; show()"
|
||||
>
|
||||
<Icon name="plus" />
|
||||
<p class="uppercase font-semibold">create</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __('create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div class="flex flex-col space-y-2">
|
||||
<Builder ref="table" :url="route('api.v1.superuser.user.paginate')">
|
||||
<Builder
|
||||
:url="route('api.v1.superuser.user.paginate')"
|
||||
ref="table"
|
||||
>
|
||||
<template #thead="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th class="border px-3 py-2 text-center" :table="table" :sort="false">no</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="name">name</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="username">username</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="email">email</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">permissions</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">roles</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="email_verified_at">verified at</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="created_at">created at</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="true" name="updated_at">updated at</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">action</Th>
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center"
|
||||
>
|
||||
{{ __('no') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="name"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('name') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="username"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('username') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="email"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('email') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('permissions') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('roles') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="email_verified_at"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('verified at') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="created_at"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('created at') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="updated_at"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('updated at') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('action') }}
|
||||
</Th>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template #tfoot="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th class="border px-3 py-2 text-center" :table="table" :sort="false">no</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">name</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">username</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">email</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">permissions</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">roles</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">verified at</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">created at</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">updated at</Th>
|
||||
<Th class="border px-3 py-2 text-center whitespace-nowrap" :table="table" :sort="false">action</Th>
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center"
|
||||
>
|
||||
{{ __('no') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('name') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('username') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('email') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('permissions') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('roles') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('verified at') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('created at') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('updated at') }}
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
{{ __('action') }}
|
||||
</Th>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template #tbody="{ data, processing, empty }">
|
||||
<TransitionGroup enterActiveClass="transition-all duration-200" leaveActiveClass="transition-all duration-200" enterFromClass="opacity-0 -scale-y-100" leaveToClass="opacity-0 -scale-y-100">
|
||||
<TransitionGroup
|
||||
enterActiveClass="transition-all duration-200"
|
||||
leaveActiveClass="transition-all duration-200"
|
||||
enterFromClass="opacity-0 -scale-y-100"
|
||||
leaveToClass="opacity-0 -scale-y-100"
|
||||
>
|
||||
<template v-if="empty">
|
||||
<tr v-if="empty">
|
||||
<tr>
|
||||
<td class="text-5xl text-center p-4" colspan="1000">
|
||||
<p class="lowercase first-letter:capitalize font-semibold">there are no data available</p>
|
||||
<p class="lowercase first-letter:capitalize font-semibold">
|
||||
{{ __('there are no data available') }}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<tr v-for="(user, i) in data" :key="i" class="dark:hover:bg-gray-600 transition-all duration-300" :class="processing && 'bg-gray-800'">
|
||||
<td class="px-2 py-1 border dark:border-gray-800 text-center">{{ i + 1 }}</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ user.name }}</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ user.username }}</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ user.email }}</td>
|
||||
<tr
|
||||
v-for="(user, i) in data"
|
||||
:key="i"
|
||||
:class="processing && 'bg-gray-800'"
|
||||
class="dark:hover:bg-gray-600 transition-all duration-300"
|
||||
>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 text-center">
|
||||
{{ i + 1 }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ user.name }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ user.username }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ user.email }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800">
|
||||
<div class="flex-wrap">
|
||||
<div v-for="(permission, j) in user.permissions" :key="j" class="inline-block bg-gray-600 rounded-md px-3 py-1 m-[1px] text-sm">
|
||||
<div
|
||||
v-for="(permission, j) in user.permissions"
|
||||
:key="j"
|
||||
class="inline-block bg-gray-600 rounded-md px-3 py-1 m-[1px] text-sm"
|
||||
>
|
||||
<div class="flex items-center justify-between space-x-1">
|
||||
<p class="uppercase font-semibold">{{ permission.name }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(permission.name) }}
|
||||
</p>
|
||||
|
||||
<Icon @click.prevent="detachPermission(user, permission)" v-if="can('update user')" name="times" class="px-2 py-1 rounded-md dark:bg-gray-700 transition-all hover:bg-red-500 cursor-pointer" />
|
||||
<Icon
|
||||
v-if="can('update user')"
|
||||
@click.prevent="detachPermission(user, permission)"
|
||||
name="times"
|
||||
class="px-2 py-1 rounded-md dark:bg-gray-700 transition-all hover:bg-red-500 cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800">
|
||||
<div class="flex-wrap">
|
||||
<div v-for="(role, j) in user.roles" :key="j" class="inline-block dark:bg-gray-800 dark:hover:bg-gray-900 border dark:border-gray-800 rounded-md px-3 py-1 m-[1px] text-sm transition-all">
|
||||
<div
|
||||
v-for="(role, j) in user.roles"
|
||||
:key="j"
|
||||
class="inline-block dark:bg-gray-800 dark:hover:bg-gray-900 border dark:border-gray-800 rounded-md px-3 py-1 m-[1px] text-sm transition-all"
|
||||
>
|
||||
<div class="flex items-center justify-between space-x-2">
|
||||
<p class="uppercase font-semibold">{{ role.name }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(role.name) }}
|
||||
</p>
|
||||
|
||||
<Icon @click.prevent="detachRole(user, role)" v-if="can('update user')" name="times" class="px-2 py-1 rounded-md dark:bg-gray-700 transition-all hover:bg-red-500 cursor-pointer" />
|
||||
<Icon
|
||||
v-if="can('update user')"
|
||||
@click.prevent="detachRole(user, role)"
|
||||
name="times"
|
||||
class="px-2 py-1 rounded-md dark:bg-gray-700 transition-all hover:bg-red-500 cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ new Date(user.email_verified_at).toLocaleString('id') }}</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ new Date(user.created_at).toLocaleString('id') }}</td>
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">{{ new Date(user.updated_at).toLocaleString('id') }}</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ new Date(user.email_verified_at).toLocaleString('id') }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ new Date(user.created_at).toLocaleString('id') }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800 uppercase">
|
||||
{{ new Date(user.updated_at).toLocaleString('id') }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border dark:border-gray-800">
|
||||
<div class="flex items-center space-x-2">
|
||||
<ButtonBlue v-if="can('update user')" @click.prevent="edit(user)">
|
||||
<ButtonBlue
|
||||
v-if="can('update user')"
|
||||
@click.prevent="edit(user)"
|
||||
>
|
||||
<Icon name="edit" />
|
||||
<p class="uppercase">edit</p>
|
||||
<p class="uppercase">
|
||||
{{ __('edit') }}
|
||||
</p>
|
||||
</ButtonBlue>
|
||||
|
||||
<ButtonRed v-if="can('delete user')" @click.prevent="destroy(user)">
|
||||
<ButtonRed
|
||||
v-if="can('delete user')"
|
||||
@click.prevent="destroy(user)"
|
||||
>
|
||||
<Icon name="trash" />
|
||||
<p class="uppercase">delete</p>
|
||||
<p class="uppercase">
|
||||
{{ __('delete') }}
|
||||
</p>
|
||||
</ButtonRed>
|
||||
</div>
|
||||
</td>
|
||||
@@ -238,7 +459,10 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
</Card>
|
||||
|
||||
<Modal :show="open">
|
||||
<form @submit.prevent="submit" class="w-full max-w-xl sm:max-w-5xl h-fit shadow-xl">
|
||||
<form
|
||||
@submit.prevent="submit"
|
||||
class="w-full max-w-xl sm:max-w-5xl h-fit shadow-xl"
|
||||
>
|
||||
<Card class="bg-gray-50 dark:bg-gray-700 dark:text-gray-100">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-end bg-gray-200 dark:bg-gray-800 p-2">
|
||||
@@ -250,8 +474,18 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex flex-col space-y-4 p-4">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="name" class="w-1/3 lowercase first-letter:capitalize">name</label>
|
||||
<Input v-model="form.name" type="text" name="name" placeholder="name" required autofocus />
|
||||
<label for="name" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('name') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.name"
|
||||
:placeholder="__('name')"
|
||||
type="text"
|
||||
name="name"
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.name" />
|
||||
@@ -259,8 +493,17 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="username" class="w-1/3 lowercase first-letter:capitalize">username</label>
|
||||
<Input v-model="form.username" type="text" name="username" placeholder="username" required />
|
||||
<label for="username" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('username') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.username"
|
||||
:placeholder="__('username')"
|
||||
type="text"
|
||||
name="username"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.username" />
|
||||
@@ -268,8 +511,17 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="email" class="w-1/3 lowercase first-letter:capitalize">email</label>
|
||||
<Input v-model="form.email" type="email" name="email" placeholder="email" required />
|
||||
<label for="email" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('name') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.email"
|
||||
:placeholder="__('email')"
|
||||
type="email"
|
||||
name="email"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.email" />
|
||||
@@ -277,8 +529,17 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="password" class="w-1/3 lowercase first-letter:capitalize">password</label>
|
||||
<Input v-model="form.password" type="password" name="password" placeholder="password" :required="form.id === null" />
|
||||
<label for="password" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('password') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.password"
|
||||
:placeholder="__('password')"
|
||||
:required="form.id === null"
|
||||
type="password"
|
||||
name="password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.password" />
|
||||
@@ -286,8 +547,17 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="password_confirmation" class="w-1/3 lowercase first-letter:capitalize">password confirmation</label>
|
||||
<Input v-model="form.password_confirmation" type="password" name="password_confirmation" placeholder="password confirmation" :required="form.id === null" />
|
||||
<label for="password_confirmation" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('password confirmation') }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
v-model="form.password_confirmation"
|
||||
:required="form.id === null"
|
||||
:placeholder="__('password confirmation')"
|
||||
type="password"
|
||||
name="password_confirmation"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.password_confirmation" />
|
||||
@@ -295,19 +565,23 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="permissions" class="w-1/3 lowercase first-letter:capitalize">permissions</label>
|
||||
<label for="permissions" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('permissions') }}
|
||||
</label>
|
||||
|
||||
<Select
|
||||
v-model="form.permissions"
|
||||
:options="permissions.map(p => ({
|
||||
label: p.name,
|
||||
label: __(p.name),
|
||||
value: p.id,
|
||||
}))"
|
||||
:clearOnSelect="false"
|
||||
:closeOnSelect="false"
|
||||
:searchable="true"
|
||||
:placeholder="__('permissions')"
|
||||
class="uppercase"
|
||||
placeholder="permissions"
|
||||
mode="tags" />
|
||||
mode="tags"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.permissions" />
|
||||
@@ -315,19 +589,23 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
|
||||
<div class="flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<label for="roles" class="w-1/3 lowercase first-letter:capitalize">roles</label>
|
||||
<label for="roles" class="w-1/3 lowercase first-letter:capitalize">
|
||||
{{ __('roles') }}
|
||||
</label>
|
||||
|
||||
<Select
|
||||
v-model="form.roles"
|
||||
:options="roles.map(r => ({
|
||||
label: r.name,
|
||||
label: __(r.name),
|
||||
value: r.id,
|
||||
}))"
|
||||
:searchable="true"
|
||||
:clearOnSelect="false"
|
||||
:closeOnSelect="false"
|
||||
:placeholder="__('roles')"
|
||||
class="uppercase"
|
||||
placeholder="roles"
|
||||
mode="tags" />
|
||||
mode="tags"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InputError :error="form.errors.roles" />
|
||||
@@ -339,8 +617,9 @@ onUnmounted(() => window.removeEventListener('keydown', esc))
|
||||
<div class="flex items-center justify-end space-x-2 bg-gray-200 dark:bg-gray-800 px-2 py-1">
|
||||
<ButtonGreen type="submit">
|
||||
<Icon name="check" />
|
||||
|
||||
<p class="uppercase font-semibold">{{ form.id ? 'update' : 'create' }}</p>
|
||||
<p class="uppercase font-semibold">
|
||||
{{ __(form.id ? 'update' : 'create') }}
|
||||
</p>
|
||||
</ButtonGreen>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
80
resources/js/Pages/Translation/Index.vue
Normal file
80
resources/js/Pages/Translation/Index.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import DashboardLayout from '@/Layouts/DashboardLayout.vue'
|
||||
import Card from '@/Components/Card.vue'
|
||||
import Icon from '@/Components/Icon.vue'
|
||||
import Input from '@/Components/Input.vue'
|
||||
import { useForm } from '@inertiajs/inertia-vue3'
|
||||
import { Inertia } from '@inertiajs/inertia'
|
||||
|
||||
const { translations } = defineProps({
|
||||
translations: Object,
|
||||
})
|
||||
|
||||
const search = ref('')
|
||||
|
||||
const update = (key, value) => {
|
||||
return useForm({key, value}).patch(route('superuser.translation.update'), {
|
||||
// onFinish: () => Inertia.get(route(route().current()))
|
||||
})
|
||||
}
|
||||
|
||||
const sorted = () => Object.keys(translations).sort().map(key => ({
|
||||
key: key,
|
||||
value: translations[key],
|
||||
}))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DashboardLayout
|
||||
:title="__('translation')"
|
||||
>
|
||||
<Card class="bg-white dark:bg-gray-700 dark:text-gray-200">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-1 justify-between bg-gray-200 dark:bg-gray-800 p-2">
|
||||
<p class="lowercase first-letter:capitalize">
|
||||
{{ __('you can change translation on this page') }}
|
||||
</p>
|
||||
|
||||
<Input
|
||||
v-model="search"
|
||||
:placeholder="__('search')"
|
||||
type="search"
|
||||
class="max-w-xs text-sm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div class="flex flex-col space-y-2 p-4 h-screen max-h-96 overflow-auto">
|
||||
<TransitionGroup
|
||||
enterActiveClass="transition-all duration-300"
|
||||
leaveActiveClass="transition-all duration-300"
|
||||
enterFromClass="opacity-0 -translate-y-full bg-white"
|
||||
leaveToClass="opacity-0 -translate-y-full bg-white"
|
||||
>
|
||||
<template
|
||||
v-for="(translation, i) in sorted().filter(t => t.key.toLocaleLowerCase().includes(search.trim().toLocaleLowerCase()))"
|
||||
:key="i"
|
||||
>
|
||||
<div class="flex flex-col space-y-1 px-2 rounded-md">
|
||||
<div class="flex items-center space-x-1">
|
||||
<label :for="`${translation.key}`" class="flex-none w-1/3">
|
||||
{{ translation.key }}
|
||||
</label>
|
||||
|
||||
<Input
|
||||
:value="translation.value"
|
||||
@change.prevent="$event.target.value.trim() && update(translation.key, $event.target.value)"
|
||||
type="text"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</template>
|
||||
</Card>
|
||||
</DashboardLayout>
|
||||
</template>
|
||||
@@ -34,8 +34,31 @@ const can = (abilities) => {
|
||||
}
|
||||
}
|
||||
|
||||
window.translations = {}
|
||||
window.locale = localStorage.getItem('locale') || 'id'
|
||||
|
||||
const translation = () => axios.get(route('api.translation.get', window.locale))
|
||||
.then(response => response.data)
|
||||
.then(response => window.translations = response)
|
||||
|
||||
translation()
|
||||
|
||||
window.can = can
|
||||
window.__ = (text, replacements = {}) => {
|
||||
if (typeof text === 'string') {
|
||||
if (window.translations.hasOwnProperty(text)) {
|
||||
text = window.translations[text]
|
||||
} else {
|
||||
axios.post(route(
|
||||
'api.translation.register', window.locale
|
||||
), { text }).then(translation)
|
||||
}
|
||||
|
||||
for (const key in replacements) {
|
||||
text = text.replace(new RegExp(`:${key}`, 'g'), replacements[key])
|
||||
}
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
|
||||
@@ -27,4 +27,9 @@ Route::prefix('/v1')->name('api.v1.')->middleware(['auth:sanctum'])->group(funct
|
||||
});
|
||||
|
||||
Route::get('/user', fn () => request()->user());
|
||||
});
|
||||
|
||||
Route::prefix('/translation/{locale?}')->name('api.translation.')->controller(App\Http\Controllers\TranslationController::class)->group(function () {
|
||||
Route::get('/', 'get')->name('get');
|
||||
Route::post('/', 'register')->name('register');
|
||||
});
|
||||
@@ -43,6 +43,11 @@ Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified']
|
||||
Route::resource('menu', App\Http\Controllers\Superuser\MenuController::class)->only([
|
||||
'index', 'store', 'update', 'destroy',
|
||||
])->middleware(['permission:read menu']);
|
||||
|
||||
Route::prefix('/translation')->name('translation.')->controller(App\Http\Controllers\TranslationController::class)->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::patch('/', 'update')->name('update');
|
||||
});
|
||||
|
||||
Route::get('/activity/login', [App\Http\Controllers\ActivityController::class, 'login'])->name('activity.login');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user