Skip to content

Instantly share code, notes, and snippets.

@htammen
Created July 17, 2019 13:47
Show Gist options
  • Save htammen/e2a3eb56261de0010876c6c3105f360f to your computer and use it in GitHub Desktop.
Save htammen/e2a3eb56261de0010876c6c3105f360f to your computer and use it in GitHub Desktop.
Typescript type definitions for sample UI5 Typescript project
declare namespace de {
namespace tammenit {
namespace ui5 {
namespace AppAdminApp {
export class Component extends sap.ui.core.UIComponent {
/**
* returns the main Model of the application
*
* @returns {sap.ui.model.json.JSONModel} the main model of the application
* @memberof Component
*/
public getMainModel(): sap.ui.model.json.JSONModel
/**
* reads the application data / List of applications from backend
* @returns ein Promise, das mit ApplicationData resolved
*/
public getApplications(): Promise<Array<de.hessen.hzd.service_hessen.prov.AppAdminApp.data.ApplicationData>>
}
namespace controller {
export class BaseController extends sap.ui.core.mvc.Controller {
/**
* Convenience method for accessing the router in every controller of the application.
* @public
* @returns {sap.ui.core.routing.Router} the router for this component
*/
getRouter(): sap.ui.core.routing.Router;
/**
* Convenience method for getting the view model by name in every controller of the application.
* @public
* @param {string} sName the model name
* @returns {sap.ui.model.json.JSONModel} the model instance
*/
getModel(sName?: String): sap.ui.model.json.JSONModel;
/**
* Convenience method for setting the view model in every controller of the application.
* @public
* @param {sap.ui.model.json.JSONModel} oModel the model instance
* @param {string} sName the model name
* @returns {sap.ui.mvc.View} the view instance
*/
setModel(oModel: sap.ui.model.json.JSONModel, sName: string): void;
/**
* Convenience method for getting the resource bundle.
* @public
* @returns {sap.base.i18n.ResourceBundle} the resourceBundle of the component
*/
getResourceBundle(): { getText(value: string): string, setText(value: string): void };
/**
* Event handler for navigating back.
* It checks if there is a history entry. If yes, history.go(-1) will happen.
* If not, it will replace the current entry of the browser history with the master route.
* @public
*/
onNavBack(): void;
/**
* gets the application main component. Technically its the return value of UIComponent.getOwnerComponent
* casted to the concrete class of ...AppAdminApp.Component
*
* @returns {de.hessen.hzd.service_hessen.prov.AppAdminApp.Component}
* @memberof BaseController
*/
getOwnerAppComponent(): de.hessen.hzd.service_hessen.prov.AppAdminApp.Component
}
}
namespace data {
enum AppAdminAppRoleType {
ADMIN,
RESPONSIBLE
}
/**
* Simple JSON result from backend. In some cases we just receive the string
* "success", "error" or a message that describes the error in more Detail e.g.
* "Data could not be loaded".
* The latter case schould only be an exception cause the backend shouldn't deliver
* texts but just status codes
*/
export interface SimpleJSONResult {
/** result as string e.g. success or error */
result: string,
/** a more detailed message that describes the error or the result */
msg?: string
}
/**
* Date structure for applications that are available for user, admin, ...
*/
export interface ApplicationData {
/** application id */
appId: string
/** application name */
appName: string
/** application description */
appDescription: string
}
/**
* A user of the application, means either an app admininstator or app responsible
*/
export interface ApplicationUser {
/** unique user id */
userId: string
/** Name of User */
name: string
/** EMail address of Users */
email: string
}
/**
* Anwendungsadministratoren und Anwendungsverantwortliche zusammengefasst in einem Objekt
*/
export interface ApplicationUsers {
/** List of app administrators */
admins: Array<ApplicationUser>
/** List of app responsibles */
resonsibles: Array<ApplicationUser>
/** additional data used in UI layer */
uidata?: {
appId: string
appName: string
appDescription: string
}
}
/**
* Data of the main model
*/
export interface MainModelData {
/** list of applications available for the current user */
applications?: Array<ApplicationData>
/** data of the currently selected application */
currentApplication?: ApplicationUsers
}
}
}
}
}
}
declare namespace sap.ui.base.input {
namespace event {
interface Lifechange extends sap.ui.base.Event {
getSource(): sap.ui.base.EventProvider
getParameter(param: "value" | "escPressed" | "previousValue"): (string | boolean)
}
}
}
declare namespace sap.ui.core.routing.target.Event {
interface Display extends sap.ui.base.Event {
getSource(): sap.ui.base.EventProvider
getParameter(param: "view" | "control" | "config" | "data"): object
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment