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

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

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

    _module: null,

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

    onPrepare: function () {

        PD.ajax({
            url: PD.Path.resolve("~/Manage/Process/Index/" + this.data("targetId")),
            success: (data) => {
                this.data("processId", data.processId);
                this.data("processName", data.processName);
                this.data("label", data.processName);
                this.data("tooltip", `<div class="-pd-module-tab-tooltip-resources">Process</div>`);
                this.ready();
            },
            error: (e) => {
                that.error();
                e.errorHandled = true;
            }
        });

    },

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

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

    onRemove: function () {
        if (this._module != null) {
            this._module.destroy();
        }
    },

    //===================================
    // 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.ProcessModule({
            container: $(`div[id=${this.get_id()}]`),
            processId: this.data("processId")
        });

    }

});