App.ajax

The App.ajax module is responsible for all communication with the backend server.

Methods

(static) call(options, showLoaderopt, cancelTokenopt) → {Promise}

Invokes an ajax call. It returns a promise making it possible to use .then().catch() syntax.

It is mandatory to pass in an url property in the options object. All settings described in the jQuery docs is valid.

Example
App.ajax.call({
    url: App.ajax.getUrl('name-of-ajax-service', 'name-of-method'),
    dataType: 'json',
    type: 'post',
    async: true,
    data: JSON.stringify([this.valueToSendToServer, this.anotherValue])
}).then(function(data) {
    console.log('data retrieved', data);
});
Parameters:
Name Type Attributes Description
options Object

Ajax options, defaults to {dataType: 'json', type: 'post', async: true}

showLoader boolean <optional>

Show global loader (optional)

cancelToken CancelToken <optional>

Token used to cancel / abort the AJAX call prematurely (optional)

Returns:

Promise that if is resolved successfully will contain the requested data

Type
Promise

(static) connectMultipleObjects(args) → {Promise}

Connects list of objects to one single object by given relationship

Parameters:
Name Type Description
args String

Args format sample: [objectId1, relationType, direction, [oids]]

Returns:
Type
Promise

(static) entryPage(pageRef) → {Promise}

Fetches a page base on a page reference

Parameters:
Name Type Description
pageRef String
Returns:
Type
Promise

(static) getDashboard()

Deprecated:

Fetches a dashboard based on a dashboard reference

(static) getDashboardByIdHash(dashboardInfo, Promise)

Fetches a dashboard based on a dashboard reference and dashboard's unique id hash

Parameters:
Name Type Description
dashboardInfo Object

Dashboard information object

Properties
Name Type Attributes Description
dashboardRef String

Reference of dashboard to be opened

dashboardIdHash String <optional>

idHash of dashboard if available in current context

objectId String <optional>

Object Id for dashboard context

Promise Promise

that if resolved successfully will contain data about the requested dashboard.

(static) getSearch(searchRef) → {Promise}

Fetches a search based on a search config reference

Parameters:
Name Type Description
searchRef String
Returns:
Type
Promise

(static) getUrl(service, method) → {String}

Creates and url based on passed in service and method

Parameters:
Name Type Description
service String
method String
Returns:

Url constructed based on passed in service and method

Type
String

(static) getWidgetByIdHash()

Fetches a Widget info based on a widget reference

Parameters:
Name Type Attributes Description
widgetInfo.widgetRef String

Reference of widget to be opened

widgetInfo.objectId String <optional>

Object Id for widget context

widgetInfo.dashboardRef String <optional>

for generating the idHash

widgetInfo.idHash String <optional>

reuse existing if we dont need new one

Returns:

the information of the widget passed in reference

(static) openObject(objectId) → {Promise}

Fetches an object.

Example
var promise = App.ajax.openObject('1.2.3.4');
promise.then(function(data) {
// data will now contain
// {
// page: [],
// urlinfo: {
//   objectId: '1.2.3.4',
//   title: 'Part EV-00001',
//   url: '/o/Part/EV-0001'
//  }
//}
});
Parameters:
Name Type Description
objectId String
Returns:

Promise that if resolved successfully will contain data about the object

Type
Promise

(static) start(page, objectId, forcedBaseUrl) → {Promise}

The initial page to be loaded. The returned Promise will, if successful, resolve data about the start page.

Example
var promise = App.ajax.start('/goto/p/helium/Page', '1.2.3.4');
var promise.then(function(data) {
  // data will now contain:
  // {
  //   page: {},
  //   topbar: {},
  //   urlinfo: {}
  // }
});
Parameters:
Name Type Description
page String

The page to be requested

objectId String

The objectId to fetch

forcedBaseUrl String

Optional url that will override the default App.info.jsonURL

Returns:

Promise Promise that if resolved successfully will contain data about the requested page

Type
Promise