Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/R-03 na registreren terug startscherm #199

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<login-overlay>
<template #default="{ onLogout }">
<the-toast-section />
<header :class="{ contactmomentLoopt: contactmoment.contactmomentLoopt }">
<global-search>
<template #articleFooter="{ id, title }">
Expand All @@ -26,6 +27,7 @@ import { GlobalSearch } from "./features/search";
import { useContactmomentStore } from "@/stores/contactmoment";
import SearchFeedback from "./features/feedback/SearchFeedback.vue";
import { logoutUrl, LoginOverlay } from "./features/login";
import TheToastSection from "./components/TheToastSection.vue";
const contactmoment = useContactmomentStore();
</script>
Expand Down
60 changes: 60 additions & 0 deletions src/components/TheToastSection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<!-- https://web.dev/building-a-toast-component/ -->
<transition-group name="toast" tag="section">
<output
v-for="{ text, type, key } in messages"
:key="key"
role="status"
:class="type"
>{{ text }}</output
>
</transition-group>
</template>

<script lang="ts" setup>
import { messages } from "@/stores/toast";
</script>

<style scoped lang="scss">
section {
position: fixed;
z-index: 1;
inset-block-end: 0;
inset-inline: 0;
padding-block-end: 5vh;
display: grid;
justify-items: center;
justify-content: center;
gap: 1vh;
pointer-events: none;
}
output {
max-inline-size: min(25ch, 90vw);
padding: var(--spacing-default);
border-radius: var(--radius-default);
font-size: 1rem;
color: white;
}
.confirm {
background-color: var(--color-accent);
}
.toast-move, /* apply transition to moving elements */
.toast-enter-active,
.toast-leave-active {
transition: all 0.5s ease;
}
.toast-enter-from,
.toast-leave-to {
opacity: 0;
}
/* ensure leaving items are taken out of layout flow so that moving
animations can be calculated correctly. */
.toast-leave-active {
position: absolute;
}
</style>
26 changes: 1 addition & 25 deletions src/features/contactmoment/ContactmomentAfhandelForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
contactmomentStore.contactmomentLoopt &&
gespresResultatenServiceResult.state === 'success'
"
@submit.prevent="submitDialog.reveal"
@submit.prevent="submit"
>
<fieldset class="utrecht-form-fieldset">
<legend
Expand Down Expand Up @@ -99,26 +99,6 @@
>
</template>
</modal-template>

<!-- Submit Dialog -->

<modal-template v-if="submitDialogRevealed">
<template #message>
<p>Weet u zeker dat u het contactmoment wilt opslaan?</p>
</template>
<template #menu>
<utrecht-button
modelValue
@click="submitDialog.cancel"
appearance="secondary-action-button"
>Nee</utrecht-button
>
<utrecht-button modelValue @click="submitDialog.confirm"
>Ja</utrecht-button
>
</template>
>
</modal-template>
</template>

<script lang="ts" setup>
Expand All @@ -141,9 +121,7 @@ const contactmomentStore = useContactmomentStore();
const service = useContactmomentService();
const cancelDialogRevealed = ref(false);
const submitDialogRevealed = ref(false);
const cancelDialog = useConfirmDialog(cancelDialogRevealed);
const submitDialog = useConfirmDialog(submitDialogRevealed);
const contactmoment: Contactmoment = reactive({
vorigContactmoment: null,
voorkeurskanaal: "",
Expand All @@ -169,8 +147,6 @@ const emit = defineEmits(["save"]);
cancelDialog.onConfirm(() => annuleren());
submitDialog.onConfirm(() => submit());
// voorkeurs kanaal voorselecteren
// organisatieId instellen, nb een medewerker kan voor meerdere organisaties tegelijk werken. vooralsnog is er geen mogelijkheid om een organisatie te selecteren. we kiezen altijd de eerste
onMounted(() => (contactmoment.kanaal = user.preferences.kanaal));
Expand Down
36 changes: 36 additions & 0 deletions src/stores/toast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { reactive } from "vue";

type MessageType = "confirm" | "error";

interface ToastParams {
text: string;
type?: MessageType;
timeout?: number;
}

interface Message {
readonly text: string;
readonly type: MessageType;
readonly key: number;
}

let key = 0;

const _messages = reactive<Message[]>([]);

export const messages = _messages as readonly Message[];

export function toast(params: ToastParams) {
const m = {
text: params.text,
type: params.type || "confirm",
key: (key += 1),
};
_messages.push(m);
setTimeout(() => {
const index = _messages.indexOf(m);
if (index !== -1) {
_messages.splice(index, 1);
}
}, params.timeout || 3000);
}
20 changes: 7 additions & 13 deletions src/views/AfhandelingView.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
<template>
<main>
<utrecht-heading :level="1">Afhandeling</utrecht-heading>
<utrecht-heading :level="1" modelValue>Afhandeling</utrecht-heading>
<router-link
v-if="contactmoment.contactmomentLoopt"
:to="{ name: 'contactmoment' }"
>terug</router-link
>
<section>
<section v-if="saving"><simple-spinner></simple-spinner></section>

<application-message v-else-if="saved" messageType="confirm">
<span
>Het contactmoment is opgeslagen. Ga terug naar het
<router-link :to="{ name: 'home' }">startscherm</router-link></span
>
</application-message>
<application-message
v-else-if="errorMessage != ''"
messageType="error"
Expand Down Expand Up @@ -45,19 +38,20 @@ import { useContactmomentService } from "@/features/contactmoment";
import type { Contactmoment } from "@/features/contactmoment/types";
import SimpleSpinner from "@/components/SimpleSpinner.vue";
import ApplicationMessage from "@/components/ApplicationMessage.vue";
import { toast } from "@/stores/toast";
import { useRouter } from "vue-router";
const router = useRouter();
const contactmoment = useContactmomentStore();
const saving = ref(false);
const service = useZaaksysteemService();
const contactmomentService = useContactmomentService();
const errorMessage = ref("");
const saved = ref(false);
const zakenToevoegenAanContactmoment = (id: string) => {
contactmoment?.zaken.forEach((zaak) => {
const data = {
contactmoment:
window.contactmomentenBaseUri + "/objectcontactmomenten/" + id, //todo de hele url zou uit de response van het aanmaken contactmoment moeten komen
contactmoment: window.gatewayBaseUri + "/api/objectcontactmomenten/" + id, //todo de hele url zou uit de response van het aanmaken contactmoment moeten komen
object: zaak.url,
objectType: "zaak",
} as ContactmomentObject;
Expand All @@ -83,8 +77,8 @@ const saveContact = (contactmoment: Contactmoment) => {
// nu ook de zaken opslaan bij het contactmoment
zakenToevoegenAanContactmoment(savedContactmoment.id);
//status bijwekren
saved.value = true;
toast({ text: "Het contactmoment is opgeslagen" });
router.push("/");
})
.catch(() => {
errorMessage.value =
Expand Down