UserInterfaceService

UserInterfaceService TypeScript Class Reference

Overview

SERVICE This class is a "service" and it is automatically injected if declared as a member in the constructor of the consuming class. - See the constructor section below for details - See the Automatic Instance Injection page for details on the topic

The UserInterfaceService class provides methods to manage the user interface of the application. It is used mostly to drive the navigation between steps within the current UI task.

No properties

Executes UI navigation a route. If the route is "validating", the framework will call the current view's validate and commit methods. It will call then the final method and will initiate the rendering process of the view targeted by the route. This is the most frequently used method to navigate between steps in the current UI task.

Do not place code after the navigate method as the navigation transition might cause unpredictable results from the code executed after.

▶️ cancel(): void

Cancels the current UI task and navigates back to the Home task

Do not place code after the cancel method as the navigation transition might cause unpredictable results from the code executed after.

▶️ launchTask(taskId: string, stepId: string, preserveContext: boolean): void

Starts UI task with given id and initiates the rendering process of the first view in the UI task.

Do not place code after the launchTask method as the navigation transition might cause unpredictable results from the code executed after.

▶️ showLoading(): Promise<void>

Displays a preloader panel (infinite loader) on the screen, which blocks the user interface. The preloader is usually used in comnbination with method hideLoading , which hides the preloader.

The showLoading and hideLoading methods are used around logic executions which takes longer.

Methods showError and showMessage will automatically hide the preloader displayed via showLoading method.

▶️ hideLoading(): Promise<void>

Hides the preloader panel (infinite loader) previously displayed with a call to showLoading. There is no side effect if the method is called several times.

▶️ showMessage(message: string): Promise<void>

Shows modal message box on the screen and hides preloader displayed via showLoading

▶️ showError(error: string | Error): Promise<void>

Shows error modal message box on the screen and hides preloader displayed via showLoading

▶️showToast(toast: string): Promise<void>

Shows a temporary non modal message, which disappears automatically after few seconds

▶️ getCurrentaskId(): Promise<string>

Returns Id if the task which is currently active. It is supposed to be called in the context of active task and id. It may return undefined in some cases.

How to use

import {View, UserInterfaceService} from '@dms'

@View
export class MyView {

    //declare UserInterfaceServece as view's member
    //so the framework will inject UserInterfaceServece instance automatically
    constructor(private UserInterfaceService: UserInterfaceService){

    }

    async resume(){
        //show toast message to the user
        this.UserInterfaceService.showToast("View's resume method was caled");
    }

    myViewMethod(){
        //navigate to a route with name save
        this.UserInterfaceService.navigate("save");
    }
}

Last updated

Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | sales@dynamicsmobile.com