/// class PD.Manage.Modules.UserBatchEditDialog
// using PD.Web.UI.Dialog

PD.Manage.Modules.UserBatchEditDialog =
PD.Web.UI.Dialog.extend({

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

    _uploadInput: null,

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

    init: function (options) {

        this._super($.extend(true, {
            config: {
                resizable: false,
                width: "400px",
                title: "User Bulk Edit"
            }
        }, options));

    },

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

    get_okButton: function () {
        return this.get_node().find("BUTTON[data-id=ok]");
    },

    get_cancelButton: function () {
        return this.get_node().find("BUTTON[data-id=cancel]");
    },

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

    onInit: function () {

    },

    onActivate: function () {
        this.get_okButton().on("click", _.bind(this.okButton_onClick, this));
        this.get_cancelButton().on("click", _.bind(this.cancelButton_onClick, this));
    },

    okButton_onClick: function () {

        var licensedVal = this.get_node().find("[data-role=ddl-licensed]").val();
        var disabledVal = this.get_node().find("[data-role=ddl-disabled]").val();

        licensedVal = (licensedVal == "" ? null : licensedVal);
        disabledVal = (disabledVal == "" ? null : (disabledVal == "true" ? true : false));

        if (licensedVal == null && disabledVal == null) {
            this.close();
            return;
        }

        this.close({
            command: "ok",
            data: {
                licensed: licensedVal,
                disabled: disabledVal
            }
        });

    },

    cancelButton_onClick: function () {
        this.close();
    },

    //===================================
    // PROTECTED METHODS
    //===================================

    template: function (e) {

        return [
            "<div class='-pd-user-batch-edit-dialog'>",
                "<div data-role='description'>",
                    "Bulk edit 'Licensed' and 'Disabled' values for each selected user.",
                "</div>",
                "<div data-role='content'>",
                    "<div data-role='group'>",
                        "<div data-role='title'>License:</div>",
                        "<select data-role='ddl-licensed'>",
                            "<option value=''>No Change</option>",
                            "<option value='0'>Not Licensed</option>",
                            "<option value='1'>Full</option>",
                            "<option value='2'>Read-Only</option>",
                        "</select>",
                    "</div>",
                    "<div data-role='group'>",
                        "<div data-role='title'>Disabled:</div>",
                        "<select data-role='ddl-disabled'>",
                            "<option value=''>No Change</option>",
                            "<option value='true'>True</option>",
                            "<option value='false'>False</option>",
                        "</select>",
                    "</div>",
                "</div>",
                "<div class='-pd-dialog-button-deck'>",
                    "<button class='-pd-button' data-id='ok'>OK</button>",
                    "<button class='-pd-button' data-id='cancel'>Cancel</button>",
                "</div>",
            "</div>"
        ];

    }

});

PD.Manage.Modules.UserBatchEditDialog.open =
function (options) {
    return new PD.Manage.Modules.UserBatchEditDialog(options);
};