-
Notifications
You must be signed in to change notification settings - Fork 15
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
1 parent
58daaaa
commit 4f85be9
Showing
9 changed files
with
436 additions
and
12 deletions.
There are no files selected for viewing
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
94 changes: 94 additions & 0 deletions
94
resources/js/console/screens/TranslationGroupsList/TranslationGroupsListScreen.vue
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,94 @@ | ||
<template> | ||
<Card> | ||
<Table | ||
title="Translation Groups" | ||
sub-title="The group of translations" | ||
:columns="columns" | ||
:records="records" | ||
> | ||
<template #action-buttons> | ||
<CreateNewTranslationGroup @created="loadRecords" /> | ||
</template> | ||
<template #record-actions="{ record }"> | ||
<div class="flex gap-x-2"> | ||
<UpdateTranslationGroupButton | ||
:translation-group="record" | ||
@updated="loadRecords" | ||
/> | ||
<DeleteTranslationGroupButton | ||
:translation-group="record" | ||
@deleted="loadRecords" | ||
/> | ||
</div> | ||
</template> | ||
<template #after-table> | ||
<Pagination | ||
v-if="paginationMeta" | ||
:from="paginationMeta.from || 0" | ||
:to="paginationMeta.to || 0" | ||
:total="paginationMeta.total" | ||
@next="loadRecords(page + 1)" | ||
@prev="loadRecords(page - 1)" | ||
/> | ||
</template> | ||
</Table> | ||
</Card> | ||
</template> | ||
|
||
<script setup> | ||
import Card from '../../components/Card/Card.vue'; | ||
import Table from '../../components/Table/Table.vue'; | ||
import { ref } from 'vue'; | ||
import DeleteTranslationGroupButton from './components/DeleteTranslationGroupButton.vue'; | ||
import UpdateTranslationGroupButton from './components/UpdateTranslationGroupButton.vue'; | ||
import { translationGroupRepository } from '../../repositories/translationGroup.repository'; | ||
import Pagination from '../../components/Pagination/Pagination.vue'; | ||
import CreateNewTranslationGroup from './components/CreateNewTranslationGroup.vue'; | ||
const columns = [ | ||
{ | ||
key: 'key', | ||
label: 'Key', | ||
headerClass: 'w-60', | ||
}, | ||
{ | ||
key: 'name', | ||
label: 'Name', | ||
headerClass: 'w-60', | ||
}, | ||
{ | ||
key: 'description', | ||
label: 'Description', | ||
}, | ||
{ | ||
key: 'created_at', | ||
label: 'Created At', | ||
transform(value) { | ||
return new Date(value).toLocaleString(); | ||
}, | ||
}, | ||
]; | ||
const records = ref([]); | ||
const page = ref(1); | ||
const paginationMeta = ref(null); | ||
const loadRecords = async () => { | ||
const data = await translationGroupRepository.index({ | ||
sortBy: 'name', | ||
}); | ||
if (!data) { | ||
return; | ||
} | ||
if (!data) { | ||
return; | ||
} | ||
records.value = [...data.data]; | ||
paginationMeta.value = { ...data.meta }; | ||
}; | ||
loadRecords(); | ||
</script> |
102 changes: 102 additions & 0 deletions
102
resources/js/console/screens/TranslationGroupsList/components/CreateNewTranslationGroup.vue
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,102 @@ | ||
<template> | ||
<Button @click="onClickCreate">Create New Translation Group</Button> | ||
<Modal | ||
title="Create New Translation Group" | ||
:is-open="isOpenModal" | ||
> | ||
<template #default> | ||
<div class="flex flex-col mt-4 gap-2"> | ||
<Input | ||
v-model="formFields.key" | ||
label="Unique Key" | ||
:disabled="isLoading" | ||
/> | ||
<Input | ||
v-model="formFields.name" | ||
label="Name" | ||
:disabled="isLoading" | ||
/> | ||
<Input | ||
v-model="formFields.description" | ||
label="Description (Optional)" | ||
:disabled="isLoading" | ||
/> | ||
</div> | ||
</template> | ||
<template #bottom-buttons> | ||
<div class="gap-1 flex"> | ||
<Button | ||
@click="onClickCloseModal" | ||
:disabled="isLoading" | ||
type="secondary" | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
@click="onClickSubmit" | ||
:disabled="isLoading" | ||
> | ||
Create | ||
</Button> | ||
</div> | ||
</template> | ||
</Modal> | ||
</template> | ||
|
||
<script setup> | ||
import Button from '../../../components/Button/Button.vue'; | ||
import Modal from '../../../components/Modal/Modal.vue'; | ||
import { ref } from 'vue'; | ||
import Input from '../../../components/Input/Input.vue'; | ||
import { notify } from '@kyvg/vue3-notification'; | ||
import { useLoading } from '../../../composable/useLoading'; | ||
import { useRouter } from 'vue-router'; | ||
import { translationGroupRepository } from '../../../repositories/translationGroup.repository'; | ||
const router = useRouter(); | ||
const isOpenModal = ref(false); | ||
const { isLoading, startLoading, stopLoading } = useLoading(); | ||
const emits = defineEmits(['created']); | ||
const getBlankFields = () => ({ | ||
key: '', | ||
name: '', | ||
description: '', | ||
}); | ||
const formFields = ref(getBlankFields()); | ||
const onClickCreate = () => { | ||
isOpenModal.value = true; | ||
}; | ||
const onClickCloseModal = () => { | ||
isOpenModal.value = false; | ||
formFields.value = getBlankFields(); | ||
}; | ||
const onClickSubmit = async () => { | ||
startLoading(); | ||
const data = await translationGroupRepository.create({ | ||
...formFields.value, | ||
}); | ||
stopLoading(); | ||
if (!data) { | ||
return; | ||
} | ||
notify({ | ||
type: 'success', | ||
title: 'Action OK', | ||
text: 'Language has been created.', | ||
}); | ||
onClickCloseModal(); | ||
emits('created'); | ||
}; | ||
</script> | ||
|
||
<style scoped></style> |
85 changes: 85 additions & 0 deletions
85
...rces/js/console/screens/TranslationGroupsList/components/DeleteTranslationGroupButton.vue
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,85 @@ | ||
<template> | ||
<Button | ||
type="error" | ||
@click="onClickDelete" | ||
:disabled="isLoading" | ||
> | ||
Delete | ||
</Button> | ||
<Modal | ||
:is-open="isOpenModal" | ||
title="Delete Confirmation" | ||
> | ||
<p class="mt-4 text-sm text-gray-500"> | ||
Are you sure you want to delete this Translation Group? The associated | ||
translations will be deleted too. | ||
</p> | ||
<template #bottom-buttons> | ||
<div class="flex gap-1"> | ||
<Button | ||
type="secondary" | ||
@click="isOpenModal = false" | ||
:disabled="isLoading" | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
type="error" | ||
@click="onClickConfirmDelete" | ||
:disabled="isLoading" | ||
> | ||
Delete | ||
</Button> | ||
</div> | ||
</template> | ||
</Modal> | ||
</template> | ||
|
||
<script setup> | ||
import Button from '../../../components/Button/Button.vue'; | ||
import { notify } from '@kyvg/vue3-notification'; | ||
import { useLoading } from '../../../composable/useLoading'; | ||
import Modal from '../../../components/Modal/Modal.vue'; | ||
import { ref } from 'vue'; | ||
import { translationGroupRepository } from '../../../repositories/translationGroup.repository'; | ||
const props = defineProps({ | ||
translationGroup: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
const emits = defineEmits(['deleted']); | ||
const { isLoading, startLoading, stopLoading } = useLoading(); | ||
const isOpenModal = ref(false); | ||
const onClickDelete = () => { | ||
isOpenModal.value = true; | ||
}; | ||
const onClickConfirmDelete = async () => { | ||
startLoading(); | ||
const data = await translationGroupRepository.destroy( | ||
props.translationGroup.uuid | ||
); | ||
stopLoading(); | ||
if (!data) { | ||
return; | ||
} | ||
notify({ | ||
type: 'success', | ||
title: 'Action OK', | ||
text: 'Translation Group has been deleted.', | ||
}); | ||
emits('deleted'); | ||
isOpenModal.value = false; | ||
}; | ||
</script> |
Oops, something went wrong.