Skip to content

Commit

Permalink
assetLicenceGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Maco2703 committed Apr 11, 2024
1 parent 45cfcd3 commit 19d867a
Show file tree
Hide file tree
Showing 27 changed files with 994 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/components/system/sidebar/SidebarMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ const { t } = useI18n()
data-cy="asset-licence-settings"
/>
</Acl>
<Acl :permission="ACL.DAM_ASSET_LICENCE_GROUP_UI">
<VListItem
:to="{ name: ROUTE.DAM.ASSET_LICENCE_GROUP.LIST }"
prepend-icon="mdi-account-key"
:title="t('sidebar.settings.assetLicenceGroups')"
data-cy="asset-licence-group-settings"
/>
</Acl>
<Acl :permission="ACL.DAM_AUTHOR_UI">
<VListItem
:to="{ name: ROUTE.DAM.AUTHOR.LIST }"
Expand Down
14 changes: 14 additions & 0 deletions src/components/system/sidebar/SidebarRail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ const { t } = useI18n()
</VTooltip>
</VListItem>
</Acl>
<Acl :permission="ACL.DAM_ASSET_LICENCE_GROUP_UI">
<VListItem
:to="{ name: ROUTE.DAM.ASSET_LICENCE_GROUP.LIST }"
prepend-icon="mdi-account-key"
data-cy="asset-licence-group-settings"
>
<VTooltip
location="right"
activator="parent"
>
{{ t('sidebar.settings.assetLicenceGroups') }}
</VTooltip>
</VListItem>
</Acl>
<Acl :permission="ACL.DAM_AUTHOR_UI">
<VListItem
:to="{ name: ROUTE.DAM.AUTHOR.LIST }"
Expand Down
2 changes: 2 additions & 0 deletions src/locales/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sidebar from '@/locales/sk/sidebar.json'
import system from '@/locales/sk/system.json'
import asset from '@/locales/sk/coreDam/asset.json'
import assetLicence from '@/locales/sk/coreDam/assetLicence.json'
import assetLicenceGroup from '@/locales/sk/coreDam/assetLicenceGroup.json'
import author from '@/locales/sk/coreDam/author.json'
import distribution from '@/locales/sk/coreDam/distribution.json'
import distributionCategory from '@/locales/sk/coreDam/distributionCategory.json'
Expand Down Expand Up @@ -32,6 +33,7 @@ export default {
coreDam: {
asset,
assetLicence,
assetLicenceGroup,
author,
distribution,
distributionCategory,
Expand Down
5 changes: 5 additions & 0 deletions src/locales/sk/breadcrumb.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"detail": "Licencie",
"edit": "Licencie"
},
"assetLicenceGroup": {
"list": "Skupiny licencií assetov",
"detail": "Skupina licencie",
"edit": "Skupina licencie"
},
"author": {
"list": "Autori",
"detail": "Autor",
Expand Down
14 changes: 14 additions & 0 deletions src/locales/sk/coreDam/assetLicenceGroup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"model": {
"id": "ID",
"name": "Meno",
"extSystem": "Externý systém",
"licences": "Licencie"
},
"filter": {
"id": "ID"
},
"meta": {
"create": "Vytvoriť skupinu licencií"
}
}
1 change: 1 addition & 0 deletions src/locales/sk/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"anzuUser": "Oprávnenia používateľov",
"extSystems": "Externé systémy",
"assetLicences": "Licencie assetov",
"assetLicenceGroups": "Skupiny Licencií assetov",
"keywords": "Kľúčové slová",
"authors": "Autori",
"distributionCategory": "Kategórie distribúcií",
Expand Down
25 changes: 25 additions & 0 deletions src/model/coreDam/factory/AssetLicenceGroupFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { SYSTEM_CORE_DAM } from '@/model/systems'
import { dateTimeNow } from '@anzusystems/common-admin'
import { ENTITY } from '@/services/api/coreDam/assetLicenceGroupApi'
import type { AssetLicenceGroup } from '@/types/coreDam/AssetLicenceGroup'

export function useAssetLicenceGroupFactory() {
const createDefault = (): AssetLicenceGroup => {
return {
id: 0,
name: '',
extSystem: null,
licences: [],
createdAt: dateTimeNow(),
modifiedAt: dateTimeNow(),
createdBy: 0,
modifiedBy: 0,
_resourceName: ENTITY,
_system: SYSTEM_CORE_DAM,
}
}

return {
createDefault,
}
}
17 changes: 17 additions & 0 deletions src/model/coreDam/filter/AssetLicenceGroupFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { makeFilterHelper } from '@anzusystems/common-admin'
import { reactive } from 'vue'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import { ENTITY } from '@/services/api/coreDam/assetLicenceGroupApi'

const makeFilter = makeFilterHelper(SYSTEM_CORE_DAM, ENTITY)

const filter = reactive({
id: {
...makeFilter({ name: 'id' }),
},
})

export function useAssetLicenceGroupListFilter() {
return filter
}

2 changes: 2 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { videoShowRoutes } from '@/router/routes/coreDam/videoShow'
import { jobRoutes } from '@/router/routes/coreDam/job'
import HomepageView from '@/views/system/HomepageView.vue'
import { ANotFoundView } from '@anzusystems/common-admin'
import { assetLicenceGroupRoutes } from '@/router/routes/coreDam/assetLicenceGroup'

const vueRouter = createRouter({
history: createWebHistory(),
Expand All @@ -38,6 +39,7 @@ const vueRouter = createRouter({
...userRoutes,
...extSystemRoutes,
...assetLicenceRoutes,
...assetLicenceGroupRoutes,
...permissionGroupRoutes,
...anzuUserRoutes,
...authorRoutes,
Expand Down
5 changes: 5 additions & 0 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const routes = {
DETAIL: 'assetLicence_detail',
EDIT: 'assetLicence_edit',
},
ASSET_LICENCE_GROUP: {
LIST: 'assetLicenceGroup_list',
DETAIL: 'assetLicenceGroup_detail',
EDIT: 'assetLicenceGroup_edit',
},
AUTHOR: {
LIST: 'author_list',
DETAIL: 'author_detail',
Expand Down
51 changes: 51 additions & 0 deletions src/router/routes/coreDam/assetLicenceGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ROUTE } from '@/router/routes'
import { ACL } from '@/types/Permission'
import type { RouteRecordRaw } from 'vue-router'
import { AEmptyRouterView } from '@anzusystems/common-admin'

export const assetLicenceGroupRoutes: RouteRecordRaw[] = [
{
path: '/asset-licence-group',
component: AEmptyRouterView,
meta: {
requiresAuth: true,
requiredPermissions: [],
layout: 'AppLayoutDrawer',
breadcrumbT: 'breadcrumb.coreDam.assetLicenceGroup.list',
},
children: [
{
path: '',
name: ROUTE.DAM.ASSET_LICENCE_GROUP.LIST,
component: () => import('@/views/coreDam/assetLicenceGroup/AssetLicenceGroupListView.vue'),
meta: {
requiresAuth: true,
requiredPermissions: [ACL.DAM_ASSET_LICENCE_GROUP_VIEW],
layout: 'AppLayoutDrawer',
},
},
{
path: ':id(\\d+)/edit',
name: ROUTE.DAM.ASSET_LICENCE_GROUP.EDIT,
component: () => import('@/views/coreDam/assetLicenceGroup/AssetLicenceGroupEditView.vue'),
meta: {
requiresAuth: true,
requiredPermissions: [ACL.DAM_ASSET_LICENCE_GROUP_VIEW, ACL.DAM_ASSET_LICENCE_GROUP_UPDATE],
layout: 'AppLayoutDrawer',
breadcrumbT: 'breadcrumb.coreDam.assetLicenceGroup.edit',
},
},
{
path: ':id(\\d+)',
name: ROUTE.DAM.ASSET_LICENCE_GROUP.DETAIL,
component: () => import('@/views/coreDam/assetLicenceGroup/AssetLicenceGroupDetailView.vue'),
meta: {
requiresAuth: true,
requiredPermissions: [ACL.DAM_ASSET_LICENCE_GROUP_VIEW],
layout: 'AppLayoutDrawer',
breadcrumbT: 'breadcrumb.coreDam.assetLicenceGroup.detail',
},
},
],
},
]
46 changes: 46 additions & 0 deletions src/services/api/coreDam/assetLicenceGroupApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { damClient } from '@/services/api/clients/damClient'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import {
apiCreateOne,
apiFetchByIds, apiFetchList,
apiFetchOne,
apiUpdateOne,
type FilterBag,
type IntegerId, type Pagination
} from '@anzusystems/common-admin'
import type { AssetLicenceGroup } from '@/types/coreDam/AssetLicenceGroup'

const END_POINT = '/adm/v1/asset-licence-group'
export const ENTITY = 'assetLicenceGroup'

export const fetchAssetLicenceGroupListByIds = (ids: IntegerId[]) =>
apiFetchByIds<AssetLicenceGroup[]>(
damClient,
ids,
END_POINT,
{},
SYSTEM_CORE_DAM,
ENTITY,
{},
true
)

export const fetchAssetLicenceGroupList = (pagination: Pagination, filterBag: FilterBag) =>
apiFetchList<AssetLicenceGroup[]>(
damClient,
END_POINT,
{},
pagination,
filterBag,
SYSTEM_CORE_DAM,
ENTITY
)

export const createAssetLicenceGroup = (data: AssetLicenceGroup) =>
apiCreateOne<AssetLicenceGroup>(damClient, data, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)

export const updateAssetLicenceGroup = (id: IntegerId, data: AssetLicenceGroup) =>
apiUpdateOne<AssetLicenceGroup>(damClient, data, END_POINT + '/:id', { id }, SYSTEM_CORE_DAM, ENTITY)

export const fetchAssetLicenceGroup = (id: IntegerId) =>
apiFetchOne<AssetLicenceGroup>(damClient, END_POINT + '/:id', { id }, SYSTEM_CORE_DAM, ENTITY)
23 changes: 23 additions & 0 deletions src/stores/coreDam/assetLicenceGroupStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { acceptHMRUpdate, defineStore } from 'pinia'
import { useAssetLicenceGroupFactory } from '@/model/coreDam/factory/AssetLicenceGroupFactory'
import type { AssetLicenceGroup } from '@/types/coreDam/AssetLicenceGroup'
import { ref } from 'vue'

export const useAssetLicenceGroupOneStore = defineStore('assetLicenceGroupOneStore', () => {
const { createDefault } = useAssetLicenceGroupFactory()

const assetLicenceGroup = ref<AssetLicenceGroup>(createDefault())

function reset() {
assetLicenceGroup.value = createDefault()
}

return {
assetLicenceGroup,
reset
}
})

if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useAssetLicenceGroupOneStore, import.meta.hot))
}
5 changes: 5 additions & 0 deletions src/types/Permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const ACL = {
DAM_ASSET_LICENCE_UPDATE: 'dam_assetLicence_update',
DAM_ASSET_LICENCE_VIEW: 'dam_assetLicence_view',
DAM_ASSET_LICENCE_LIST: 'dam_assetLicence_list',
DAM_ASSET_LICENCE_GROUP_CREATE: 'dam_assetLicenceGroup_create',
DAM_ASSET_LICENCE_GROUP_UPDATE: 'dam_assetLicenceGroup_update',
DAM_ASSET_LICENCE_GROUP_VIEW: 'dam_assetLicenceGroup_view',
DAM_ASSET_LICENCE_GROUP_LIST: 'dam_assetLicenceGroup_list',
DAM_USER_VIEW: 'dam_user_view',
DAM_USER_CREATE: 'dam_user_create',
DAM_USER_UPDATE: 'dam_user_update',
Expand Down Expand Up @@ -81,6 +85,7 @@ export const ACL = {
DAM_PERMISSION_GROUP_UI: 'dam_permissionGroup_ui',
DAM_EXT_SYSTEM_UI: 'dam_extSystem_ui',
DAM_ASSET_LICENCE_UI: 'dam_assetLicence_ui',
DAM_ASSET_LICENCE_GROUP_UI: 'dam_assetLicenceGroup_ui',
DAM_AUTHOR_UI: 'dam_author_ui',
DAM_KEYWORD_UI: 'dam_keyword_ui',
DAM_DISTRIBUTION_CATEGORY_UI: 'dam_distributionCategory_ui',
Expand Down
13 changes: 13 additions & 0 deletions src/types/coreDam/AssetLicenceGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type {
AnzuUserAndTimeTrackingAware,
IntegerId,
IntegerIdNullable,
ResourceNameSystemAware
} from '@anzusystems/common-admin'

export interface AssetLicenceGroup extends AnzuUserAndTimeTrackingAware, ResourceNameSystemAware {
id: IntegerId
name: string
extSystem: IntegerIdNullable
licences: IntegerId[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ const { getCachedAssetLicence } = useCachedAssetLicences()
:id="id"
:get-cached-fn="getCachedAssetLicence"
:route="ROUTE.DAM.ASSET_LICENCE.DETAIL"
display-text-path="title"
display-text-path="name"
/>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script lang="ts" setup>
import { AActionCloseButton, AActionSaveButton, ACard, stringToInt } from '@anzusystems/common-admin'
import { onBeforeUnmount, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { ROUTE } from '@/router/routes'
import { useAssetLicenceGroupEditActions } from '@/views/coreDam/assetLicenceGroup/composables/assetLicenceGroupActions'
import AssetLicenceGroupEditForm from '@/views/coreDam/assetLicenceGroup/components/AssetLicenceGroupEditForm.vue'
import ActionbarWrapper from '@/components/wrappers/ActionbarWrapper.vue'
const route = useRoute()
const id = stringToInt(route.params.id)
const {
detailLoading,
saveButtonLoading,
saveAndCloseButtonLoading,
fetchData,
resetStore,
onUpdate,
assetLicenceGroup
} =
useAssetLicenceGroupEditActions()
const getData = () => {
fetchData(id)
}
onMounted(() => {
getData()
})
onBeforeUnmount(() => {
resetStore()
})
</script>

<template>
<ActionbarWrapper :last-breadcrumb-title="assetLicenceGroup.name">
<template #buttons>
<AActionSaveButton
v-if="!detailLoading"
:loading="saveButtonLoading"
:disabled="saveAndCloseButtonLoading"
@save-record="onUpdate"
/>
<AActionCloseButton :route-name="ROUTE.DAM.ASSET_LICENCE_GROUP.LIST" />
</template>
</ActionbarWrapper>

<ACard :loading="detailLoading">
<VCardText>
<AssetLicenceGroupEditForm />
</VCardText>
</ACard>
</template>
Loading

0 comments on commit 19d867a

Please sign in to comment.