diff --git a/app/Http/Controllers/Admin/UiElementController.php b/app/Http/Controllers/Admin/UiElementController.php index c638b25..6ed6a8f 100644 --- a/app/Http/Controllers/Admin/UiElementController.php +++ b/app/Http/Controllers/Admin/UiElementController.php @@ -27,13 +27,28 @@ class UiElementController extends Controller // 頁籤一:UI 元素列表(素材庫) // ================================================================== - public function uiElements() + public function uiElements(Request $request) { - $elements = UiElement::orderByDesc('id')->get(); + $perPage = (int) $request->input('per_page', 10); + $perPage = in_array($perPage, [10, 25, 50, 100], true) ? $perPage : 10; + + $search = trim((string) $request->input('search', '')); + + $query = UiElement::orderByDesc('id'); + if ($search !== '') { + $query->where(function ($q) use ($search) { + $q->where('name', 'like', "%{$search}%") + ->orWhere('part_key', 'like', "%{$search}%"); + }); + } + + $elements = $query->paginate($perPage)->withQueryString(); return view('admin.app.ui-elements.index', [ 'elements' => $elements, 'parts' => $this->activeParts(), + 'perPage' => $perPage, + 'search' => $search, ]); } diff --git a/lang/en.json b/lang/en.json index 405dc89..06a67c9 100644 --- a/lang/en.json +++ b/lang/en.json @@ -2348,6 +2348,8 @@ "Saved and update pushed to machine.": "Saved and update pushed to machine.", "Saved. Machine will apply on next sync/reboot.": "Saved. Machine will apply on next sync/reboot.", "No data": "No data", + "entries": "entries", + "Search name or category...": "Search name or category...", "Back": "Back", "Rename": "Rename", "Content Settings": "Content Settings", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index 9b92b62..206969e 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -2349,6 +2349,8 @@ "Saved and update pushed to machine.": "已儲存,並已推送更新到機台(機台將立即重拉並套用)。", "Saved. Machine will apply on next sync/reboot.": "已儲存。推送未成功(機台可能離線),將於下次同步/重開機時套用。", "No data": "無資料", + "entries": "筆", + "Search name or category...": "搜尋名稱或類別…", "Back": "返回", "Rename": "重新命名", "Content Settings": "內容設定", diff --git a/resources/views/admin/app/ui-elements/index.blade.php b/resources/views/admin/app/ui-elements/index.blade.php index 168198b..2055969 100644 --- a/resources/views/admin/app/ui-elements/index.blade.php +++ b/resources/views/admin/app/ui-elements/index.blade.php @@ -9,6 +9,28 @@ + {{-- 控制列:每頁筆數 + 搜尋 --}} +
+