Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Message

JMap.Application.Message

You can manage the application Messages here.

Index

Functions

closeWaitingOverlay

  • closeWaitingOverlay(messageId?: undefined | string): void
  • JMap.Application.Message.closeWaitingOverlay

    Close all overlay messages or just one.

    If no overlay is displayed, do nothing.

    throws

    if you pass a message id that is not found

    example
    
    // display a waiting overlay, making the app unavailable for user as long it is displayed
    const messageId = JMap.Application.Message.displayWaitingOverlay("Please wait, processing data")
    // NG app is now unavailable for the user
    // You can do some asynchronous processing
    myAsyncProcess()
     .then(() => {
       // close the waiting overlay
       JMap.Application.Message.closeWaitingOverlay(messageId)
       // NG App is now available again
       JMap.Application.Message.success("The process was successfully completed")
     })
     .catch(error => {
       // close the waiting overlay
       JMap.Application.Message.closeWaitingOverlay(messageId)
       // NG App is now available again
       console.error(error)
       JMap.Application.Message.error("An error has occurred while processing")
     })

    Parameters

    • Optional messageId: undefined | string

      the message to close

    Returns void

confirmMessage

  • JMap.Application.Message.confirmMessage

    Prompts a confirmation dialog message on the screen.

    The onSuccess callback is called when the user clicked "confirm" button.

    If it's an input confirm message, the onSuccess will get the input, else an empty string.

    The optional onCancel callback is called when the cancel button is clicked.

    example
    
    JMap.Application.Message.confirmMessage({
      message: "Are you sure to do a given action ?",
      onSuccess: () => console.log(`The user is sure`),
      onCancel: () => console.info("The user is not sure")
    })
    
    JMap.Application.Message.confirmMessage({
      message: "City name :",
      isInputMessage: true,
      onSuccess: cityName => console.log(`City name input = ${cityName}`),
      onCancel: () => console.info("Input has been canceled")
    })

    Parameters

    Returns void

display

  • JMap.Application.Message.display

    Adds an generic message in the application message stack for the current session. severity level should be passed (will default to "info")

    example
    
    const message = "The operation has failed"
    const level = "error"
    JMap.Application.Message.display(message, { duration: 5000 , severity: level})

    Parameters

    • message: string

      the text of the message

    • Optional options: JAppMessageOptions

      a JAppMessageOptions object

    Returns void

displayWaitingOverlay

  • displayWaitingOverlay(message: string): string
  • JMap.Application.Message.displayWaitingOverlay

    Opens an overlay panel that displays your message and a loading bar.

    User cannot hide or close this overlay, it aims to avoid user interactions while you are doing an async processing.

    If overlay is already displaying a previous message, it will display only the new message and hide the previous message (until you close the new message).

    Overlay is displayed all the time until you call the method JMap.Application.Message.closeWaitingOverlay.

    This method is used to close one or more messages:

    • Called without params, it will close all messages
    • Called with a messageId, it will close only the message for the given message id
    throws

    if message is not a non empty string

    example
    
    // display a waiting overlay, making the app unavailable for user as long it is displayed
    const messageId = JMap.Application.Message.displayWaitingOverlay("Please wait, processing data")
    // NG app is now unavailable for the user
    // You can do some asynchronous processing
    myAsyncProcess()
     .then(() => {
       // close the waiting overlay
       JMap.Application.Message.closeWaitingOverlay(messageId)
       // NG App is now available again
       JMap.Application.Message.success("The process was successfully completed")
     })
     .catch(error => {
       // close the waiting overlay
       JMap.Application.Message.closeWaitingOverlay(messageId)
       // NG App is now available again
       console.error(error)
       JMap.Application.Message.error("An error has occurred while processing")
     })

    Parameters

    • message: string

      the message to display

    Returns string

    the message id, usefull when you display multiple messages at the same time, but want to close only one.

error

  • JMap.Application.Message.error

    Adds an error message in the application message stack for the current session.

    example
    
    const message = "This operation is not allowed"
    JMap.Application.Message.error(message, { duration: 5000 })

    Parameters

    • message: string

      the text of the message

    • Optional options: JAppMessageOptions

      a JAppMessageOptions object

    Returns void

info

  • JMap.Application.Message.info

    Adds an info message in the application message stack for the current session.

    example
    
    const message = "You are here"
    JMap.Application.Message.info(message, { duration: 5000 })

    Parameters

    • message: string

      the text of the message

    • Optional options: JAppMessageOptions

      a JAppMessageOptions object

    Returns void

success

  • JMap.Application.Message.success

    Adds an success message in the application message stack for the current session.

    example
    
    const message = "The operation was successful"
    JMap.Application.Message.success(message, { duration: 5000 })

    Parameters

    • message: string

      the text of the message

    • Optional options: JAppMessageOptions

      a JAppMessageOptions object

    Returns void

warning

  • JMap.Application.Message.warning

    Adds an warning message in the application message stack for the current session.

    example
    
    const message = "This operation has no effect"
    JMap.Application.Message.warning(message, { duration: 5000 })

    Parameters

    • message: string

      the text of the message

    • Optional options: JAppMessageOptions

      a JAppMessageOptions object

    Returns void