Skip to content

Commit

Permalink
feat: allow edit approve result
Browse files Browse the repository at this point in the history
  • Loading branch information
keenthekeen committed Sep 8, 2024
1 parent a0ec328 commit 1aa6c40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
4 changes: 1 addition & 3 deletions app/Http/Controllers/ProjectClosureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ public function approvalSubmit(Request $request, Project $project) {
'approve_participants' => 'nullable|required_if:approve,yes|array',
]);
$closureStatus = $project->getClosureStatus();
abort_unless(in_array($closureStatus,
[ProjectClosureStatus::SUBMITTED, ProjectClosureStatus::REVIEWING, ProjectClosureStatus::REJECTED_AND_RESUBMIT]), 403,
'Closure approved or hasn\'t been submitted.');
abort_if($closureStatus == ProjectClosureStatus::NOT_SUBMITTED, 403, 'Closure approved or hasn\'t been submitted.');

$project->closure_approved_by = $request->user()->id;
$project->closure_approved_at = now();
Expand Down
45 changes: 28 additions & 17 deletions resources/js/Pages/ProjectApproval.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,33 @@
</div>
</div>
</div>
<div v-if="item.closure_status >= 1 && item.closure_status <= 5" class="bg-white shadow overflow-hidden sm:rounded-lg my-4">
<div v-if="item.closure_status <= -1" class="bg-white shadow overflow-hidden sm:rounded-lg my-4">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
ไม่อนุมัติรายงานผลโครงการ
</h3>
</div>
<div class="border-t border-gray-200">
<div class="px-4 py-4 sm:px-6">
<p class="font-bold text-lg">
<ClosureStatusText :closure_status="item.closure_status"/>
</p>
<span class="text-gray-600 underline">เหตุผล</span>&ensp;
{{ item.closure_approved_message }}
</div>
</div>
</div>
<div v-if="!(item.closure_status >= 1 && item.closure_status <= 5) && item.closure_status !== 0" class="relative flex gap-x-3">
<div class="flex h-6 items-center">
<input id="force_approve" v-model="forceShowApproveBox"
type="checkbox" class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"/>
</div>
<div class="text-sm leading-6">
<label for="force_approve" class="font-medium text-gray-700">แก้ไขผลการอนุมัติ/ไม่อนุมัติ</label>
</div>
</div>
<div v-if="(item.closure_status >= 1 && item.closure_status <= 5) || forceShowApproveBox"
class="bg-white shadow overflow-hidden sm:rounded-lg my-4">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
อนุมัติรายงานผลโครงการ และรายชื่อนิสิตผู้เกี่ยวข้องหรือไม่
Expand Down Expand Up @@ -280,22 +306,6 @@
</div>
</div>
</div>
<div v-if="item.closure_status <= -1" class="bg-white shadow overflow-hidden sm:rounded-lg my-4">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
ไม่อนุมัติรายงานผลโครงการ
</h3>
</div>
<div class="border-t border-gray-200">
<div class="px-4 py-4 sm:px-6">
<p class="font-bold text-lg">
<ClosureStatusText :closure_status="item.closure_status"/>
</p>
<span class="text-gray-600 underline">เหตุผล</span>&ensp;
{{ item.closure_approved_message }}
</div>
</div>
</div>
<p class="mt-4 px-2 text-xs">
<a class="text-blue-500 cursor-pointer" @click="showLogDialog = true">ดูประวัติ</a>
</p>
Expand Down Expand Up @@ -335,6 +345,7 @@ const form = useForm({
});
const selectedParticipants = ref(props.item.participants.map(e => e.id));
const showLogDialog = ref(false);
const forceShowApproveBox = ref(false);

// Computed
const participantsGrouped = computed(() => {
Expand Down

0 comments on commit 1aa6c40

Please sign in to comment.