/// class PD.Manage.Modules.Resources.FolderConflictDialog
// using PD.Shared.Dialogs.TaskAlertDialog

PD.Manage.Modules.Resources.FolderConflictDialog =
PD.Shared.Dialogs.TaskAlertDialog.extend({

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

    init: function (options) {

        this._super($.extend(true, {
            config: {
                title: "Folder Conflict",
                actions: []
            }
        }, options));

    },

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

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

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

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

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

    onActivate: function (options) {
        this.get_mergeButton().on("click", _.bind(this._mergeButton_onClick, this));
        this.get_skipButton().on("click", _.bind(this._skipButton_onClick, this));
        this.get_canelButton().on("click", _.bind(this._cancelButton_onClick, this));
    },

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

    _mergeButton_onClick: function () {
        this.close({
            command: "ok",
            data: this._getResponse(2)
        });
    },

    _skipButton_onClick: function () {
        this.close({
            command: "ok",
            data: this._getResponse(1)
        });
    },

    _cancelButton_onClick: function () {
        this.close({
            command: "ok",
            data: this._getResponse(0)
        });
    },

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

    template: function (options) {
        return [
            "<div data-dialog-type='folder-conflict' class='task-alert-dialog'>",
                "<div class='-pd-task-alert-content'>",
                    "<div>",
                        "The destination already contains a folder named <b>" + this.getTag("name") + "</b><br/><br/>",
                        "Do you want to merge this folder<br/><br/>",
                        "<div class='-pd-folder-in-conflict'><b>" + this.getTag("name") + "</b><br/>" + this.getTag("targetpath") + "</div>",
                        "<div style='padding:10px 0 10px 0;'>with this one</div>",
                        "<div class='-pd-folder-in-conflict'><b>" + this.getTag("name") + "</b><br/>" + this.getTag("sourcepath") + "</div>",
                    "</div>",
                    "<div class='-pd-task-alert-repeat'>",
                        "<label>",
                            "<input type='checkbox' data-id='repeat' />&nbsp;Do this for all conflicts like this.",
                        "</label>",
                    "</div>",
                "</div>",
                "<div class='-pd-dialog-button-deck'>",
                    "<button class='-pd-button' data-id='merge'>Merge</button>",
                    "<button class='-pd-button' data-id='skip'>Skip</button>",
                    "<button class='-pd-button' data-id='cancel'>Cancel</button>",
                "</div>",
            "</div>"
        ];
    },
    
    //===================================
    // PRIVATE METHODS
    //===================================

    _getResponse: function (action) {
        return {
            action: action,
            repeat: this.get_node().find("INPUT[data-id=repeat]").is(":checked")
        };
    }

});

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