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

127 lines
6.1 KiB
Vue

<template>
<div>
<h2 id="page-heading" data-cy="QuestionHeading">
<span id="question">{{ t$('questionBankApp.question.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.question.home.refreshListLabel') }}</span>
</button>
<router-link :to="{ name: 'QuestionCreate' }" custom v-slot="{ navigate }">
<button
@click="navigate"
id="jh-create-entity"
data-cy="entityCreateButton"
class="btn btn-primary jh-create-entity create-question"
>
<font-awesome-icon icon="plus"></font-awesome-icon>
<span>{{ t$('questionBankApp.question.home.createLabel') }}</span>
</button>
</router-link>
</div>
</h2>
<br />
<div class="alert alert-warning" v-if="!isFetching && questions?.length === 0">
<span>{{ t$('questionBankApp.question.home.notFound') }}</span>
</div>
<div class="table-responsive" v-if="questions?.length > 0">
<table class="table table-striped" aria-describedby="questions">
<thead>
<tr>
<th scope="col" @click="changeOrder('id')">
<span>{{ t$('global.field.id') }}</span>
<jhi-sort-indicator :current-order="propOrder" :reverse="reverse" :field-name="'id'"></jhi-sort-indicator>
</th>
<th scope="col" @click="changeOrder('prompt')">
<span>{{ t$('questionBankApp.question.prompt') }}</span>
<jhi-sort-indicator :current-order="propOrder" :reverse="reverse" :field-name="'prompt'"></jhi-sort-indicator>
</th>
<th scope="col" @click="changeOrder('explanation')">
<span>{{ t$('questionBankApp.question.explanation') }}</span>
<jhi-sort-indicator :current-order="propOrder" :reverse="reverse" :field-name="'explanation'"></jhi-sort-indicator>
</th>
<th scope="col" @click="changeOrder('active')">
<span>{{ t$('questionBankApp.question.active') }}</span>
<jhi-sort-indicator :current-order="propOrder" :reverse="reverse" :field-name="'active'"></jhi-sort-indicator>
</th>
<th scope="col" @click="changeOrder('subject.name')">
<span>{{ t$('questionBankApp.question.subject') }}</span>
<jhi-sort-indicator :current-order="propOrder" :reverse="reverse" :field-name="'subject.name'"></jhi-sort-indicator>
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr v-for="question in questions" :key="question.id" data-cy="entityTable">
<td>
<router-link :to="{ name: 'QuestionView', params: { questionId: question.id } }">{{ question.id }}</router-link>
</td>
<td>{{ question.prompt }}</td>
<td>{{ question.explanation }}</td>
<td>{{ question.active }}</td>
<td>
<div v-if="question.subject">
<router-link :to="{ name: 'SubjectView', params: { subjectId: question.subject.id } }">{{
question.subject.name
}}</router-link>
</div>
</td>
<td class="text-end">
<div class="btn-group">
<router-link :to="{ name: 'QuestionView', params: { questionId: question.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: 'QuestionEdit', params: { questionId: question.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(question)" 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.question.delete.question" data-cy="questionDeleteDialogHeading">{{ t$('entity.delete.title') }}</span>
</template>
<div class="modal-body">
<p id="jhi-delete-question-heading">{{ t$('questionBankApp.question.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-question"
data-cy="entityConfirmDeleteButton"
@click="removeQuestion"
>
{{ t$('entity.action.delete') }}
</button>
</div>
</template>
</b-modal>
<div v-show="questions?.length > 0">
<div class="d-flex justify-content-center">
<jhi-item-count :page="page" :total="queryCount" :items-per-page="itemsPerPage"></jhi-item-count>
</div>
<div class="d-flex justify-content-center">
<b-pagination size="md" :total-rows="totalItems" v-model="page" :per-page="itemsPerPage"></b-pagination>
</div>
</div>
</div>
</template>
<script lang="ts" src="./question.component.ts"></script>