/// class ProspectDirector.Web.UI.Canvas.Charts.RemoveField
/// using ProspectDirector.Web.UI.Canvas.Charts.FieldListCommand

/**
@class RemoveField
@constructor
@namespace Web.UI.Canvas.Charts
@extends Web.UI.Canvas.Charts.FieldListCommand
**/
ProspectDirector.Web.UI.Canvas.Charts.RemoveField = ProspectDirector.Web.UI.Canvas.Charts.FieldListCommand.extend({

    //===================================
    // PUBLIC METHODS
    //===================================

    execute: function () {

        var editor = this.get_editor(),
            selection = this.get_editor().get_selection(),
            selections = selection.get_selections(),
            keys = selections.toKeysList();

        keys.each(function (index, key) {

            var field = selections.findByPrimaryKey(key);

            selection.remove(field);

            editor.remove(field.id);

        });

    }

});