/// class PD.Actions.ActionManager

PD.Actions.ActionManager =
Class.extend({

    //===================================
    // FIELDS
    //===================================

    _actions: null,

    //===================================
    // CONSTRUCTOR
    //===================================

    init: function () {
        this._actions = {};
    },

    //===================================
    // METHODS
    //===================================

    hasActions: function () {
        return _.keys(this._actions).length > 0;
    },

    getActionDefinitions: function () {
        return _.clone(this._actions);
    },

    addActionDefinition: function (action) {

        var actionId = action.get_id();

        if (!(actionId in this._actions)) {
            this._actions[actionId] = action;
        }

    },

    removeAction: function (action) {

        var actionId = null;
        var isActionId = _.isString(action);
    
        if (isActionId) {
            actionId = action;
        }
        else {
            actionId = action.get_id();
        }

        delete this._actions[actionId];

    },

    getActionDefinitionById: function (id) {

        var result = null;
    
        if (this._actions[id] != null) {
            result = this._actions[id];
        }

        return result;

    }

});