/// class PD.Manage.OverviewModule
// using PD.Manage.Module

PD.Manage.Modules.OverviewModule = PD.Manage.Module.extend({

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

    _areas: null,
    _modules: null,

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

    onInit: function (e) {

        this._areas = new PD.Manage.Modules.OverviewArea({
            insertAt: ".-pd-module-content"
        });

        this.get_children().add(this._areas);

    },

    onActivate: function (e) {

        $(this._grid).on("onModuleDoubleClick", function (e) {
            PD.context.get_global().get_events().publish("Module:Request", e.module);
        });

    },

    onComplete: function () {
        this._areas.load(this._modules);
    },

    prepare: function () {

        var that = this;
        
        PD.ajax({
            url: PD.Path.resolve("~/Manage/Overview"),
            success: function (data) {
                that.data("color", "#AA0000");
                that._modules = data;
                that.ready();
            },
            error: function (e) {
                that.error();
                e.errorHandled = true;
            }
        });

    },

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

    template: function (e) {

        return [
            "<div class='-pd-module'>",
                "<div class='-pd-module-content'>",
                "</div>",
            "</div>"
        ];

    }

});