Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseController

Hierarchy

  • BaseController

Index

Constructors

constructor

Properties

_APIEndpoint

_APIEndpoint: string

_eventService

_eventService: EventService

_extraStoreFunctionality

_extraStoreFunctionality: Module<string, any>

Extra store functionality can added through the store service

_goToPageAfterCreateAction

_goToPageAfterCreateAction: () => void

Type declaration

    • (): void
    • Returns void

_goToPageAfterDeleteAction

_goToPageAfterDeleteAction: () => void

Type declaration

    • (): void
    • Returns void

_goToPageAfterEditAction

_goToPageAfterEditAction: (id: any) => void

Set the routes to go to after a certain action has been done by the store Can be edited/overwritten in controller

Type declaration

    • (id: any): void
    • Parameters

      • id: any

      Returns void

_routeSettings

_routeSettings: RouteSettings

Initiate basic route settings Settings can be changed in controller

_routerService

_routerService: RouterService

_storeService

_storeService: StoreService

_translatorService

_translatorService: TranslatorService

Accessors

APIEndpoint

  • get APIEndpoint(): string

basePage

  • get basePage(): { mounted: () => Promise<any>; render: (h: CreateElement) => any }
  • The base page for the current controller Sned a read request to the server on mount

    Returns { mounted: () => Promise<any>; render: (h: CreateElement) => any }

    • mounted: () => Promise<any>
        • (): Promise<any>
        • Returns Promise<any>

    • render: (h: CreateElement) => any
        • (h: CreateElement): any
        • Parameters

          • h: CreateElement

          Returns any

create

  • get create(): (item: Item, goToRouteName: string) => Promise<void>
  • Send a create to the api

    Returns (item: Item, goToRouteName: string) => Promise<void>

      • (item: Item, goToRouteName: string): Promise<void>
      • Parameters

        • item: Item

          The item with the information to be created

        • goToRouteName: string

        Returns Promise<void>

createPage

  • get createPage(): Component

destroy

  • get destroy(): (id: string | number, goToRouteName: string) => Promise<void>
  • Send a delete to the api

    Returns (id: string | number, goToRouteName: string) => Promise<void>

      • (id: string | number, goToRouteName: string): Promise<void>
      • Parameters

        • id: string | number

          The id of the item to be deleted

        • goToRouteName: string

        Returns Promise<void>

destroyByCurrentRouteId

  • get destroyByCurrentRouteId(): () => Promise<void>
  • Send a delete with current route id to the api

    Returns () => Promise<void>

      • (): Promise<void>
      • Returns Promise<void>

destroyByCurrentRouteIdModal

  • get destroyByCurrentRouteIdModal(): () => void
  • Shows a modal with the standard destroy modal message. On OK will send a destroy request based on the current route id

    Returns () => void

      • (): void
      • Returns void

destroyByIdModal

  • get destroyByIdModal(): (id: any) => void
  • Shows a modal with the standard destroy modal message. On OK will send a destroy request based on the given id

    Returns (id: any) => void

      • (id: any): void
      • Parameters

        • id: any

        Returns void

destroyByIdWithoutRouteChange

  • get destroyByIdWithoutRouteChange(): (id: string | number) => Promise<any>
  • Send a delete to the api without changing route afterwards

    Returns (id: string | number) => Promise<any>

      • (id: string | number): Promise<any>
      • Parameters

        • id: string | number

          The id of the item to be deleted

        Returns Promise<any>

destroyModalMessage

  • get destroyModalMessage(): string

editPage

  • get editPage(): Component

getByCurrentRouteId

  • get getByCurrentRouteId(): () => Item

overviewPage

  • get overviewPage(): Component

read

  • get read(): () => Promise<any>
  • Send a read request for the current controller StoreService will catch the data and put it in store

    Returns () => Promise<any>

      • (): Promise<any>
      • Returns Promise<any>

routeSettings

show

  • get show(): (id: string | number) => Promise<any>
  • Send a read request for an item with the given id StoreService will catch the data and put it in store

    Returns (id: string | number) => Promise<any>

      • (id: string | number): Promise<any>
      • Parameters

        • id: string | number

          the id of the item to read from the server

        Returns Promise<any>

showByCurrentRouteId

  • get showByCurrentRouteId(): () => Promise<any>
  • Send a read request for an item with id of the current route StoreService will catch the data and put it in store

    Returns () => Promise<any>

      • (): Promise<any>
      • Returns Promise<any>

showPage

  • get showPage(): Component

update

  • get update(): (item: Item, goToRouteName: string) => Promise<void>
  • Send an update to the api

    Returns (item: Item, goToRouteName: string) => Promise<void>

      • (item: Item, goToRouteName: string): Promise<void>
      • Parameters

        • item: Item

          The item with the information to be updated

        • goToRouteName: string

        Returns Promise<void>

Methods

createAndSetExtraGetAction

  • createAndSetExtraGetAction(name: string, options: AxiosRequestConfig): void
  • create a new action to add to the store which sends a get request url for the new request will be: this.APIEndpoint + payload ? /${payload} : ''

    Parameters

    • name: string

      name of the new action

    • options: AxiosRequestConfig

    Returns void

createAndSetExtraPostAction

  • createAndSetExtraPostAction(name: string): void
  • create a new action to add to the store which sends a post request url for the post request will be: `${this.APIEndpoint}/${payload.id}/${name}

    Parameters

    • name: string

      name of the new action and the last part of the url

    Returns void

dispatchToStore

  • dispatchToStore(action: string, payload: any): void
  • dispatch an action to the store

    Parameters

    • action: string

      the name of the action being dispatched

    • payload: any

      the payload being used by the action

    Returns void

getAll

  • getAll(): any

getAllFrom

  • getAllFrom(moduleName: string): Item[]
  • Get alle items from the given moduleName If moduleName is not found throws a StoreModuleNotFoundError

    throws

    {StoreModuleNotFoundError}

    Parameters

    • moduleName: string

      moduleName to get all items from

    Returns Item[]

getById

  • getById(id: number): Item
  • Get an item from the store based on the given id

    Parameters

    • id: number

      get the item from the store base don id

    Returns Item

goToCreatePage

  • goToCreatePage(query?: {}): void
  • Go to the create page for this controller

    Parameters

    • Optional query: {}
      • [x: string]: string

    Returns void

goToEditPage

  • goToEditPage(id: string | number, query?: {}): void
  • Go to the edit page for this controller

    Parameters

    • id: string | number
    • Optional query: {}
      • [x: string]: string

    Returns void

goToOverviewPage

  • goToOverviewPage(): void

goToShowPage

  • goToShowPage(id: string | number): void
  • go the the show page for the given item of the given id

    Parameters

    • id: string | number

      id of item to go to the show page

    Returns void

init

  • init(): void
  • init the controller this will add a module to the store and register routes

    Returns void

popModal

  • popModal(message: string, okAction: Function, cancelAction?: Function): void
  • pops up a modal with the given message

    Parameters

    • message: string

      the message being shown by the modal

    • okAction: Function

      the function being used when click on ok

    • Optional cancelAction: Function

    Returns void

setExtraStoreAction

  • setExtraStoreAction(name: string, action: ActionMethod): void
  • Add an extra action to this store module

    Parameters

    • name: string
    • action: ActionMethod

    Returns void

setExtraStoreGetter

  • setExtraStoreGetter(name: string, getter: GetterMethod): void

setExtraStoreMutation

  • setExtraStoreMutation(name: string, mutation: MutationMethod): void
  • Add an extra mutation to this store module

    Parameters

    • name: string
    • mutation: MutationMethod

    Returns void

Generated using TypeDoc