src/models/navigation/PlatformMenu.js
/**
* Model representing a platform menu.
*/
class PlatformMenuModel {
/**
* @param {Object} response - JSON formatted response of a single platform menu
* @param {!Number} response.id - The id of the platform menu on the server
* @param {!String} response.type - The type of this object ('platform menus')
* @param {!String} response.title - Title
* @param {Number} response.position - Position in which to sort
* @param {String} response.url - Url for target
* @param {Boolean} response.enabled - Is this enabled
* @param {String} response.icon - Icon class used by CSS to determine image
* @param {String} response.access_class - Access class
*/
constructor(response = {}) {
const _response = response.data || response; // if json api is passed in directly
const attributes = _response.attributes || _response; // if json api is passed in directly
if (_response.id) {
/** @type {Number} */
this.id = parseInt(_response.id, 10);
}
/** @type {String} */
this.title = attributes.title;
/** @type {Number} */
this.position = attributes.position;
/** @type {String} */
this.url = attributes.url;
/** @type {Boolean} */
this.enabled = attributes.enabled;
/** @type {String} */
this.icon = attributes.icon;
/** @type {String} */
this.accessClass = attributes.access_class;
}
}
export default PlatformMenuModel;