forked from bayang/jelu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
652 additions
and
87 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<script setup lang="ts"> | ||
import { useTitle } from '@vueuse/core' | ||
import { ref } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
import { useStore } from 'vuex' | ||
import dataService from "../services/DataService" | ||
import { key } from '../store' | ||
import { setErrors } from '@formkit/vue' | ||
import { ObjectUtils } from "../utils/ObjectUtils"; | ||
import { useProgrammatic } from "@oruga-ui/oruga-next"; | ||
const { t } = useI18n({ | ||
inheritLocale: true, | ||
useScope: 'global' | ||
}) | ||
useTitle('Jelu | Users admin') | ||
const store = useStore(key) | ||
const { oruga } = useProgrammatic() | ||
const form = ref({'login' : '', 'password' : '', 'admin': false}) | ||
async function createUser(user: any) { | ||
console.log("create user") | ||
console.log(user) | ||
try { | ||
await dataService.createUser({"login" : user.login, "password": user.password, "isAdmin" : user.admin}) | ||
ObjectUtils.toast(oruga, "success", t('admin_user.user_saved', {name : user.login}), 4000) | ||
} catch (err: any) { | ||
setErrors('create-user-form', [], err.message) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="grid grid-cols-1 justify-center justify-items-center justify-self-center"> | ||
<h1 class="typewriter text-2xl mb-3 capitalize"> | ||
{{ t('admin_user.create_user') }} : | ||
</h1> | ||
<div class="flex flex-row justify-center basis-10/12 sm:basis-1/3"> | ||
<div class=""> | ||
<FormKit | ||
id="create-user-form" | ||
v-slot="{ state: { valid } }" | ||
v-model="form" | ||
type="form" | ||
:actions="false" | ||
message-class="text-error-content" | ||
messages-class="alert alert-error mt-2" | ||
@submit="createUser" | ||
> | ||
<FormKit | ||
type="text" | ||
name="login" | ||
:label="t('admin_user.login')" | ||
placeholder="joe123" | ||
validation="required|length:3" | ||
/> | ||
<FormKit | ||
type="password" | ||
name="password" | ||
:label="t('admin_user.password')" | ||
validation="required|length:3" | ||
:placeholder="t('admin_user.password')" | ||
/> | ||
<FormKit | ||
type="password" | ||
name="password_confirm" | ||
:label="t('admin_user.password_confirm')" | ||
:placeholder="t('admin_user.password_confirm')" | ||
validation="required|confirm" | ||
/> | ||
<FormKit | ||
type="checkbox" | ||
:help="t('admin_user.admin_help')" | ||
:label="t('admin_user.admin')" | ||
name="admin" | ||
/> | ||
<FormKit | ||
type="submit" | ||
:disabled="!valid" | ||
input-class="btn-accent" | ||
> | ||
{{ t('admin_user.create_user') }} | ||
</FormKit> | ||
</FormKit> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,7 +398,7 @@ getBooks() | |
/> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
<style scoped> | ||
label { | ||
margin: 0 0.5em; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Create some re-useable definitions because | ||
// many input types are identical in how | ||
// we want to style them. | ||
const textClassification = { | ||
label: 'label label-text font-semibold formkit-invalid:text-error capitalize', | ||
wrapper: ` | ||
form-control | ||
`, | ||
input: 'input input-primary', | ||
} | ||
const boxClassification = { | ||
outer: ' mt-2', | ||
inner: 'self-center flex items-center content-center', | ||
input: 'checkbox checkbox-primary', | ||
fieldset: 'max-w-md border border-gray-400 rounded-md px-2 pb-1', | ||
legend: 'font-bold text-sm', | ||
wrapper: 'flex items-center content-center cursor-pointer mb-0', | ||
label: 'label label-text mt-1 mx-1 capitalize self-center' | ||
} | ||
const buttonClassification = { | ||
input: 'btn' | ||
} | ||
|
||
// export our definitions using our above | ||
// templates and declare one-offs and | ||
// overrides as needed. | ||
export default { | ||
// the global key will apply to all inputs | ||
global: { | ||
help: 'label label-text mt-0', | ||
message: 'text-error' | ||
}, | ||
button: buttonClassification, | ||
color: { | ||
label: 'block mb-1 font-bold text-sm', | ||
input: 'w-16 h-8 appearance-none cursor-pointer border border-gray-300 rounded-md mb-2 p-1' | ||
}, | ||
date: textClassification, | ||
'datetime-local': textClassification, | ||
checkbox: boxClassification, | ||
email: textClassification, | ||
file: { | ||
label: 'block mb-1 font-bold text-sm', | ||
inner: 'max-w-md cursor-pointer', | ||
input: 'text-gray-600 text-sm mb-1 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:bg-blue-500 file:text-white hover:file:bg-blue-600', | ||
noFiles: 'block text-gray-800 text-sm mb-1', | ||
fileItem: 'block flex text-gray-800 text-sm mb-1', | ||
removeFiles: 'ml-auto text-blue-500 text-sm' | ||
}, | ||
month: textClassification, | ||
number: textClassification, | ||
password: textClassification, | ||
radio: { | ||
...boxClassification, | ||
input: boxClassification.input.replace('rounded-sm', 'rounded-full'), | ||
}, | ||
range: { | ||
inner: 'max-w-md', | ||
input: 'form-range appearance-none w-full h-2 p-0 bg-gray-200 rounded-full focus:outline-none focus:ring-0 focus:shadow-none' | ||
}, | ||
search: textClassification, | ||
select: textClassification, | ||
submit: buttonClassification, | ||
tel: textClassification, | ||
text: textClassification, | ||
textarea: { | ||
...textClassification, | ||
input: 'block w-full h-32 px-3 border-none text-base text-gray-700 placeholder-gray-400 focus:shadow-outline', | ||
}, | ||
time: textClassification, | ||
url: textClassification, | ||
week: textClassification, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.