/// class PD.Manage.Modules.EntityManagementContextMenu
// using PD.Web.UI.Controls.ContextMenuSegment

PD.Manage.Modules.EntityManagementContextMenu =
PD.Web.UI.Controls.ContextMenuSegment.extend({

    //===================================
    // EVENT HANDLERS
    //===================================

    onRegisterItems: function (e) {

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/entity-management:entity/open"
        }));

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/entity-management:entity/change-status"
        }));

        e.addSeparator();

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/entity-management:entity/delete"
        }));

        e.addSeparator();

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/entity-management:entity/properties-dialog"
        }));


    },

    onOpen: function (e) {
        
        var grid = this.get_context()["grid"];
        var selection = _.first(grid.getSelections().toArray());

        PD.context.get_default().get_commands().setState({
            "pd/entity-management/context-menu": {
                entities: selection
            }
        });

    }

});