Skip to content

Commit

Permalink
feat: show submitted feedback as readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Jan 10, 2025
1 parent 5d14d6f commit 2ecb93e
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 18 deletions.
94 changes: 78 additions & 16 deletions frontend/src/components/BatchFeedback.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
<template>
<div v-if="feedbackList.data"></div>
<div v-else class="space-y-8">
<div class="grid grid-cols-4 gap-5">
<Rating v-model="feedback.content" :label="__('Content')" />
<Rating v-model="feedback.delivery" :label="__('Delivery')" />
<Rating v-model="feedback.instructors" :label="__('Instructors')" />
<Rating v-model="feedback.value" :label="__('Value')" />
<div>
<div
v-if="feedbackList.data?.length"
class="bg-blue-100 text-blue-700 p-2 rounded-md mb-5"
>
{{ __('Thank you for providing your feedback!') }}
</div>
<div v-else class="flex justify-between items-center mb-5">
<div class="text-lg font-semibold">
{{ __('Help Us Improve') }}
</div>
<Button @click="submitFeedback()">
{{ __('Submit') }}
</Button>
</div>
<div class="space-y-8">
<div class="grid grid-cols-4 gap-5">
<Rating
v-model="feedback.content"
:label="__('Content')"
:readonly="readOnly"
/>
<Rating
v-model="feedback.delivery"
:label="__('Delivery')"
:readonly="readOnly"
/>
<Rating
v-model="feedback.instructors"
:label="__('Instructors')"
:readonly="readOnly"
/>
<Rating
v-model="feedback.value"
:label="__('Value')"
:readonly="readOnly"
/>
</div>
<FormControl
v-model="feedback.feedback"
type="textarea"
:label="__('Feedback')"
:rows="7"
:readonly="readOnly"
/>
</div>
<FormControl
v-model="feedback.feedback"
type="textarea"
:label="__('Feedback')"
rows="7"
/>
</div>
</template>
<script setup lang="ts">
import { inject, reactive } from 'vue'
import { createListResource, FormControl, Rating } from 'frappe-ui'
<script setup>
import { inject, reactive, ref } from 'vue'
import { Button, createListResource, FormControl, Rating } from 'frappe-ui'
const user = inject('$user')
const ratingKeys = ['content', 'delivery', 'instructors', 'value']
const readOnly = ref(false)
const feedback = reactive({
content: 0,
delivery: 0,
Expand All @@ -41,7 +75,35 @@ const feedbackList = createListResource({
batch: props.batch,
member: user.data?.name,
},
fields: ['content', 'delivery', 'instructors', 'value', 'feedback', 'name'],
cache: ['feedbackList', props.batch, user.data?.name],
auto: true,
onSuccess(data) {
if (data.length) {
readOnly.value = true
Object.keys(feedback).forEach((key) => {
if (ratingKeys.includes(key)) feedback[key] = data[0][key] * 5
else feedback[key] = data[0][key]
})
}
},
})
const submitFeedback = () => {
ratingKeys.forEach((key) => {
feedback[key] = feedback[key] / 5
})
feedbackList.insert.submit(
{
member: user.data?.name,
batch: props.batch,
...feedback,
},
{
onSuccess: () => {
feedbackList.reload()
},
}
)
}
</script>
2 changes: 1 addition & 1 deletion frontend/src/components/JobCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex rounded p-1 lg:px-2 lg:py-2.5 hover:bg-gray-100">
<div class="flex rounded p-1 lg:px-2 lg:py-4 hover:bg-gray-100">
<div class="flex w-3/5 md:w-2/5">
<img
:src="job.company_logo"
Expand Down
14 changes: 13 additions & 1 deletion lms/lms/doctype/lms_batch_feedback/lms_batch_feedback.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-01-07 18:56:38.800575",
"modified": "2025-01-10 17:25:25.482724",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch Feedback",
Expand All @@ -82,6 +82,18 @@
"role": "System Manager",
"share": 1,
"write": 1
},
{
"create": 1,
"email": 1,
"export": 1,
"if_owner": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "LMS Student",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
Expand Down

0 comments on commit 2ecb93e

Please sign in to comment.