From c63755d1ac0f1ea1b89e560e1f1cb3f1a5f33dc6 Mon Sep 17 00:00:00 2001 From: Maicol Battistini Date: Thu, 27 Jan 2022 18:53:40 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Aggiunto=20metodo=20per=20o?= =?UTF-8?q?ttenere=20tutti=20i=20model=20come=20opzioni=20di=20una=20selec?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/Components/Pages/RecordsPage.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/js/Components/Pages/RecordsPage.tsx b/resources/js/Components/Pages/RecordsPage.tsx index 59caa7cc4..864644795 100644 --- a/resources/js/Components/Pages/RecordsPage.tsx +++ b/resources/js/Components/Pages/RecordsPage.tsx @@ -26,6 +26,7 @@ import { } from '../../Models'; import type { FieldT, + SelectOptionsT, SelectT, TextAreaT, TextFieldT @@ -539,4 +540,14 @@ export class RecordsPage extends Page { return list.join(''); } + + async getModelSelectOptions(model: typeof Model, labelAttribute: string): Promise { + const response = await model.all(); + const categories = response.getData(); + + return categories.map((instance: IModel) => ({ + value: instance.getId() as string, + label: instance[labelAttribute] as string + })); + } }