-
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.
Merge pull request #103 from ConductionNL/feature/PC108-119/resultaten
finished frontend resultaten
- Loading branch information
Showing
14 changed files
with
742 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './resultaat.ts' | ||
export * from './resultaat.types.ts' | ||
export * from './resultaat.mock.ts' |
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,14 @@ | ||
import { Resultaat } from './resultaat' | ||
import { TResultaat } from './resultaat.types' | ||
|
||
export const mockResultaatData = (): TResultaat[] => [ | ||
{ | ||
id: '15551d6f-44e3-43f3-a9d2-59e583c91eb0', | ||
url: 'https://api.example.com/resultaten/15551d6f-44e3-43f3-a9d2-59e583c91eb0', | ||
zaak: '15551d6f-44e3-43f3-a9d2-59e583c91eb0', | ||
resultaattype: 'Audit', | ||
toelichting: 'Deze taak omvat het uitvoeren van een gedetailleerde interne audit van de bedrijfsprocessen om te controleren of alle afdelingen voldoen aan de vastgestelde kwaliteitsnormen. De bevindingen worden gedocumenteerd en er worden aanbevelingen gedaan voor verbeteringen.', | ||
}, | ||
] | ||
|
||
export const mockResultaat = (data: TResultaat[] = mockResultaatData()): TResultaat[] => data.map(item => new Resultaat(item)) |
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,12 @@ | ||
import { Resultaat } from './resultaat' | ||
import { mockResultaatData } from './resultaat.mock' | ||
|
||
describe('Resultaat Entity', () => { | ||
it('should create a Resultaat entity with full data', () => { | ||
const resultaat = new Resultaat(mockResultaatData()[0]) | ||
|
||
expect(resultaat).toBeInstanceOf(Resultaat) | ||
expect(resultaat).toEqual(mockResultaatData()[0]) | ||
expect(resultaat.validate().success).toBe(true) | ||
}) | ||
}) |
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,32 @@ | ||
import { SafeParseReturnType, z } from 'zod' | ||
import { TResultaat } from './resultaat.types' | ||
|
||
export class Resultaat implements TResultaat { | ||
|
||
public id: string | ||
public url: string | ||
public zaak: string | ||
public resultaattype: string | ||
public toelichting: string | ||
|
||
constructor(source: TResultaat) { | ||
this.id = source.id || '' | ||
this.url = source.url || '' | ||
this.zaak = source.zaak || '' | ||
this.resultaattype = source.resultaattype || '' | ||
this.toelichting = source.toelichting || '' | ||
} | ||
|
||
public validate(): SafeParseReturnType<TResultaat, unknown> { | ||
const schema = z.object({ | ||
id: z.string(), | ||
url: z.string(), | ||
zaak: z.string(), | ||
resultaattype: z.string(), | ||
toelichting: z.string(), | ||
}) | ||
|
||
return schema.safeParse(this) | ||
} | ||
|
||
} |
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,7 @@ | ||
export type TResultaat = { | ||
id: string; | ||
url: string; | ||
zaak: string; | ||
resultaattype: string; | ||
toelichting: string; | ||
} |
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,109 @@ | ||
<script setup> | ||
import { resultaatStore, navigationStore, zaakStore } from '../../store/store.js' | ||
</script> | ||
|
||
<template> | ||
<NcDialog name="Resultaat verwijderen" | ||
size="normal" | ||
:can-close="false"> | ||
<!-- if zaken list is not populated yet, show a quick loading icon (this should under normal conditions not happen) --> | ||
<div v-if="!zaakStore.zakenList?.length"> | ||
<NcLoadingIcon :size="40" /> | ||
</div> | ||
<div v-else> | ||
<p v-if="success === null"> | ||
Weet u zeker dat u | ||
<b>{{ zaakStore.zakenList.find((zaak) => zaak.id === resultaatStore.resultaatItem?.zaak)?.identificatie }} > {{ resultaatStore.resultaatItem?.toelichting }}</b> | ||
permanent wilt verwijderen? Deze actie kan niet ongedaan worden gemaakt. | ||
</p> | ||
|
||
<div v-if="success !== null"> | ||
<NcNoteCard v-if="success" type="success"> | ||
<p>Resultaat succesvol verwijderd</p> | ||
</NcNoteCard> | ||
<NcNoteCard v-if="!success && !error" type="error"> | ||
<p>Er is een fout opgetreden bij het verwijderen van het resultaat</p> | ||
</NcNoteCard> | ||
<NcNoteCard v-if="error" type="error"> | ||
<p>{{ error }}</p> | ||
</NcNoteCard> | ||
</div> | ||
</div> | ||
|
||
<template #actions> | ||
<NcButton @click="closeDialog"> | ||
<template #icon> | ||
<Cancel :size="20" /> | ||
</template> | ||
{{ success === null ? 'Annuleren' : 'Sluiten' }} | ||
</NcButton> | ||
<NcButton v-if="success === null" | ||
:disabled="loading" | ||
type="error" | ||
@click="deleteResultaat()"> | ||
<template #icon> | ||
<NcLoadingIcon v-if="loading" :size="20" /> | ||
<TrashCanOutline v-if="!loading" :size="20" /> | ||
</template> | ||
Verwijderen | ||
</NcButton> | ||
</template> | ||
</NcDialog> | ||
</template> | ||
|
||
<script> | ||
import { | ||
NcButton, | ||
NcDialog, | ||
NcLoadingIcon, | ||
NcNoteCard, | ||
} from '@nextcloud/vue' | ||
import Cancel from 'vue-material-design-icons/Cancel.vue' | ||
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue' | ||
export default { | ||
name: 'DeleteResultaat', | ||
components: { | ||
NcDialog, | ||
NcButton, | ||
NcLoadingIcon, | ||
NcNoteCard, | ||
// Icons | ||
TrashCanOutline, | ||
Cancel, | ||
}, | ||
data() { | ||
return { | ||
success: null, | ||
loading: false, | ||
error: null, | ||
closeModalTimeout: null, | ||
} | ||
}, | ||
mounted() { | ||
zaakStore.refreshZakenList() | ||
}, | ||
methods: { | ||
closeDialog() { | ||
navigationStore.setModal(null) | ||
clearTimeout(this.closeModalTimeout) | ||
}, | ||
async deleteResultaat() { | ||
this.loading = true | ||
resultaatStore.deleteResultaat({ | ||
...resultaatStore.resultaatItem, | ||
}).then(({ response }) => { | ||
this.success = response.ok | ||
response.ok && (this.closeModalTimeout = setTimeout(this.closeDialog, 2000)) | ||
}).catch((error) => { | ||
this.success = false | ||
this.error = error.message || 'Er is een fout opgetreden bij het verwijderen van het resultaat' | ||
}).finally(() => { | ||
this.loading = false | ||
}) | ||
}, | ||
}, | ||
} | ||
</script> |
Oops, something went wrong.