浏览代码

filter protoype

master
azri 1 天前
父节点
当前提交
d6a0242515
共有 2 个文件被更改,包括 43 次插入10 次删除
  1. 40
    9
      resources/views/project.blade.php
  2. 3
    1
      routes/web.php

+ 40
- 9
resources/views/project.blade.php 查看文件

@@ -44,25 +44,31 @@
44 44
 
45 45
             <div class="relative w-fit">
46 46
                 <select
47
-                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500">
47
+                    id="selectProjectStatus"
48
+                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
49
+                    onchange="renderFDITable()">
48 50
                     <option value="all" selected>Status</option>
49
-                    <option value="final">Perjanjian Muktamad</option>
50
-                    <option value="draft">Deraf Perjanjian</option>
51
+                    <option value="1">Perjanjian Muktamad</option>
52
+                    <option value="0">Deraf Perjanjian</option>
51 53
                 </select>
52 54
             </div>
53 55
 
54 56
             <div class="relative w-fit">
55 57
                 <select
56
-                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500">
58
+                    id="selectProjectArea"
59
+                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
60
+                    onchange="renderFDITable()">
57 61
                     <option value="all" selected>Daerah</option>
58
-                    <option value="1">Gambang</option>
59
-                    <option value="2">Pekan</option>
62
+                    <option value="Gambang">Gambang</option>
63
+                    <option value="Pekan">Pekan</option>
60 64
                 </select>
61 65
             </div>
62 66
 
63 67
             <div class="relative w-fit">
64 68
                 <select
65
-                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500">
69
+                    id="selectProjectYear"
70
+                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
71
+                    onchange="renderFDITable()">
66 72
                     <option value="all" selected>Tahun</option>
67 73
                     <option value="2026">2026</option>
68 74
                     <option value="2025">2025</option>
@@ -236,6 +242,10 @@
236 242
 
237 243
 @section('scripts')
238 244
     <script>
245
+
246
+        var FDIProject = [];
247
+        var DDIProject = [];
248
+
239 249
         async function fetchAndRenderProjects() {
240 250
 
241 251
             const selectedType = document.getElementById('selectProjectType').value;
@@ -247,18 +257,21 @@
247 257
 
248 258
                 if (!data.FDIProject || !data.DDIProject) return
249 259
 
250
-                renderFDITable(data.FDIProject)
260
+                FDIProject = data.FDIProject
261
+                renderFDITable()
251 262
 
252 263
             } catch (error) {
253 264
                 console.error('Error fetching projects:', error);
254 265
             }
255 266
         }
256 267
 
257
-        function renderFDITable(data) {
268
+        function renderFDITable() {
258 269
 
259 270
             const tbody = document.getElementById('FDItableBody');
260 271
             tbody.innerHTML = ''; // Clear existing content
261 272
 
273
+            data = filterData(FDIProject)
274
+
262 275
             data.forEach((project, index) => {
263 276
                 const statusHTML = (() => {
264 277
                     switch (project.status) {
@@ -294,6 +307,24 @@
294 307
 
295 308
         }
296 309
 
310
+        function filterData(data){
311
+
312
+            const status = document.getElementById("selectProjectStatus").value
313
+            const area = document.getElementById("selectProjectArea").value
314
+            const year = document.getElementById("selectProjectYear").value
315
+
316
+            // filter by status
317
+            data = data.filter(project => (status === "all" || parseInt(status) === parseInt(project.status)))
318
+
319
+            // filter by area
320
+            data = data.filter(project => (area === "all" || area === project.area))
321
+
322
+            // filter by year
323
+            data = data.filter(project => (year === "all" || parseInt(year) === parseInt(project.year)))
324
+
325
+            return data
326
+        }
327
+
297 328
         document.addEventListener('DOMContentLoaded', fetchAndRenderProjects);
298 329
     </script>
299 330
 @endsection

+ 3
- 1
routes/web.php 查看文件

@@ -315,7 +315,8 @@ Route::prefix('api')->group(function () {
315 315
                 "type" => "Data Center",
316 316
                 "status" => 1,
317 317
                 "note" => "Dalam Proses Submit",
318
-                "moa_date" => "22-02-2025",
318
+                "moa_date" => "22-02-2026",
319
+                "year" => "2026",
319 320
                 "area" => "Gambang",
320 321
                 "invesment_approx" => 100000000,
321 322
                 "labour_approx" => 50,
@@ -328,6 +329,7 @@ Route::prefix('api')->group(function () {
328 329
                 "status" => 0,
329 330
                 "note" => "Loi Ditandatangani pada 14-03-2025",
330 331
                 "moa_date" => "22-02-2025",
332
+                "year" => "2025",
331 333
                 "area" => "Pekan",
332 334
                 "invesment_approx" => 100000000,
333 335
                 "labour_approx" => 50,

正在加载...
取消
保存