fixed problems with tailwind overwriting naive ui styles
implemented user datatable
This commit is contained in:
@@ -34,7 +34,15 @@ export default class UsersController {
|
|||||||
return inertia.render('Users/Show', { queriedUser })
|
return inertia.render('Users/Show', { queriedUser })
|
||||||
}
|
}
|
||||||
|
|
||||||
public async edit({}: HttpContextContract) {}
|
public async edit({ bouncer, params, inertia }: HttpContextContract) {
|
||||||
|
const queriedUser: User = await User.findByOrFail('id', params.id)
|
||||||
|
|
||||||
|
await bouncer
|
||||||
|
.with("UserPolicy")
|
||||||
|
.authorize('edit', queriedUser)
|
||||||
|
|
||||||
|
return inertia.render("Users/Edit", { queriedUser })
|
||||||
|
}
|
||||||
|
|
||||||
public async update({}: HttpContextContract) {}
|
public async update({}: HttpContextContract) {}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,18 @@ export default class UserPolicy extends BasePolicy {
|
|||||||
public async index(user: User) {
|
public async index(user: User) {
|
||||||
return user.isAdmin
|
return user.isAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async create(user: User) {
|
||||||
|
return user.isAdmin
|
||||||
|
}
|
||||||
|
|
||||||
public async show(user: User, query: User) {
|
public async show(user: User, query: User) {
|
||||||
return user.isAdmin || user.id === query.id
|
return user.isAdmin || user.id === query.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async edit(user: User, query: User) {
|
||||||
|
return user.isAdmin || user.id === query.id
|
||||||
|
}
|
||||||
|
|
||||||
public async update(user: User, query: User) {
|
public async update(user: User, query: User) {
|
||||||
return user.isAdmin || user.id === query.id
|
return user.isAdmin || user.id === query.id
|
||||||
|
|||||||
1
components.d.ts
vendored
1
components.d.ts
vendored
@@ -8,6 +8,7 @@ export {}
|
|||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
NButton: typeof import('naive-ui')['NButton']
|
NButton: typeof import('naive-ui')['NButton']
|
||||||
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
NDataTable: typeof import('naive-ui')['NDataTable']
|
NDataTable: typeof import('naive-ui')['NDataTable']
|
||||||
NForm: typeof import('naive-ui')['NForm']
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<LoginLayout class="w-3/5">
|
<n-config-provider preflight-style-disabled>
|
||||||
<MainNav />
|
<LoginLayout class="w-3/5">
|
||||||
<slot></slot>
|
<MainNav />
|
||||||
|
<slot></slot>
|
||||||
|
|
||||||
</LoginLayout>
|
</LoginLayout>
|
||||||
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import '../css/app.css'
|
import '../css/app.css'
|
||||||
import { createApp, h } from "vue";
|
import { createApp, h } from "vue";
|
||||||
import { createInertiaApp, Link } from "@inertiajs/vue3";
|
import { createInertiaApp, Link } from "@inertiajs/vue3";
|
||||||
import '../css/app.css'
|
|
||||||
|
|
||||||
createInertiaApp({
|
createInertiaApp({
|
||||||
resolve: (name) => require(`./pages/${name}`),
|
resolve: (name) => require(`./pages/${name}`),
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<n-button
|
<n-button
|
||||||
class="bg-[#18A058]"
|
|
||||||
type="success"
|
type="success"
|
||||||
@click="onClickLogin"
|
@click="onClickLogin"
|
||||||
:disabled="!form.password || !form.username"
|
:disabled="!form.password || !form.username"
|
||||||
|
|||||||
6
resources/js/pages/Users/Edit.vue
Normal file
6
resources/js/pages/Users/Edit.vue
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
</script>
|
||||||
@@ -7,18 +7,26 @@
|
|||||||
<n-data-table
|
<n-data-table
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="users"
|
:data="users"
|
||||||
|
row-class-name="group"
|
||||||
/>
|
/>
|
||||||
<div>
|
|
||||||
{{ users }}
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import BELayout from '@/layouts/BELayout.vue'
|
|
||||||
import FlashMessages from '@/components/FlashMessages.vue'
|
|
||||||
import type { User } from '../../types/User'
|
import type { User } from '../../types/User'
|
||||||
import type { DataTableColumns } from 'naive-ui'
|
import type { DataTableColumns } from 'naive-ui'
|
||||||
|
import type { VNode } from 'vue'
|
||||||
|
|
||||||
|
import { h } from 'vue'
|
||||||
|
import BELayout from '@/layouts/BELayout.vue'
|
||||||
|
import FlashMessages from '@/components/FlashMessages.vue'
|
||||||
|
import { NIcon, NButton } from 'naive-ui'
|
||||||
|
|
||||||
|
import {
|
||||||
|
AdminPanelSettingsFilled as Admin,
|
||||||
|
EditRound as Edit,
|
||||||
|
DeleteRound as Delete,
|
||||||
|
} from '@vicons/material'
|
||||||
|
|
||||||
defineOptions({ layout: BELayout })
|
defineOptions({ layout: BELayout })
|
||||||
|
|
||||||
@@ -29,16 +37,59 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const columns: DataTableColumns<User> = [
|
const columns: DataTableColumns<User> = [
|
||||||
{
|
{
|
||||||
title: "ID",
|
title: "Admin",
|
||||||
key: "id",
|
key: "is_admin",
|
||||||
|
align: "center",
|
||||||
|
render (row) {
|
||||||
|
if(row.is_admin) {
|
||||||
|
return h(
|
||||||
|
NIcon,
|
||||||
|
{ size: 20, component: Admin, class: "align-middle" }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Benutzername",
|
title: "Benutzername",
|
||||||
key: "username",
|
key: "username",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Admin?",
|
title: "Aktionen",
|
||||||
key: "is_admin",
|
key: "actions",
|
||||||
|
className: "space-x-4",
|
||||||
|
render(row) {
|
||||||
|
let arr: VNode[] = []
|
||||||
|
arr[0] = h(
|
||||||
|
NButton,
|
||||||
|
{
|
||||||
|
class: "invisible group-hover:visible align-middle",
|
||||||
|
circle: true,
|
||||||
|
onClick: () => { clickEdit(row.id) },
|
||||||
|
renderIcon: () => { return h(NIcon, { component: Edit, size: 20 }) },
|
||||||
|
},
|
||||||
|
)
|
||||||
|
arr[1] = h(
|
||||||
|
NButton,
|
||||||
|
{
|
||||||
|
class: "invisible group-hover:visible align-middle",
|
||||||
|
secondary: true,
|
||||||
|
circle: true,
|
||||||
|
type: "error",
|
||||||
|
onClick: () => { clickDelete(row.id) },
|
||||||
|
renderIcon: () => { return h(NIcon, { component: Delete, size: 20 }) },
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return arr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
function clickEdit(id: Number){
|
||||||
|
console.log("Edit clicked: "+id)
|
||||||
|
}
|
||||||
|
|
||||||
|
function clickDelete(id: Number){
|
||||||
|
console.log("Delete clicked: "+id)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
@entryPointScripts('app')
|
@entryPointScripts('app')
|
||||||
|
|
||||||
<title>enzos-events</title>
|
<title>enzos-events</title>
|
||||||
|
<meta name="naive-ui-style" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@inertia
|
@inertia
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// tsconfig.vue.json
|
// tsconfig.vue.json
|
||||||
|
|
||||||
"extends": "@vue/tsconfig/tsconfig.json",
|
"extends": "@vue/tsconfig/tsconfig.web.json",
|
||||||
"include": [
|
"include": [
|
||||||
"./resources/js/**/*"
|
"./resources/js/**/*"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ Encore.enableVueLoader(() => {}, {
|
|||||||
*/
|
*/
|
||||||
const config = Encore.getWebpackConfig()
|
const config = Encore.getWebpackConfig()
|
||||||
config.infrastructureLogging = {
|
config.infrastructureLogging = {
|
||||||
level: 'info',
|
level: 'debug',
|
||||||
}
|
}
|
||||||
config.stats = 'errors-warnings'
|
config.stats = 'errors-warnings'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user