mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
answer vue component: use union type instead of enum
This commit is contained in:
parent
c804462f15
commit
3a88ea0b0f
@ -27,12 +27,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent, PropType} from 'vue';
|
import {defineComponent, PropType} from 'vue';
|
||||||
|
|
||||||
enum AnswerStatus {
|
const ACCEPTED = 'accepted';
|
||||||
ACCEPTED = 'accepted',
|
const DECLINED = 'declined';
|
||||||
DECLINED = 'declined',
|
const PENDING = 'pending';
|
||||||
PENDING = 'pending',
|
const TENTATIVELY_ACCEPTED = 'tentative';
|
||||||
TENTATIVELY_ACCEPTED = 'tentative',
|
|
||||||
};
|
|
||||||
|
|
||||||
const i18n = {
|
const i18n = {
|
||||||
messages: {
|
messages: {
|
||||||
@ -54,20 +52,25 @@ export default defineComponent({
|
|||||||
i18n,
|
i18n,
|
||||||
props: {
|
props: {
|
||||||
calendarId: { type: Number, required: true},
|
calendarId: { type: Number, required: true},
|
||||||
status: {type: Object as PropType<AnswerStatus>, required: true},
|
status: {type: String as PropType<"accepted" | "declined" | "pending" | "tentative">, required: true},
|
||||||
},
|
},
|
||||||
emits: {
|
emits: {
|
||||||
statusChanged(payload: AnswerStatus) {
|
statusChanged(payload: "accepted" | "declined" | "pending" | "tentative") {
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Statuses: AnswerStatus,
|
Statuses: {
|
||||||
|
ACCEPTED,
|
||||||
|
DECLINED,
|
||||||
|
PENDING,
|
||||||
|
TENTATIVELY_ACCEPTED,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeStatus: function (newStatus: AnswerStatus) {
|
changeStatus: function (newStatus: "accepted" | "declined" | "pending" | "tentative") {
|
||||||
console.log('changeStatus', newStatus);
|
console.log('changeStatus', newStatus);
|
||||||
const url = `/api/1.0/calendar/calendar/${this.$props.calendarId}/answer/${newStatus}.json`;
|
const url = `/api/1.0/calendar/calendar/${this.$props.calendarId}/answer/${newStatus}.json`;
|
||||||
window.fetch(url, {
|
window.fetch(url, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user