Skip to content

Commit

Permalink
RISDEV-6143 Add 'documentType category (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-deazevedo authored Jan 17, 2025
1 parent aafb8f1 commit 37e876a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 13 deletions.
10 changes: 6 additions & 4 deletions frontend/e2e/RubrikenPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ test(
amtlicheLangüberschriftElement.fill('my long title')
await expect(amtlicheLangüberschriftElement).toHaveValue('my long title')

// const dokumentTyp = page.getByText('Dokumenttyp')
// await expect(dokumentTyp).toHaveCount(1)
// dokumentTyp.selectOption({ label: 'VR' }) // select by visible text option
// await expect(dokumentTyp).toHaveValue('vr') // confirm selection by value
const dokumentTyp = page.getByText('Dokumenttyp')
await expect(dokumentTyp).toHaveCount(1)
await dokumentTyp.fill('V')
await expect(page.getByText('VR')).toHaveCount(1)
await page.getByText('VR').click()
await expect(dokumentTyp).toHaveValue('VR') // confirm selection by value

const inkrafttretedatumElement = page.getByText('Datum des Inkrafttretens *')
await expect(inkrafttretedatumElement).toHaveCount(1)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/input/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LabelPosition } from '@/components/input/InputField.vue'
import LegalPeriodical from '@/domain/legalPeriodical'
import type { Court } from '@/domain/documentUnit'
import type { Court, DocumentType } from '@/domain/documentUnit'
import type { Ref } from 'vue'
import type { ComboboxResult } from '@/domain/comboboxResult.ts'

Expand Down Expand Up @@ -118,7 +118,7 @@ export interface DropdownInputField extends BaseInputField {
}

//COMBOBOX
export type ComboboxInputModelType = LegalPeriodical | Court
export type ComboboxInputModelType = LegalPeriodical | Court | DocumentType

export type ComboboxItem = {
label: string
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/domain/documentUnit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type DocumentationOffice from './documentationOffice'

export type DocumentType = {
uuid?: string
jurisShortcut: string
label: string
}

export type Court = {
type?: string
location?: string
Expand Down
22 changes: 17 additions & 5 deletions frontend/src/routes/documentUnit/[documentNumber]/RubrikenPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const selectedCourt = ref()
const zitierdatum = ref()
const inkrafttretedatum = ref()
const ausserkrafttretedatum = ref()
const selectedDocumentType = ref()
</script>

<template>
Expand All @@ -23,7 +24,7 @@ const ausserkrafttretedatum = ref()
<DateInput
id="zitierdatum"
v-model="zitierdatum"
aria-label="Zitierdatum"
ariaLabel="Zitierdatum"
class="ds-input-medium"
></DateInput>
</InputField>
Expand All @@ -39,7 +40,7 @@ const ausserkrafttretedatum = ref()
</InputField>
</div>
</div>
<div class="flex flex-col">
<div class="flex flex-row gap-24">
<InputField id="langue" label="Amtl. Langüberschrift *">
<Textarea
id="langue"
Expand All @@ -50,7 +51,17 @@ const ausserkrafttretedatum = ref()
/>
</InputField>
</div>

<div class="border-b-1 border-b-gray-400"></div>
<div class="flex flex-row gap-24 w-[calc(50%-10px)]">
<InputField id="documentType" label="Dokumenttyp *">
<ComboboxInput
id="documentType"
v-model="selectedDocumentType"
aria-label="Dokumenttyp"
:item-service="ComboboxItemService.getDocumentTypes"
></ComboboxInput>
</InputField>
</div>
<div class="flex flex-col">
<div class="flex flex-row gap-24">
<InputField
Expand All @@ -61,7 +72,7 @@ const ausserkrafttretedatum = ref()
<DateInput
id="inkrafttretedatum"
v-model="inkrafttretedatum"
aria-label="Inkrafttretedatum"
ariaLabel="Inkrafttretedatum"
class="ds-input-medium"
></DateInput>
</InputField>
Expand All @@ -73,12 +84,13 @@ const ausserkrafttretedatum = ref()
<DateInput
id="ausserkrafttretedatum"
v-model="ausserkrafttretedatum"
aria-label="Ausserkrafttretedatum"
ariaLabel="Ausserkrafttretedatum"
class="ds-input-medium"
></DateInput>
</InputField>
</div>
</div>
<div class="mt-4">* Pflichtfelder für die Veröffentlichung</div>
</div>
</div>
</template>
22 changes: 22 additions & 0 deletions frontend/src/services/comboboxItemService.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it } from 'vitest'
import ComboboxItemService from '@/services/comboboxItemService.ts'
import { ref } from 'vue'
import type { ComboboxItem } from '@/components/input/types.ts'

describe('comboboxItemService', () => {
it('getDocumentTypes.data', () => {
const documentTypes = ComboboxItemService.getDocumentTypes(ref(''))

expect(documentTypes.data.value as ComboboxItem[]).toEqual(
expect.arrayContaining([<ComboboxItem>{ label: 'VR', value: { label: 'VR' } }]),
)
})

it('getDocumentTypes.execute', async () => {
const documentTypes = ComboboxItemService.getDocumentTypes(ref(''))

const executionResult = await documentTypes.execute()

expect(executionResult.data.value).toEqual(documentTypes.data.value)
})
})
20 changes: 18 additions & 2 deletions frontend/src/services/comboboxItemService.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { Ref } from 'vue'
import type { ComboboxItem } from '@/components/input/types'
import LegalPeriodical from '@/domain/legalPeriodical.ts'
import type { Court } from '@/domain/documentUnit'
import type { Court, DocumentType } from '@/domain/documentUnit'
import type { ComboboxResult } from '@/domain/comboboxResult.ts'
import { computed, ref } from 'vue'

type ComboboxItemService = {
export type ComboboxItemService = {
getLegalPeriodicals: (filter: Ref<string | undefined>) => ComboboxResult<ComboboxItem[]>
getCourts: (filter: Ref<string | undefined>) => ComboboxResult<ComboboxItem[]>
getDocumentTypes: (filter: Ref<string | undefined>) => ComboboxResult<ComboboxItem[]>
}

const service: ComboboxItemService = {
Expand Down Expand Up @@ -82,6 +83,21 @@ const service: ComboboxItemService = {
}
return result
},
getDocumentTypes: (filter: Ref<string | undefined>) => {
const documentTypeValues = ['VR', 'VE', 'VV', 'ST']
const documentTypes = documentTypeValues.map((v) => <DocumentType>{ label: v })
const items = ref(documentTypes.map((dt) => <ComboboxItem>{ label: dt.label, value: dt }))
const execute = async () => {
return service.getDocumentTypes(filter)
}
const result: ComboboxResult<ComboboxItem[]> = {
data: items,
execute: execute,
canAbort: computed(() => false),
abort: () => {},
}
return result
},
}

export default service

0 comments on commit 37e876a

Please sign in to comment.