diff --git a/app/Controllers/Http/UsersController.ts b/app/Controllers/Http/UsersController.ts index 5ce5f9c..392a95b 100644 --- a/app/Controllers/Http/UsersController.ts +++ b/app/Controllers/Http/UsersController.ts @@ -6,20 +6,20 @@ export default class UsersController { public async index({ inertia, bouncer }: HttpContextContract) { await bouncer.with('UserPolicy').authorize('index') - - const users = await Database + + const users = await Database .from('users') .select('id', 'username', 'is_admin') return inertia.render('Users/Index', { users }) } - public async create({ auth, inertia }: HttpContextContract) { - if(auth.user?.isAdmin) { - inertia.render('Users/Create') - } else { - - } + public async create({ inertia, bouncer }: HttpContextContract) { + await bouncer + .with('UserPolicy') + .authorize('create') + + return inertia.render('Users/Create') } public async store({}: HttpContextContract) {} diff --git a/components.d.ts b/components.d.ts index e6deafc..9237eb1 100644 --- a/components.d.ts +++ b/components.d.ts @@ -10,11 +10,8 @@ declare module 'vue' { NButton: typeof import('naive-ui')['NButton'] NCheckbox: typeof import('naive-ui')['NCheckbox'] NDataTable: typeof import('naive-ui')['NDataTable'] - NDivider: typeof import('naive-ui')['NDivider'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] - NGi: typeof import('naive-ui')['NGi'] - NGrid: typeof import('naive-ui')['NGrid'] NInput: typeof import('naive-ui')['NInput'] NMenu: typeof import('naive-ui')['NMenu'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] diff --git a/resources/js/components/MainNav.vue b/resources/js/components/MainNav.vue index 2830151..c31f8f7 100644 --- a/resources/js/components/MainNav.vue +++ b/resources/js/components/MainNav.vue @@ -10,6 +10,7 @@ \ No newline at end of file diff --git a/resources/js/components/UserForm.vue b/resources/js/components/UserForm.vue new file mode 100644 index 0000000..7fb13b3 --- /dev/null +++ b/resources/js/components/UserForm.vue @@ -0,0 +1,74 @@ + + + \ No newline at end of file diff --git a/resources/js/pages/Users/Create.vue b/resources/js/pages/Users/Create.vue index 27e0f69..5217917 100644 --- a/resources/js/pages/Users/Create.vue +++ b/resources/js/pages/Users/Create.vue @@ -1,3 +1,22 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/resources/js/pages/Users/Index.vue b/resources/js/pages/Users/Index.vue index 1188f8f..e945a9a 100644 --- a/resources/js/pages/Users/Index.vue +++ b/resources/js/pages/Users/Index.vue @@ -4,6 +4,16 @@ :messages="props.flashMessages" /> +
+ + Neuer Benutzer +
{ clickEdit(row.id) }, - renderIcon: () => { return h(NIcon, { component: Edit, size: 20 }) }, + renderIcon: () => { return renderIcon(Edit) }, }, ) arr[1] = h( @@ -70,7 +78,7 @@ const columns = [ circle: true, type: "error", onClick: () => { clickDelete(row.id) }, - renderIcon: () => { return h(NIcon, { component: Delete, size: 20 }) }, + renderIcon: () => { return renderIcon(Delete) }, }, ) return arr @@ -86,4 +94,8 @@ function clickDelete(id){ console.log("Delete clicked: "+id) } +function renderIcon(icon, className = "") { + return h(NIcon, { component: icon, class: className, size: 20 }) +} + \ No newline at end of file diff --git a/resources/js/types/User.ts b/resources/js/types/User.ts deleted file mode 100644 index 154c498..0000000 --- a/resources/js/types/User.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { DateTime } from 'luxon' - -export type User = { - id: Number, - username: String, - is_admin: Boolean, - updated_at: DateTime, - created_at: DateTime, - remember_me_token: String | null, -} \ No newline at end of file diff --git a/resources/js/util/index.js b/resources/js/util/index.js new file mode 100644 index 0000000..b8e041f --- /dev/null +++ b/resources/js/util/index.js @@ -0,0 +1,6 @@ +import { h } from "vue" +import { NIcon } from 'naive-ui' + +export function renderIcon(icon, className = "", size = 20) { + return h(NIcon, { component: icon, class: className, size: size }) +} \ No newline at end of file