# Copyright (c) 2020, JINGROW
# License: MIT. See LICENSE

import jingrow
from jingrow.model.page import Page


class ModuleProfile(Page):
	# begin: auto-generated types
	# This code is auto-generated. Do not modify anything in this block.

	from typing import TYPE_CHECKING

	if TYPE_CHECKING:
		from jingrow.core.pagetype.block_module.block_module import BlockModule
		from jingrow.types import DF

		block_modules: DF.Table[BlockModule]
		description: DF.Data | None
		module_profile_name: DF.Data
	# end: auto-generated types
	def onload(self):
		from jingrow.config import get_modules_from_all_apps

		self.set_onload("all_modules", sorted(m.get("module_name") for m in get_modules_from_all_apps()))


@jingrow.whitelist()
def get_all_modules():
	"""Return sorted list of all module names for the module editor."""
	from jingrow.config import get_modules_from_all_apps

	return sorted(m.get("module_name") for m in get_modules_from_all_apps())
