Skip to content

Commit

Permalink
update to latest common admin
Browse files Browse the repository at this point in the history
  • Loading branch information
volar committed Dec 15, 2023
1 parent 4c1f498 commit 2e0e7f8
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"cy:open": "CYPRESS_CACHE_FOLDER='node_modules/.cache/Cypress' yarn cypress open -C cypress/config/cypress.config.ts"
},
"dependencies": {
"@anzusystems/common-admin": "1.40.0-alpha19",
"@anzusystems/common-admin": "1.40.0-alpha20",
"@mdi/font": "7.3.67",
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
Expand Down
4 changes: 2 additions & 2 deletions src/composables/system/currentExtSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import type { DamExtSystem } from '@anzusystems/common-admin'
import { isDocId, isString, useDamConfigState, useDamCurrentUser } from '@anzusystems/common-admin'
import { fetchExtSystem } from '@/services/api/coreDam/extSystemApi'
import { fetchAssetLicence } from '@/services/api/coreDam/assetLicenceApi'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'
import { fetchAsset } from '@/services/api/coreDam/assetApi'
import { useAssetDetailStore } from '@/stores/coreDam/assetDetailStore'

const currentExtSystemId = ref(0)
const currentExtSystem = ref<DamExtSystem>()

const currentAssetLicence = ref<AssetLicence>()
const currentAssetLicence = ref<DamAssetLicence>()
const currentAssetLicenceId = ref(0)

export const initCurrentExtSystemAndLicence = (loadFromAsset = false, assetId: string | undefined = undefined) => {
Expand Down
4 changes: 2 additions & 2 deletions src/model/coreDam/factory/AssetLicenceFactory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SYSTEM_CORE_DAM } from '@/model/systems'
import { dateTimeNow } from '@anzusystems/common-admin'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'
import { ENTITY } from '@/services/api/coreDam/assetLicenceApi'

export function useAssetLicenceFactory() {
const createDefault = (): AssetLicence => {
const createDefault = (): DamAssetLicence => {
return {
id: 0,
name: '',
Expand Down
16 changes: 8 additions & 8 deletions src/services/api/coreDam/assetLicenceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import { damClient } from '@/services/api/clients/damClient'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import type { FilterBag, Pagination } from '@anzusystems/common-admin'
import { apiCreateOne, apiFetchByIds, apiFetchList, apiFetchOne, apiUpdateOne } from '@anzusystems/common-admin'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'

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

export const fetchAssetLicenceListByIds = (ids: number[]) =>
apiFetchByIds<AssetLicence[]>(damClient, ids, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)
apiFetchByIds<DamAssetLicence[]>(damClient, ids, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)

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

export const createAssetLicence = (data: AssetLicence) =>
apiCreateOne<AssetLicence>(damClient, data, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)
export const createAssetLicence = (data: DamAssetLicence) =>
apiCreateOne<DamAssetLicence>(damClient, data, END_POINT, {}, SYSTEM_CORE_DAM, ENTITY)

export const updateAssetLicence = (id: number, data: AssetLicence) =>
apiUpdateOne<AssetLicence>(damClient, data, END_POINT + '/:id', { id }, SYSTEM_CORE_DAM, ENTITY)
export const updateAssetLicence = (id: number, data: DamAssetLicence) =>
apiUpdateOne<DamAssetLicence>(damClient, data, END_POINT + '/:id', { id }, SYSTEM_CORE_DAM, ENTITY)

export const fetchAssetLicence = (id: number) =>
apiFetchOne<AssetLicence>(damClient, END_POINT + '/:id', { id }, SYSTEM_CORE_DAM, ENTITY)
apiFetchOne<DamAssetLicence>(damClient, END_POINT + '/:id', { id }, SYSTEM_CORE_DAM, ENTITY)
6 changes: 3 additions & 3 deletions src/stores/coreDam/assetLicenceStore.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { acceptHMRUpdate, defineStore } from 'pinia'
import { useAssetLicenceFactory } from '@/model/coreDam/factory/AssetLicenceFactory'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'

const { createDefault } = useAssetLicenceFactory()

interface State {
assetLicence: AssetLicence
assetLicence: DamAssetLicence
}

export const useAssetLicenceOneStore = defineStore('assetLicenceOneStore', {
state: (): State => ({
assetLicence: createDefault(),
}),
actions: {
setAssetLicence(assetLicence: AssetLicence) {
setAssetLicence(assetLicence: DamAssetLicence) {
this.assetLicence = assetLicence
},
reset() {
Expand Down
16 changes: 0 additions & 16 deletions src/types/coreDam/AssetLicence.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ACreateDialog, AFormTextField, ARow, ASystemEntityScope } from '@anzusy
import { SYSTEM_CORE_DAM } from '@/model/systems'
import ExtSystemRemoteAutocomplete from '@/views/coreDam/extSystem/components/ExtSystemRemoteAutocomplete.vue'
import { useAssetLicenceFactory } from '@/model/coreDam/factory/AssetLicenceFactory'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'
import { useAssetLicenceValidation } from '@/views/coreDam/assetLicence/composables/assetLicenceValidation'
import { createAssetLicence, ENTITY } from '@/services/api/coreDam/assetLicenceApi'
Expand All @@ -20,11 +20,11 @@ withDefaults(
}
)
const emit = defineEmits<{
(e: 'onSuccess', data: AssetLicence): void
(e: 'onSuccess', data: DamAssetLicence): void
}>()
const { createDefault } = useAssetLicenceFactory()
const assetLicence = ref<AssetLicence>(createDefault())
const assetLicence = ref<DamAssetLicence>(createDefault())
const dialog = ref(false)
const { v$ } = useAssetLicenceValidation(assetLicence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import AssetLicenceFilter from '@/views/coreDam/assetLicence/components/AssetLic
import { useAssetLicenceListFilter } from '@/model/coreDam/filter/AssetLicenceFilter'
import CachedExtSystemChip from '@/views/coreDam/extSystem/components/CachedExtSystemChip.vue'
import { ACL, type AclValue } from '@/types/Permission'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'
type DatatableItem = AssetLicence
type DatatableItem = DamAssetLicence
const router = useRouter()
const filter = useAssetLicenceListFilter()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref } from 'vue'
import type { FilterBag, Pagination, ValueObjectOption } from '@anzusystems/common-admin'
import { useAlerts } from '@anzusystems/common-admin'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'
import { useAssetLicenceOneStore } from '@/stores/coreDam/assetLicenceStore'
import { storeToRefs } from 'pinia'
import {
Expand All @@ -26,7 +26,7 @@ const saveButtonLoading = ref(false)
const saveAndCloseButtonLoading = ref(false)

export const useAssetLicenceListActions = () => {
const listItems = ref<AssetLicence[]>([])
const listItems = ref<DamAssetLicence[]>([])

const fetchList = async (pagination: Pagination, filterBag: FilterBag) => {
listLoading.value = true
Expand Down Expand Up @@ -129,8 +129,8 @@ export const useAssetLicenceEditActions = () => {
}

export const useAssetLicenceSelectActions = () => {
const mapToValueObjectOption = (assetLicences: AssetLicence[]): ValueObjectOption<number>[] => {
return assetLicences.map((assetLicence: AssetLicence) => ({
const mapToValueObjectOption = (assetLicences: DamAssetLicence[]): ValueObjectOption<number>[] => {
return assetLicences.map((assetLicence: DamAssetLicence) => ({
title: assetLicence.name,
value: assetLicence.id,
}))
Expand All @@ -151,8 +151,8 @@ export const useAssetLicenceSelectActions = () => {
}

export const useAssetLicenceByExtIdSelectActions = () => {
const mapToValueObjectOption = (assetLicences: AssetLicence[]): ValueObjectOption<number>[] => {
return assetLicences.map((assetLicence: AssetLicence) => ({
const mapToValueObjectOption = (assetLicences: DamAssetLicence[]): ValueObjectOption<number>[] => {
return assetLicences.map((assetLicence: DamAssetLicence) => ({
title: assetLicence.extId,
value: assetLicence.id,
}))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Ref } from 'vue'
import { computed } from 'vue'
import useVuelidate from '@vuelidate/core'
import type { AssetLicence } from '@/types/coreDam/AssetLicence'
import type { DamAssetLicence } from '@anzusystems/common-admin'
import { useValidate } from '@anzusystems/common-admin'

const { required, minLength } = useValidate()

export function useAssetLicenceValidation(assetLicence: Ref<AssetLicence>) {
export function useAssetLicenceValidation(assetLicence: Ref<DamAssetLicence>) {
const rules = computed(() => ({
assetLicence: {
name: {
Expand Down
19 changes: 9 additions & 10 deletions src/views/coreDam/assetLicence/composables/cachedAssetLicences.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import type { AssetLicence, AssetLicenceMinimal } from '@/types/coreDam/AssetLicence'
import { fetchAssetLicenceListByIds } from '@/services/api/coreDam/assetLicenceApi'
import type { IntegerId } from '@anzusystems/common-admin'
import type { DamAssetLicence, DamAssetLicenceMinimal, IntegerId } from '@anzusystems/common-admin'
import { defineCached } from '@anzusystems/common-admin'
import { fetchAssetLicenceListByIds } from '@/services/api/coreDam/assetLicenceApi'

const mapFullToMinimal = (assetLicence: AssetLicence): AssetLicenceMinimal => ({
const mapFullToMinimal = (assetLicence: DamAssetLicence): DamAssetLicenceMinimal => ({
id: assetLicence.id,
name: assetLicence.name,
})

const mapIdToMinimal = (id: IntegerId): AssetLicenceMinimal => {
const mapIdToMinimal = (id: IntegerId): DamAssetLicenceMinimal => {
return { id: id, name: '' }
}

const { cache, fetch, add, addManual, has, get, isLoaded } = defineCached<IntegerId, AssetLicence, AssetLicenceMinimal>(
mapFullToMinimal,
mapIdToMinimal,
fetchAssetLicenceListByIds
)
const { cache, fetch, add, addManual, has, get, isLoaded } = defineCached<
IntegerId,
DamAssetLicence,
DamAssetLicenceMinimal
>(mapFullToMinimal, mapIdToMinimal, fetchAssetLicenceListByIds)

export const useCachedAssetLicences = () => {
return {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ __metadata:
languageName: node
linkType: hard

"@anzusystems/common-admin@npm:1.40.0-alpha19":
version: 1.40.0-alpha19
resolution: "@anzusystems/common-admin@npm:1.40.0-alpha19"
"@anzusystems/common-admin@npm:1.40.0-alpha20":
version: 1.40.0-alpha20
resolution: "@anzusystems/common-admin@npm:1.40.0-alpha20"
peerDependencies:
"@vuelidate/core": 2.0.3
"@vuelidate/validators": 2.0.4
Expand All @@ -41,7 +41,7 @@ __metadata:
optional: true
vue-router:
optional: true
checksum: fc3780f816fd906c2373fd9f59dda70fc4340d14654ce9689052fa77ce9efc0993a2f957683b6cf374f12bdb214da3abc4c0d0cc05295b2a3fecefe70d907142
checksum: bfdb2bb5ad561a2642af8dda9e5dcee2b3adc9ee4fc7816d87abebf2ae5e0c776054caed92f09476140de664f8beaf22d0a9a84f35f416ccaeb3914f4892f656
languageName: node
linkType: hard

Expand Down Expand Up @@ -1572,7 +1572,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "adam-admin@workspace:."
dependencies:
"@anzusystems/common-admin": "npm:1.40.0-alpha19"
"@anzusystems/common-admin": "npm:1.40.0-alpha20"
"@cypress/grep": "npm:^4.0.1"
"@intlify/unplugin-vue-i18n": "npm:^1.6.0"
"@mdi/font": "npm:7.3.67"
Expand Down

0 comments on commit 2e0e7f8

Please sign in to comment.