/// class PD.Manage.Modules.ObjectModel.ProcessList
/// using PD.Manage.Module

PD.Manage.Modules.ObjectModel.ProcessList =
PD.Manage.Module.extend({

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

    _module: null,

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

    onActivate: function (e) {
        this._init_module();
    },

    onFocus: function () {
        if (this._module != null) {
            this._module.resize();
        }
    },

    prepare: function () {

        PD.ajax({
            url: PD.Path.resolve("~/Manage/Process/List"),
            success: (data) => {
                this.data("viewStateId", data.viewStateId);
                this.ready();
            },
            error: (e) => {
                this.error();
                e.errorHandled = true;
            }
        });

    },

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

    template: function (e) {
        return `<div style="position:absolute;inset:0;overflow:hidden;"></div>`;
    },

    //===================================
    // PRIVATE METHODS
    //===================================

    _init_module: function () {

        this._module = new PDJS.Manage.Process.ProcessesModule({
            container: $(`div[id=${this.get_id()}]`),
            viewStateId: this.data("viewStateId")
        });

    }

});