define('application/models/production/menu/menuitem', [
'rofl/models/api/abstract',
'application/models/production/menu/action'
], function (
Abstract,
Action
) {
'use strict';
return Abstract.extend({
/**
* Initialises the Menu model.
*
* @param {Object} data - The data.
*/
init: function (data) {
data = data || {};
this._label = data._label || null;
this._icon = data._icon || null;
this._id = data._id || null;
this._type = data.type || '';
this._children = data._children || [];
this._action = new Action({
route: data.route,
args: data.args
});
},
/**
* Returns the menu item label.
*
* @returns {string} - The menu item label.
*/
getLabel: function () {
return this._label;
},
/**
* Returns the menu item icon.
*
* @returns {string} - The menu item icon.
*/
getIcon: function () {
return this._icon;
},
/**
* Returns the menu item id.
*
* @returns {string/number} - The menu item id.
*/
getId: function () {
return this._id;
},
/**
* Gets the type.
*
* @returns {string|null} - The type or null if not set.
*/
getType: function () {
return this._type;
},
/**
* Checks if this menu item has children.
*
* @returns {boolean} - Whether it has children.
*/
hasChildren: function () {
return this._children.length > 0;
},
/**
* Gets the children.
*
* @returns {Array} - The children.
*/
getChildren: function () {
return this._children;
},
/**
* Checks if this menu item has children.
*
* @returns {boolean} - Whether it has submenu.
*/
hasSubmenu: function () {
return this._children.length > 0;
},
/**
* Gets the action.
*
* @returns {MenuAction} - The menu action.
*/
getAction: function () {
return this._action;
}
});
});