src/snorlogue/frontend/pageContexts

Source   Edit  

Provides PageContext objects necessary and procs to construct them. Each nimja template has its own type of PageContext, as such a context provides the data that gets rendered into the nimja template to create a snorlogue page.

Types

ConfigurationContext = object of PageContext
  port*: int
  debug*: bool
  address*: string
  routes*: Table[string, seq[string]]
Context for the CONFIG page Source   Edit  
ModelCreateContext[T] = object of PageContext
  modelName*: string
  listUrl*: string
  createUrl*: string
  fields*: seq[FormField]
  hasFileField*: bool
Context for the CREATE page Source   Edit  
ModelDeleteContext[T] = object of PageContext
  deleteUrl*: string
  detailUrl*: string
  model*: T
  modelName*: string
Context for the DELETE page Source   Edit  
ModelDetailContext[T] = object of PageContext
  modelName*: string
  model*: T
  fields*: seq[FormField]
  hasFileField*: bool
  fkOptions*: Table[string, IntOption]
  deleteUrl*: string
  updateUrl*: string
  listUrl*: string
Context for the DETAIL page Source   Edit  
ModelListContext[T] = object of PageContext
  modelName*: string
  models*: seq[T]
  totalModelCount*: int64
  deleteUrlStub*: string
  createUrl*: string
  detailUrlStub*: string
  listUrlStub*: string
  pageIndices*: seq[int]
  currentPageIndex*: int
  isFirstPage*: bool
  isLastPage*: bool
Context for the LIST page Source   Edit  
OverviewContext = object of PageContext
  modelLinks*: OrderedTable[ModelMetaData, string]
Context for the OVERVIEW page Source   Edit  
PageContext = object of RootObj
  currentPage*: Page
  currentUrl*: string
  overviewUrl*: string
  sqlUrl*: string
  aboutApplicationUrl*: string
  projectName*: string
  modelTypes*: seq[ModelMetaData]
Base amount of data needed in a context for any snorlogue page. Defines all fields required by the root template of all pages. Source   Edit  
SqlContext = object of PageContext
  query*: string
  rows*: Option[seq[Row]]
  columns*: Option[seq[string]]
  queryErrorMsg*: Option[string]
Context for the SQL page Source   Edit  

Procs

proc hasFileField(fields: seq[FormField]): bool {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc initAboutApplicationContext(urlPrefix: static string; settings: Settings;
                                 routes: Table[string, seq[string]]): ConfigurationContext
Generates the context for the CONFIG page Source   Edit  
proc initCreateContext[T: Model](model: T; urlPrefix: static string;
                                 settings: Settings): ModelCreateContext[T]
Generates the context for a CREATE page Source   Edit  
proc initDeleteContext[T: Model](model: T; urlPrefix: static string;
                                 settings: Settings): ModelDeleteContext[T]
Generates the context for a DELETE page Source   Edit  
proc initDetailContext[T: Model](model: T; urlPrefix: static string;
                                 settings: Settings): ModelDetailContext[T]
Generates the context for a DETAIL page Source   Edit  
proc initListContext[T](models: seq[T]; urlPrefix: static string;
                        settings: Settings; totalModelCount: int64;
                        pageIndex: int; pageSize: int): ModelListContext[T]
Generates the context for a LIST page Source   Edit  
proc initOverviewContext(metaDataEntries: seq[ModelMetaData];
                         urlPrefix: static string; settings: Settings): OverviewContext
Generates the context for a OVERVIEW page Source   Edit  
proc initSqlContext(urlPrefix: static string; settings: Settings; query: string;
                    rows: Option[seq[Row]]; columnNames: Option[seq[string]];
                    errorMsg: Option[string]): SqlContext
Generates the context for the SQL page Source   Edit