|
|
@@ -0,0 +1,542 @@
|
|
|
+<x-admin::layouts>
|
|
|
+ <x-slot:title>
|
|
|
+ @lang('admin::app.catalog.questions.answers.title')
|
|
|
+ </x-slot>
|
|
|
+
|
|
|
+ <div class="flex items-center justify-between gap-4 max-sm:flex-wrap">
|
|
|
+ <div class="flex items-center gap-2">
|
|
|
+ <a
|
|
|
+ href="{{ route('admin.catalog.questions.index') }}"
|
|
|
+ class="text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-white"
|
|
|
+ >
|
|
|
+ @lang('admin::app.catalog.questions.index.title')
|
|
|
+ </a>
|
|
|
+
|
|
|
+ <span class="text-gray-400">/</span>
|
|
|
+
|
|
|
+ <p class="py-3 text-xl font-bold text-gray-800 dark:text-white">
|
|
|
+ @lang('admin::app.catalog.questions.answers.title')
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ @if (bouncer()->hasPermission('catalog.questions.edit'))
|
|
|
+ <button
|
|
|
+ class="primary-button"
|
|
|
+ onclick="document.dispatchEvent(new CustomEvent('open-create-answer'))"
|
|
|
+ >
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.btn')
|
|
|
+ </button>
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Question context card -->
|
|
|
+ <div class="box-shadow rounded-lg bg-white p-4 dark:bg-gray-900 mb-4">
|
|
|
+ <p class="text-xs font-semibold text-gray-500 dark:text-gray-400 mb-1">
|
|
|
+ @lang('admin::app.catalog.questions.answers.question-label')
|
|
|
+ </p>
|
|
|
+ <p class="text-base text-gray-800 dark:text-white font-medium">
|
|
|
+ {{ $question->question }}
|
|
|
+ </p>
|
|
|
+
|
|
|
+ <div class="flex items-center gap-6 mt-2 text-sm text-gray-500 dark:text-gray-400">
|
|
|
+ <span>
|
|
|
+ @lang('admin::app.catalog.questions.answers.by'): <strong>{{ $question->customer_name }}</strong>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <span>
|
|
|
+ @lang('admin::app.catalog.questions.answers.status'):
|
|
|
+ <span class="{{ $question->status === 'approved' ? 'text-green-600' : ($question->status === 'rejected' ? 'text-red-500' : 'text-yellow-500') }} font-semibold">
|
|
|
+ {{ ucfirst($question->status) }}
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <span>
|
|
|
+ @lang('admin::app.catalog.questions.answers.answer-count'): {{ $question->answers_count }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <v-answer-edit-drawer></v-answer-edit-drawer>
|
|
|
+ <v-create-answer-modal></v-create-answer-modal>
|
|
|
+
|
|
|
+ @pushOnce('scripts')
|
|
|
+ <script
|
|
|
+ type="text/x-template"
|
|
|
+ id="v-answer-edit-drawer-template"
|
|
|
+ >
|
|
|
+ <x-admin::datagrid
|
|
|
+ :src="route('admin.catalog.questions.answers', {{ $question->id }})"
|
|
|
+ :isMultiRow="true"
|
|
|
+ ref="answer_data"
|
|
|
+ >
|
|
|
+ @php
|
|
|
+ $hasEditPermission = bouncer()->hasPermission('catalog.questions.edit');
|
|
|
+ $hasDeletePermission = bouncer()->hasPermission('catalog.questions.delete');
|
|
|
+ $hasPermission = $hasEditPermission || $hasDeletePermission;
|
|
|
+ @endphp
|
|
|
+
|
|
|
+ <template #header="{
|
|
|
+ isLoading,
|
|
|
+ available,
|
|
|
+ applied,
|
|
|
+ selectAll,
|
|
|
+ sort,
|
|
|
+ performAction
|
|
|
+ }">
|
|
|
+ <template v-if="isLoading">
|
|
|
+ <x-admin::shimmer.datagrid.table.head :isMultiRow="true" />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-else>
|
|
|
+ <div class="row grid grid-cols-1 md:grid-cols-[2fr_1fr_minmax(150px,_3fr)_0.5fr] grid-rows-1 gap-1 items-center border-b px-4 py-2.5 dark:border-gray-800 min-w-full">
|
|
|
+ <div
|
|
|
+ class="flex items-center gap-2.5"
|
|
|
+ v-for="(columnGroup, index) in [['customer_name', 'answer_status', 'is_pinned'], ['useful_count', 'created_at', 'answer_id'], ['answer']]"
|
|
|
+ >
|
|
|
+ @if ($hasPermission)
|
|
|
+ <label
|
|
|
+ class="flex w-max cursor-pointer select-none items-center gap-1"
|
|
|
+ for="mass_action_select_all_records"
|
|
|
+ v-if="! index"
|
|
|
+ >
|
|
|
+ <input
|
|
|
+ type="checkbox"
|
|
|
+ id="mass_action_select_all_records"
|
|
|
+ class="peer hidden"
|
|
|
+ name="mass_action_select_all_records"
|
|
|
+ :checked="['all', 'partial'].includes(applied.massActions.meta.mode)"
|
|
|
+ @change="selectAll"
|
|
|
+ >
|
|
|
+
|
|
|
+ <span
|
|
|
+ class="icon-uncheckbox cursor-pointer rounded-md text-2xl"
|
|
|
+ :class="[
|
|
|
+ applied.massActions.meta.mode === 'all' ? 'peer-checked:icon-checked peer-checked:text-blue-600' : (
|
|
|
+ applied.massActions.meta.mode === 'partial' ? 'peer-checked:icon-checkbox-partial peer-checked:text-blue-600' : ''
|
|
|
+ ),
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </label>
|
|
|
+ @endif
|
|
|
+
|
|
|
+ <p class="text-gray-600 dark:text-gray-300">
|
|
|
+ <span class="[&>*]:after:content-['_/_']">
|
|
|
+ <template v-for="column in columnGroup">
|
|
|
+ <span
|
|
|
+ class="after:content-['/'] last:after:content-['']"
|
|
|
+ :class="{
|
|
|
+ 'font-medium text-gray-800 dark:text-white': applied.sort.column == column,
|
|
|
+ 'cursor-pointer hover:text-gray-800 dark:hover:text-white': available.columns.find(c => c.index === column)?.sortable,
|
|
|
+ }"
|
|
|
+ @click="available.columns.find(c => c.index === column)?.sortable ? sort(available.columns.find(c => c.index === column)) : {}"
|
|
|
+ >
|
|
|
+ @{{ available.columns.find(c => c.index === column)?.label }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <i
|
|
|
+ class="align-text-bottom text-base text-gray-800 dark:text-white ltr:ml-1.5 rtl:mr-1.5"
|
|
|
+ :class="[applied.sort.order === 'asc' ? 'icon-down-stat' : 'icon-up-stat']"
|
|
|
+ v-if="columnGroup.includes(applied.sort.column)"
|
|
|
+ ></i>
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #body="{
|
|
|
+ isLoading,
|
|
|
+ available,
|
|
|
+ applied,
|
|
|
+ selectAll,
|
|
|
+ sort,
|
|
|
+ performAction
|
|
|
+ }">
|
|
|
+ <template v-if="isLoading">
|
|
|
+ <x-admin::shimmer.datagrid.table.body :isMultiRow="true" />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-else>
|
|
|
+ <div
|
|
|
+ class="row grid grid-cols-1 gap-2 md:grid-cols-[2fr_1fr_minmax(150px,_3fr)_0.5fr] md:gap-0 border-b px-4 py-2.5 transition-all hover:bg-gray-50 dark:border-gray-800 dark:hover:bg-gray-950 min-w-full"
|
|
|
+ v-for="record in available.records"
|
|
|
+ >
|
|
|
+ <!-- Customer, Status, Pinned -->
|
|
|
+ <div class="flex gap-2.5">
|
|
|
+ @if ($hasPermission)
|
|
|
+ <input
|
|
|
+ type="checkbox"
|
|
|
+ :id="`mass_action_select_record_${record.answer_id}`"
|
|
|
+ class="peer hidden"
|
|
|
+ :name="`mass_action_select_record_${record.answer_id}`"
|
|
|
+ :value="record.answer_id"
|
|
|
+ v-model="applied.massActions.indices"
|
|
|
+ @change="setCurrentSelectionMode"
|
|
|
+ >
|
|
|
+
|
|
|
+ <label
|
|
|
+ class="icon-uncheckbox peer-checked:icon-checked cursor-pointer rounded-md text-2xl peer-checked:text-blue-600"
|
|
|
+ :for="`mass_action_select_record_${record.answer_id}`"
|
|
|
+ ></label>
|
|
|
+ @endif
|
|
|
+
|
|
|
+ <div class="flex flex-col gap-1.5">
|
|
|
+ <p class="text-base font-semibold text-gray-800 dark:text-white">
|
|
|
+ @{{ record.customer_name }}
|
|
|
+ </p>
|
|
|
+
|
|
|
+ <p v-html="record.answer_status"></p>
|
|
|
+
|
|
|
+ <p v-html="record.is_pinned"></p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Useful count, Date, ID -->
|
|
|
+ <div class="flex flex-col gap-1.5 ps-8 md:ps-0">
|
|
|
+ <p class="text-gray-800 dark:text-white">
|
|
|
+ 👍 @{{ record.useful_count }}
|
|
|
+ </p>
|
|
|
+
|
|
|
+ <p class="text-gray-600 dark:text-gray-300">
|
|
|
+ @{{ record.created_at }}
|
|
|
+ </p>
|
|
|
+
|
|
|
+ <p class="text-gray-600 dark:text-gray-300">
|
|
|
+ @{{ "#" + record.answer_id }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Answer text -->
|
|
|
+ <div class="flex flex-col gap-1.5 ps-8 md:ps-0">
|
|
|
+ <p class="text-gray-800 dark:text-white">
|
|
|
+ @{{ record.answer }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Actions -->
|
|
|
+ <div class="flex place-content-end items-center gap-1.5 self-center">
|
|
|
+ <a @click="performAction(record.actions.find(action => action.index === 'delete'))">
|
|
|
+ <span
|
|
|
+ :class="record.actions.find(action => action.index === 'delete')?.icon"
|
|
|
+ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 dark:hover:bg-gray-800 ltr:ml-1 rtl:mr-1"
|
|
|
+ ></span>
|
|
|
+ </a>
|
|
|
+
|
|
|
+ <a
|
|
|
+ v-if="record.actions.find(action => action.index === 'edit')"
|
|
|
+ @click="edit(record.actions.find(action => action.index === 'edit')?.url)"
|
|
|
+ >
|
|
|
+ <span class="icon-sort-right rtl:icon-sort-left cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 dark:hover:bg-gray-800 ltr:ml-1 rtl:mr-1"></span>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </x-admin::datagrid>
|
|
|
+
|
|
|
+ <!-- Edit Drawer -->
|
|
|
+ <div class="flex flex-1 flex-col gap-2 max-xl:flex-auto">
|
|
|
+ <x-admin::form
|
|
|
+ v-slot="{ meta, errors, handleSubmit }"
|
|
|
+ as="div"
|
|
|
+ >
|
|
|
+ <form
|
|
|
+ @submit="handleSubmit($event, update)"
|
|
|
+ ref="answerForm"
|
|
|
+ >
|
|
|
+ <x-admin::drawer ref="answerDrawer">
|
|
|
+ <x-slot:header>
|
|
|
+ <div class="flex items-center justify-between">
|
|
|
+ <p class="text-xl font-medium dark:text-white">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.title')
|
|
|
+ </p>
|
|
|
+
|
|
|
+ <button class="primary-button ltr:mr-11 rtl:ml-11">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.save-btn')
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </x-slot>
|
|
|
+
|
|
|
+ <x-slot:content>
|
|
|
+ <div class="flex flex-col gap-4 px-1.5 py-2.5">
|
|
|
+ <div class="grid grid-cols-2 gap-4">
|
|
|
+ <div>
|
|
|
+ <p class="text-xs font-semibold text-gray-600 dark:text-gray-300">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.customer')
|
|
|
+ </p>
|
|
|
+ <p class="font-semibold text-gray-800 dark:text-white">
|
|
|
+ @{{ answer.customer_name || 'N/A' }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <p class="text-xs font-semibold text-gray-600 dark:text-gray-300">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.useful-count')
|
|
|
+ </p>
|
|
|
+ <p class="font-semibold text-gray-800 dark:text-white">
|
|
|
+ 👍 @{{ answer.useful_count }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="w-full">
|
|
|
+ <p class="block text-xs font-semibold leading-6 text-gray-600 dark:text-gray-300">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.answer-text')
|
|
|
+ </p>
|
|
|
+ <p class="text-gray-800 dark:text-white">
|
|
|
+ @{{ answer.answer }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="w-full">
|
|
|
+ <x-admin::form.control-group.control
|
|
|
+ type="hidden"
|
|
|
+ name="id"
|
|
|
+ rules="required"
|
|
|
+ ::value="answer.id"
|
|
|
+ />
|
|
|
+
|
|
|
+ <x-admin::form.control-group>
|
|
|
+ <x-admin::form.control-group.label class="required">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.status')
|
|
|
+ </x-admin::form.control-group.label>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.control
|
|
|
+ type="select"
|
|
|
+ name="status"
|
|
|
+ rules="required"
|
|
|
+ ::value="answer.status"
|
|
|
+ >
|
|
|
+ <option value="pending">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.pending')
|
|
|
+ </option>
|
|
|
+ <option value="approved">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.approved')
|
|
|
+ </option>
|
|
|
+ <option value="rejected">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.rejected')
|
|
|
+ </option>
|
|
|
+ </x-admin::form.control-group.control>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.error control-name="status" />
|
|
|
+ </x-admin::form.control-group>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="w-full">
|
|
|
+ <x-admin::form.control-group>
|
|
|
+ <x-admin::form.control-group.label>
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.pin-answer')
|
|
|
+ </x-admin::form.control-group.label>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.control
|
|
|
+ type="select"
|
|
|
+ name="is_pinned"
|
|
|
+ ::value="answer.is_pinned ? '1' : '0'"
|
|
|
+ >
|
|
|
+ <option value="0">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.no')
|
|
|
+ </option>
|
|
|
+ <option value="1">
|
|
|
+ @lang('admin::app.catalog.questions.answers.edit.yes')
|
|
|
+ </option>
|
|
|
+ </x-admin::form.control-group.control>
|
|
|
+ </x-admin::form.control-group>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </x-slot>
|
|
|
+ </x-admin::drawer>
|
|
|
+ </form>
|
|
|
+ </x-admin::form>
|
|
|
+ </div>
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <script type="module">
|
|
|
+ app.component('v-answer-edit-drawer', { template: '#v-answer-edit-drawer-template',
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ answer: {},
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ edit(url) {
|
|
|
+ this.$axios.get(url)
|
|
|
+ .then((response) => {
|
|
|
+ this.answer = response.data.data;
|
|
|
+ this.$refs.answerDrawer.open();
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ this.$emitter.emit('add-flash', { type: 'error', message: error.response?.data?.message || 'Error' });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ update(params) {
|
|
|
+ let formData = new FormData(this.$refs.answerForm);
|
|
|
+ formData.append('_method', 'put');
|
|
|
+
|
|
|
+ this.$axios.post(`{{ route('admin.catalog.questions.answers.update', '') }}/${params.id}`, formData)
|
|
|
+ .then((response) => {
|
|
|
+ this.$refs.answerDrawer.close();
|
|
|
+ this.$refs.answer_data.get();
|
|
|
+ this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ if (error.response?.status === 422) {
|
|
|
+ setErrors(error.response.data.errors);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+
|
|
|
+ {{-- Create Answer Modal --}}
|
|
|
+ <script
|
|
|
+ type="text/x-template"
|
|
|
+ id="v-create-answer-modal-template"
|
|
|
+ >
|
|
|
+ <x-admin::form
|
|
|
+ v-slot="{ meta, errors, handleSubmit }"
|
|
|
+ as="div"
|
|
|
+ >
|
|
|
+ <form
|
|
|
+ @submit="handleSubmit($event, store)"
|
|
|
+ ref="createAnswerForm"
|
|
|
+ >
|
|
|
+ <x-admin::modal ref="createModal">
|
|
|
+ <x-slot:header>
|
|
|
+ <p class="text-xl font-medium dark:text-white">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.title')
|
|
|
+ </p>
|
|
|
+ </x-slot>
|
|
|
+
|
|
|
+ <x-slot:content>
|
|
|
+ <div class="flex flex-col gap-4 px-1 py-2">
|
|
|
+ <div class="box-shadow rounded bg-gray-50 dark:bg-gray-800 p-3 text-sm text-gray-700 dark:text-gray-300">
|
|
|
+ {{ $question->question }}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <x-admin::form.control-group>
|
|
|
+ <x-admin::form.control-group.label class="required">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.answer-text')
|
|
|
+ </x-admin::form.control-group.label>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.control
|
|
|
+ type="textarea"
|
|
|
+ name="answer"
|
|
|
+ rules="required|max:5000"
|
|
|
+ rows="4"
|
|
|
+ :placeholder="trans('admin::app.catalog.questions.answers.create.answer-placeholder')"
|
|
|
+ />
|
|
|
+
|
|
|
+ <x-admin::form.control-group.error control-name="answer" />
|
|
|
+ </x-admin::form.control-group>
|
|
|
+
|
|
|
+ <x-admin::form.control-group>
|
|
|
+ <x-admin::form.control-group.label class="required">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.status')
|
|
|
+ </x-admin::form.control-group.label>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.control
|
|
|
+ type="select"
|
|
|
+ name="status"
|
|
|
+ value="approved"
|
|
|
+ rules="required"
|
|
|
+ >
|
|
|
+ <option value="approved">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.approved')
|
|
|
+ </option>
|
|
|
+ <option value="pending">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.pending')
|
|
|
+ </option>
|
|
|
+ <option value="rejected">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.rejected')
|
|
|
+ </option>
|
|
|
+ </x-admin::form.control-group.control>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.error control-name="status" />
|
|
|
+ </x-admin::form.control-group>
|
|
|
+
|
|
|
+ <x-admin::form.control-group>
|
|
|
+ <x-admin::form.control-group.label>
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.pin-answer')
|
|
|
+ </x-admin::form.control-group.label>
|
|
|
+
|
|
|
+ <x-admin::form.control-group.control
|
|
|
+ type="select"
|
|
|
+ name="is_pinned"
|
|
|
+ value="0"
|
|
|
+ >
|
|
|
+ <option value="0">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.no')
|
|
|
+ </option>
|
|
|
+ <option value="1">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.yes')
|
|
|
+ </option>
|
|
|
+ </x-admin::form.control-group.control>
|
|
|
+ </x-admin::form.control-group>
|
|
|
+ </div>
|
|
|
+ </x-slot>
|
|
|
+
|
|
|
+ <x-slot:footer>
|
|
|
+ <div class="flex items-center gap-x-2.5">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="transparent-button"
|
|
|
+ @click="$refs.createModal.close()"
|
|
|
+ >
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.cancel')
|
|
|
+ </button>
|
|
|
+
|
|
|
+ <button type="submit" class="primary-button">
|
|
|
+ @lang('admin::app.catalog.questions.answers.create.save-btn')
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </x-slot>
|
|
|
+ </x-admin::modal>
|
|
|
+ </form>
|
|
|
+ </x-admin::form>
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <script type="module">
|
|
|
+ app.component('v-create-answer-modal', {
|
|
|
+ template: '#v-create-answer-modal-template',
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ document.addEventListener('open-create-answer', () => {
|
|
|
+ this.$refs.createModal.open();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ store(params) {
|
|
|
+ let formData = new FormData(this.$refs.createAnswerForm);
|
|
|
+
|
|
|
+ this.$axios.post('{{ route('admin.catalog.questions.answers.store', $question->id) }}', formData)
|
|
|
+ .then((response) => {
|
|
|
+ this.$refs.createModal.close();
|
|
|
+ this.$refs.createAnswerForm.reset();
|
|
|
+
|
|
|
+ // Refresh the answers DataGrid
|
|
|
+ document.querySelector('[ref="answer_data"]')
|
|
|
+ ?.__vueParentComponent?.refs?.answer_data?.get?.();
|
|
|
+
|
|
|
+ this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ if (error.response?.status === 422) {
|
|
|
+ setErrors(error.response.data.errors);
|
|
|
+ } else {
|
|
|
+ this.$emitter.emit('add-flash', { type: 'error', message: error.response?.data?.message || 'Error' });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+ @endPushOnce
|
|
|
+</x-admin::layouts>
|