Files
jhipster-question-bank/src/main/webapp/app/entities/choice/choice.vue
T

118 lines
5.0 KiB
Vue

<template>
<div>
<h2 id="page-heading" data-cy="ChoiceHeading">
<span id="choice">{{ t$('questionBankApp.choice.home.title') }}</span>
<div class="d-flex justify-content-end">
<button class="btn btn-info me-2" @click="handleSyncList" :disabled="isFetching">
<font-awesome-icon icon="sync" :spin="isFetching"></font-awesome-icon>
<span>{{ t$('questionBankApp.choice.home.refreshListLabel') }}</span>
</button>
<router-link :to="{ name: 'ChoiceCreate' }" custom v-slot="{ navigate }">
<button
@click="navigate"
id="jh-create-entity"
data-cy="entityCreateButton"
class="btn btn-primary jh-create-entity create-choice"
>
<font-awesome-icon icon="plus"></font-awesome-icon>
<span>{{ t$('questionBankApp.choice.home.createLabel') }}</span>
</button>
</router-link>
</div>
</h2>
<br />
<div class="alert alert-warning" v-if="!isFetching && choices?.length === 0">
<span>{{ t$('questionBankApp.choice.home.notFound') }}</span>
</div>
<div class="table-responsive" v-if="choices?.length > 0">
<table class="table table-striped" aria-describedby="choices">
<thead>
<tr>
<th scope="col">
<span>{{ t$('global.field.id') }}</span>
</th>
<th scope="col">
<span>{{ t$('questionBankApp.choice.optionKey') }}</span>
</th>
<th scope="col">
<span>{{ t$('questionBankApp.choice.content') }}</span>
</th>
<th scope="col">
<span>{{ t$('questionBankApp.choice.displayOrder') }}</span>
</th>
<th scope="col">
<span>{{ t$('questionBankApp.choice.correct') }}</span>
</th>
<th scope="col">
<span>{{ t$('questionBankApp.choice.question') }}</span>
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr v-for="choice in choices" :key="choice.id" data-cy="entityTable">
<td>
<router-link :to="{ name: 'ChoiceView', params: { choiceId: choice.id } }">{{ choice.id }}</router-link>
</td>
<td>{{ t$('questionBankApp.OptionKey.' + choice.optionKey) }}</td>
<td>{{ choice.content }}</td>
<td>{{ choice.displayOrder }}</td>
<td>{{ choice.correct }}</td>
<td>
<div v-if="choice.question">
<router-link :to="{ name: 'QuestionView', params: { questionId: choice.question.id } }">{{
choice.question.id
}}</router-link>
</div>
</td>
<td class="text-end">
<div class="btn-group">
<router-link :to="{ name: 'ChoiceView', params: { choiceId: choice.id } }" custom v-slot="{ navigate }">
<button @click="navigate" class="btn btn-info btn-sm details" data-cy="entityDetailsButton">
<font-awesome-icon icon="eye"></font-awesome-icon>
<span class="d-none d-md-inline">{{ t$('entity.action.view') }}</span>
</button>
</router-link>
<router-link :to="{ name: 'ChoiceEdit', params: { choiceId: choice.id } }" custom v-slot="{ navigate }">
<button @click="navigate" class="btn btn-primary btn-sm edit" data-cy="entityEditButton">
<font-awesome-icon icon="pencil-alt"></font-awesome-icon>
<span class="d-none d-md-inline">{{ t$('entity.action.edit') }}</span>
</button>
</router-link>
<b-button @click="prepareRemove(choice)" variant="danger" class="btn btn-sm" data-cy="entityDeleteButton">
<font-awesome-icon icon="times"></font-awesome-icon>
<span class="d-none d-md-inline">{{ t$('entity.action.delete') }}</span>
</b-button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<b-modal ref="removeEntity" id="removeEntity">
<template #title>
<span id="questionBankApp.choice.delete.question" data-cy="choiceDeleteDialogHeading">{{ t$('entity.delete.title') }}</span>
</template>
<div class="modal-body">
<p id="jhi-delete-choice-heading">{{ t$('questionBankApp.choice.delete.question', { id: removeId }) }}</p>
</div>
<template #footer>
<div>
<button type="button" class="btn btn-secondary" @click="closeDialog()">{{ t$('entity.action.cancel') }}</button>
<button
type="button"
class="btn btn-primary"
id="jhi-confirm-delete-choice"
data-cy="entityConfirmDeleteButton"
@click="removeChoice"
>
{{ t$('entity.action.delete') }}
</button>
</div>
</template>
</b-modal>
</div>
</template>
<script lang="ts" src="./choice.component.ts"></script>