1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

feat: Aggiunto metodo per ottenere tutti i model come opzioni di una select

This commit is contained in:
Maicol Battistini
2022-01-27 18:53:40 +01:00
parent bed410e2df
commit c63755d1ac

View File

@@ -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<SelectOptionsT> {
const response = await model.all();
const categories = response.getData();
return categories.map((instance: IModel) => ({
value: instance.getId() as string,
label: instance[labelAttribute] as string
}));
}
}