AppMenuService
Extends:
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 |
|
|
public |
|
|
public |
async getActionDetails(params: Object): Promise Call a GET request expecting JSON API information. |
|
public |
|
|
public |
|
|
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 |
Call a DELETE request on the main obj.type expecting JSON API information. |
|
public |
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 |
Call a POST request on the main obj.type expecting JSON API information. |
|
public |
Call a PATCH request on the main obj.type expecting JSON API information. |
Public Constructors
Public Methods
public async clearStorageMenus(menu: AppMenu) source
Params:
Name | Type | Attribute | Description |
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#deleteParams:
Name | Type | Attribute | Description |
appMenu | AppMenu | AppMenu object in which to update |
|
options | Object |
|
Options to modify the network call and storage options |
options.cacheMode | String |
|
Override the caching method for this call |
options.cascade | Boolean |
|
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 |
Throw:
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:
- [unit] AppMenuService.delete should exist
- [unit] AppMenuService.delete should throw errors for invalid parameters
- [unit] AppMenuService.delete should make a properly formatted delete request
- [unit] AppMenuService.delete should receive a valid response for a delete request
- [unit] AppMenuService.delete should make a properly formatted delete request with cascade is false
- [unit] AppMenuService.delete should make a properly formatted delete request with cascade=true when appMenu has sub-menus
- [unit] AppMenuService.delete should remove the element from local storage
- [unit] AppMenuService.delete should also delete the children (submenus)
public async get(params: Object, cacheMode: String): Promise<AppMenu[]|AppMenu> source
Call a GET request expecting JSON API information.
Override:
JsonApiService#getReturn:
Promise<AppMenu[]|AppMenu> | Promise object that returns one appMenu or a key:appMenu hashtable |
Throw:
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));
public async getActionDetails(params: Object): Promise source
Call a GET request expecting JSON API information.
Throw:
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));
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#insertExample:
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();
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#updateExample:
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();
public async updateOrder(order: AppMenu[], cacheMode: String): Promise<AppMenu[]> source
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));