Skip to content

Commit

Permalink
feat: show approval/summary document in project index
Browse files Browse the repository at this point in the history
  • Loading branch information
keenthekeen committed Oct 13, 2023
1 parent 9042648 commit d2b731a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
7 changes: 6 additions & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public function index(Request $request): Response {
$keyword = $request->input('search');

return Inertia::render('ProjectIndex', [
'list' => Project::searchQuery($keyword)->orderByDesc('year')->orderByDesc('number')->paginate(15)->withQueryString(),
'list' => Project::searchQuery($keyword)->orderByDesc('year')->orderByDesc('number')->with([
'documents' => function ($query) {
$query->select('id', 'tag', 'project_id');
$query->whereNotNull('tag');
},
])->paginate(15)->withQueryString(),
'keyword' => $keyword
]);
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/DocumentIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
{{ item.title }}
</inertia-link>
<span class="pl-1">
<DocumentChartBarIcon v-if="item.tag === 'summary'" class="text-yellow-700 h-4 w-4 inline-block"/>
<DocumentTextIcon v-if="item.tag === 'approval'" class="text-purple-700 h-4 w-4 inline-block"/>
<DocumentChartBarIcon v-if="item.tag === 'summary'" class="text-yellow-700 h-4 w-4 inline-block"/>
<DocumentCheckIcon v-if="item.status === 'APPROVED'" class="text-green-700 h-4 w-4 inline-block"/>
<ExclamationCircleIcon v-if="item.status === 'REJECTED'" class="text-amber-700 h-4 w-4 inline-block"/>
</span>
Expand Down
2 changes: 2 additions & 0 deletions resources/js/Pages/ProjectCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<jet-input-error v-if="form.errors.name" :message="form.errors.name" class="mt-2"/>
<jet-input-error v-else-if="form.name.startsWith('โครงการ')" message='ไม่ต้องขึ้นต้นด้วยคำว่า "โครงการ"' class="mt-2"/>
<jet-input-error v-else-if="form.name.startsWith('ขออนุมัติ')" message='ไม่ต้องขึ้นต้นด้วยคำว่า "ขออนุมัติ"' class="mt-2"/>
<jet-input-error v-else-if="form.name.includes('รายงานผล')"
message='หากต้องการรายงานผล ให้อ้างถึงโครงการที่ได้บันทึกไว้แล้ว โดยไม่ต้องสร้างโครงการใหม่' class="mt-2"/>
</div>
<div class="col-span-6">
<label for="department" class="block text-sm font-medium text-gray-700">หน่วยงานที่รับผิดชอบ</label>
Expand Down
15 changes: 9 additions & 6 deletions resources/js/Pages/ProjectIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
<th scope="col" class="px-2 py-2 md:px-4 md:py-3 text-left text-xs font-medium text-gray-500 tracking-wider">
วันที่จัด
</th>
<th scope="col" class="relative px-2 py-2 md:px-4 md:py-3 hidden md:table-cell">
<span class="sr-only">Edit</span>
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
Expand All @@ -51,6 +48,12 @@
<inertia-link :href="route('projects.show', {project: item.id})">
{{ item.name }}
</inertia-link>
<span class="pl-1">
<inertia-link v-for="document in item.documents" :href="route('documents.show', {document: document.id})">
<DocumentTextIcon v-if="document.tag === 'approval'" class="text-gray-300 h-3 w-3 inline-block"/>
<DocumentChartBarIcon v-if="document.tag === 'summary'" class="text-yellow-700 h-4 w-4 inline-block"/>
</inertia-link>
</span>
</td>
<td class="px-2 py-2 md:px-4 md:py-3 text-sm">
<span v-if="item.department_id === 33" class="text-gray-400">-</span>
Expand All @@ -60,9 +63,6 @@
{{ item.period_start }}
<span v-if="item.period_start !== item.period_end">- {{ item.period_end }}</span>
</td>
<td class="px-2 py-2 md:px-4 md:py-3 text-right text-sm font-medium hidden md:table-cell">
<inertia-link :href="route('projects.show', {project: item.id})" class="text-indigo-600 hover:text-indigo-900">View</inertia-link>
</td>
</tr>
</tbody>
</table>
Expand All @@ -87,9 +87,12 @@ import AppLayout from '@/Layouts/AppLayout.vue'
import SearchInput from "@/Components/SearchInput.vue";
import Pagination from "@/Components/Pagination.vue";
import {Bars4Icon} from "@heroicons/vue/24/solid";
import {DocumentChartBarIcon} from "@heroicons/vue/20/solid";
import {DocumentTextIcon} from "@heroicons/vue/24/outline";
export default {
components: {
DocumentChartBarIcon, DocumentTextIcon,
AppLayout,
Pagination,
SearchInput,
Expand Down
9 changes: 7 additions & 2 deletions resources/js/Pages/ProjectShow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@
<span v-else>-</span>
</td>
<td class="p-2">
{{ e.title }}
<inertia-link :href="route('documents.show', {document: e.id})">
<DocumentChartBarIcon v-if="e.tag === 'summary'" class="text-yellow-700 h-4 w-4 inline-block"/>
<DocumentTextIcon v-if="e.tag === 'approval'" class="text-purple-700 h-4 w-4 inline-block"/>
{{ e.title }}
</inertia-link>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -289,13 +293,14 @@
<script>
import AppLayout from '@/Layouts/AppLayout.vue'
import JetButton from '@/Jetstream/Button.vue'
import {ArrowUpTrayIcon, PlusIcon, PrinterIcon, XMarkIcon} from "@heroicons/vue/20/solid";
import {ArrowUpTrayIcon, DocumentChartBarIcon, DocumentTextIcon, PlusIcon, PrinterIcon, XMarkIcon} from "@heroicons/vue/20/solid";
import StudentIdDialog from "../Components/StudentIdDialog.vue";
import _ from "lodash";
import ImportParticipantDialog from "../Components/ImportParticipantDialog.vue";
export default {
components: {
DocumentChartBarIcon, DocumentTextIcon,
ImportParticipantDialog,
StudentIdDialog,
AppLayout,
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/ProjectYearIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</td>
<td class="px-2 py-1 md:px-4" colspan="4">
<DocumentChartBarIcon class="text-yellow-700 h-4 w-4 inline-block" v-if="document.tag === 'summary'" />
<DocumentTextIcon class="text-green-700 h-4 w-4 inline-block" v-if="document.tag === 'approval'" />
<DocumentTextIcon class="text-purple-700 h-4 w-4 inline-block" v-if="document.tag === 'approval'"/>
<inertia-link :href="route('documents.show', {document: document.id})">
{{ document.title }}
</inertia-link>
Expand Down

0 comments on commit d2b731a

Please sign in to comment.