2021-02-07 13:44:53 +08:00
|
|
|
<template>
|
2021-02-10 07:56:02 +08:00
|
|
|
<v-dialog v-model="dialog" width="500" persistent>
|
2021-02-07 13:44:53 +08:00
|
|
|
<template #activator="{ on, attrs }">
|
2021-02-10 07:56:02 +08:00
|
|
|
<v-btn v-bind="attrs" :class="activatorClass" v-on="on">
|
2021-02-07 13:44:53 +08:00
|
|
|
<v-icon>mdi-flag</v-icon>
|
|
|
|
{{ $t('project.actions.flag') }}
|
|
|
|
</v-btn>
|
|
|
|
</template>
|
|
|
|
<v-card>
|
|
|
|
<v-card-title> {{ $t('project.flag.flagProject', [project.name]) }} </v-card-title>
|
|
|
|
<v-card-text>
|
2021-02-10 07:56:02 +08:00
|
|
|
<v-form ref="modalForm" v-model="validForm">
|
2021-02-07 13:44:53 +08:00
|
|
|
<v-radio-group v-model="form.selection" :rules="[$util.$vc.require('A reason')]">
|
|
|
|
<v-radio v-for="(reason, index) in flagReasons" :key="index" :label="reason.title" :value="reason.type" />
|
|
|
|
</v-radio-group>
|
|
|
|
<v-textarea v-model.trim="form.comment" rows="3" filled :rules="[$util.$vc.require('A comment')]" :label="$t('general.comment')" />
|
|
|
|
</v-form>
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-actions class="justify-end">
|
2021-02-10 07:56:02 +08:00
|
|
|
<v-btn text color="warning" @click.stop="dialog = false">{{ $t('general.close') }}</v-btn>
|
|
|
|
<v-btn color="error" :disabled="!validForm" :loading="loading" @click.stop="submitFlag">{{ $t('general.submit') }}</v-btn>
|
2021-02-07 13:44:53 +08:00
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-02-10 07:56:02 +08:00
|
|
|
import { Component, Prop } from 'nuxt-property-decorator';
|
2021-02-07 13:44:53 +08:00
|
|
|
import { FlagReason, HangarProject } from 'hangar-internal';
|
2021-02-10 07:56:02 +08:00
|
|
|
import { PropType } from 'vue';
|
|
|
|
import { HangarFormModal } from '~/components/mixins';
|
2021-02-07 13:44:53 +08:00
|
|
|
|
|
|
|
@Component
|
2021-02-10 07:56:02 +08:00
|
|
|
export default class FlagModal extends HangarFormModal {
|
2021-02-07 13:44:53 +08:00
|
|
|
flagReasons: FlagReason[] = [];
|
|
|
|
form = {
|
|
|
|
selection: null as string | null,
|
|
|
|
comment: null as string | null,
|
|
|
|
};
|
|
|
|
|
2021-02-10 07:56:02 +08:00
|
|
|
@Prop({ required: true, type: Object as PropType<HangarProject> })
|
2021-02-07 13:44:53 +08:00
|
|
|
project!: HangarProject;
|
|
|
|
|
|
|
|
submitFlag() {
|
|
|
|
this.loading = true;
|
2021-02-10 07:56:02 +08:00
|
|
|
// TODO flag endpoint
|
2021-02-07 13:44:53 +08:00
|
|
|
setTimeout(
|
|
|
|
(self: FlagModal) => {
|
|
|
|
self.loading = false;
|
2021-02-10 07:56:02 +08:00
|
|
|
self.dialog = false;
|
2021-02-07 13:44:53 +08:00
|
|
|
},
|
|
|
|
1000,
|
|
|
|
this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
async fetch() {
|
|
|
|
this.flagReasons.push(...(await this.$api.requestInternal<FlagReason[]>('data/flagReasons', true)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|