/// class ProspectDirector.Modules.ExplorerModel.Forms.FeatureViewDesign
/// using ProspectDirector.Types.Core.Feature

/**
@class FeatureViewDesign
@namespace ProspectDirector.Modules.ExplorerModel.Forms
**/
ProspectDirector.Modules.ExplorerModel.Forms.FeatureViewDesign = ProspectDirector.Types.Core.Feature.extend({

    //---------------------------
    //--- CONSTRUCTOR
    //---------------------------

    init: function (options) {

        this._super(options);

        this.init_feature();

    },

    //---------------------------
    //--- PROPERTIES
    //---------------------------

    get_radioTrue: function () {
        return this.get_container().find("INPUT[data-id=built-in-false]");
    },

    get_radioFalse: function () {
        return this.get_container().find("INPUT[data-id=built-in-true]");
    },

    get_buttonEdit: function () {
        return this.get_container().find("INPUT[type=button]");
    },

    //---------------------------
    //--- INITIALIZERS
    //---------------------------

    init_feature: function () {

        this.get_radioTrue().on("change", $.proxy(this.radio_onChange, this));
        this.get_radioFalse().on("change", $.proxy(this.radio_onChange, this));
        this.get_buttonEdit().on("click", $.proxy(this.buttonEdit_onClick, this));
        this.updateState();

    },

    //---------------------------
    //--- EVENT HANDLERS
    //---------------------------

    buttonEdit_onClick: function (e) {

        ProspectDirector.Types.Core.Dialogs.ViewEditor.show({
            config: {
                actions: ["Maximize", "Close"],
                resizable: true,
                width: 800,
                height: 500
            },
            params: {
                viewId: this.options.data.viewId
            }
        });

    },

    radio_onChange: function (e) {
        this.updateState();
    },

    updateState: function () {
        
        var enabled = this.get_radioTrue().is(":checked") || !this.options.data.useBuiltInSupported;

        this.get_buttonEdit().enabled(enabled);

    }

});