Manual Reference Source Test
import AppMenuService from 'clinical6/src/services/AppMenuService.js'
public class | source

AppMenuService

Extends:

AbstractServiceJsonApiService → AppMenuService

Service handling AppMenu calls with specific endpoints.

Constructor Summary

Public Constructor
public

Update type to be appMenus

Method Summary

Public Methods
public

async clearStorageMenus(menu: AppMenu)

public

async delete(appMenu: AppMenu, options: Object): Promise

public

async get(params: Object, cacheMode: String): Promise<AppMenu[]|AppMenu>

public

async getActionDetails(params: Object): Promise

Call a GET request expecting JSON API information.

public

async insert(appMenu: Object, cacheMode: String): Promise<AppMenu>

public

async update(appMenu: AppMenu, cacheMode: String): Promise<AppMenu>

public

async updateOrder(order: AppMenu[], cacheMode: String): Promise<AppMenu[]>

Inherited Summary

From class AbstractService
public get
public set
public
private
From class JsonApiService
public

options: *

public

async delete(obj: Object, options: String): Promise

Call a DELETE request on the main obj.type expecting JSON API information.

public

async get(params: Object, options: String): Promise

Call a GET request expecting JSON API information.

public

async getChildren(parent: Object, child: Object, options: String): Promise

Call a GET request expecting JSON API information for children given a parent.

public

async insert(obj: Object, options: String): Promise

Call a POST request on the main obj.type expecting JSON API information.

public

async update(obj: Object, options: String): Promise

Call a PATCH request on the main obj.type expecting JSON API information.

Public Constructors

public constructor() source

Update type to be appMenus

Override:

JsonApiService#constructor

Public Methods

public async clearStorageMenus(menu: AppMenu) source

Params:

NameTypeAttributeDescription
menu AppMenu

// pass parent menu in, then filter the children array to clear from storage // after the delete the clear function is chained as follows: .then(() => appMenuService.clearStorageMenus(appMenu)); // this will clear the sub-menus if cascade = true in the options being passed on the delete, for example: await appMenuService.delete(parentMenu, { cascade: true });

public async delete(appMenu: AppMenu, options: Object): Promise source

Call a DELETE request on the main obj.type expecting JSON API information.

Override:

JsonApiService#delete

Params:

NameTypeAttributeDescription
appMenu AppMenu

AppMenu object in which to update

options Object
  • optional

Options to modify the network call and storage options

options.cacheMode String
  • optional

Override the caching method for this call

options.cascade Boolean
  • optional

boolean value: if not set, defaults to false; if set to true that means there were sub-menus that can be deleted with the parent, if false, that means it can only be deleted if there are no sub-menus

Return:

Promise

Message

Throw:

Clinical6Error

If casacade param is false and there are submenus

Example:

import { appMenuService } from 'clinical6';

// You will be able to delete a appMenu using `delete`.
appMenuService.delete({ id: 23 });
// This will also clear the local storage of this type and id
// cascade will also delete sub-menus if set to true

Test:

public async get(params: Object, cacheMode: String): Promise<AppMenu[]|AppMenu> source

Call a GET request expecting JSON API information.

Override:

JsonApiService#get

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters used to get information from server (such as id)

params.id Number
  • optional

Id of the appMenu

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AppMenu[]|AppMenu>

Promise object that returns one appMenu or a key:appMenu hashtable

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { appMenuService } from 'clinical6';

// You will be able to access these appMenus using the `get` method.
appMenuService.get().then(appMenus => console.log(appMenus));

// Additionally, you can retrieve the subcategories for a specific appMenu with the `get`
// method, using the ID of the desired appMenu as a parameter.
appMenuService.get({ id: 23 }).then(appMenu => console.log(appMenu));

Test:

public async getActionDetails(params: Object): Promise source

Call a GET request expecting JSON API information.

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters used to get information from server (such as id)

params.filters Number
  • optional

Id of the appMenu

Return:

Promise

Promise object that returns one appMenu or a key:appMenu hashtable

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { appMenuService } from 'clinical6';

// You will be able to access these action details using the `getActionDetails` method.
appMenuService.getActionDetails().then(a => console.log(a));

// Additionally, we allow for filtering of the `getActionDetails` method, using the filter key.
// No filters are current supported on the platform
appMenuService.getActionDetails({ filter: { 'someFilter': 'someValue' }}).then(a => console.log(a));

Test:

public async insert(appMenu: Object, cacheMode: String): Promise<AppMenu> source

Call a POST request on the main obj.type expecting JSON API information.

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
appMenu Object
  • optional

Parameters used to get information from server (such as id)

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AppMenu>

Inserted appMenu

Example:

import { AppMenu, appMenuService } from 'clinical6';
const appMenu = new AppMenu({...});

// you can insert a appMenu using the `insert` method.
appMenuService.insert(appMenu).then(appMenu => console.log(appMenu));

// you could also just call `save` on the appMenu if it doesn't have an id, which will also
// invoke the `insert` method
appMenu.save();

Test:

public async update(appMenu: AppMenu, cacheMode: String): Promise<AppMenu> source

Call a PATCH request on the main obj.type expecting JSON API information.

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
appMenu AppMenu

AppMenu object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AppMenu>

Updated appMenu

Example:

import { AppMenu, appMenuService } from 'clinical6';
const appMenu = new AppMenu({...});

// you can update a appMenu using the `update` method.
appMenuService.update(appMenu).then(appMenu => console.log(appMenu));

// you could also just call `save` on the appMenu if it has an id, which will also
// invoke the `update` method
appMenu.save();

Test:

public async updateOrder(order: AppMenu[], cacheMode: String): Promise<AppMenu[]> source

Params:

NameTypeAttributeDescription
order AppMenu[]

Array of AppMenus to order. The desired position / parent information should be set in each AppMenu

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AppMenu[]>

Updated appMenus

Example:

import { AppMenu, appMenuService } from 'clinical6';
const appMenu1 = new AppMenu({ id: 13 });
const appMenu2 = new AppMenu({ id: 15 });
const appMenu3 = new AppMenu({ id: 16 });
const appMenu4 = new AppMenu({ id: 17 });

const order = [appMenu1, appMenu2, appMenu3, appMenu4];

// you can update the order of appMenus using the `updateOrder` method.
appMenuService.updateOrder(order).then(appMenus => console.log(appMenus));

Test: