runFunction method
Implementation
Future<dynamic> runFunction(BuildContext context, CMSAction action) async {
try {
final variable = getVariable(context, action);
if (action is CMSInsertAction) {
if (variable.data is! Map<String, dynamic>) {
throw Exception('Data must be a Map');
}
return await add(context.pageCubit, action, jsonDecode(variable.data));
} else if (action is CMSUpdateAction) {
if (variable.data is! Map<String, dynamic>) {
throw Exception('Data must be a Map');
}
return await update(
context.pageCubit, action, jsonDecode(variable.data));
} else if (action is CMSDeleteAction) {
return await remove(context.pageCubit, action);
} else if (action is CMSQueryAction) {
return await get(context, context.pageCubit, action, variable);
}
} catch (e) {
context.logsCubit.onNewLog(
EditorLogEntity(
id: _uuid.v1(),
content: e.toString(),
createdAt: DateTime.now(),
),
);
}
return;
}