/// class ProspectDirector.Web.UI.FeatureSets.Editors.Macro.AclEditor
/// using ProspectDirector.Web.UI.FeatureSets.MacroEditorBase

ProspectDirector.Web.UI.FeatureSets.Editors.Macro.AclEditor =
    ProspectDirector.Web.UI.FeatureSets.MacroEditorBase.extend({

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

    _aclEditor: null,

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

    init: function (options) {

        this._super(options);

        var that = this;

        // this code forces a render on create, needed to get around the issue with setting a new parent on the canvas based macro editor.
        setTimeout(function () {

            that._aclEditor = new PDJS.Security.AclEditor({
                container: $("#" + that.getId() + " > DIV"),
                permissions: that.get_permissions(),
                aces: that.get_aces(),
                securableId: that.get_securableId(),
                enabled: that.get_enabled(),
                userDisplayName: that.get_userDisplayName(),
                isAdvancedAllowed: that.get_isAdvancedAllowed()
            });

        }, 100);
            
    },

    //==============================
    // PROPERTIES
    //==============================

    get_node: function () {
        return $("#" + this.getId());
    },

    get_aces: function () {
        return this.get_data().aces;
    },

    get_securableId: function () {
        return this.get_data().securableId;
    },

    get_enabled: function () {
        return this.get_data().enabled;
    },

    get_userDisplayName: function () {
        return this.get_data().userDisplayName;
    },

    get_permissions: function () {
            return this.get_data().permissions;
    },

    get_isAdvancedAllowed: function () {
        return this.get_data().isAdvancedAllowed;
    },
    
    //==============================
    // PUBLIC METHODS
    //==============================

    activate: function () {
        var that = this;
        setTimeout(function () { that._aclEditor.redraw(); }, 100);
    },

    focus: function () {
        var that = this;
        setTimeout(function () { that._aclEditor.redraw(); }, 100);
    },

    render: function () {
        return "<div id=\"" + this.getId() + "\"><div style='position:absolute;top:10px;left:10px;bottom:10px;right:10px;'></div></div>";
    },
        
    commit: function () {
        if (this._aclEditor != null) {
            this.setPrimaryValue(this._aclEditor.getAcl());
        }
    }

});