VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/tech_preview/hr/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/tech_preview/hr/output_form_mobile.js
"use strict";

// absol.form.PluginManager.push(absol.form.R.PLUGINS.PROJECT_EXPLORER, absol.form.PluginProjectExplore);
// absol.form.PluginManager.push(absol.form.R.PLUGINS.LOAD_CONTENT_DATA, absol.form.PluginLoadContentData);
// absol.form.PluginManager.push(absol.form.R.PLUGINS.SAVE_CONTENT_DATA, absol.form.PluginSaveContentData);
// absol.form.PluginManager.push(absol.form.R.PLUGINS.COMPONENT_PICKER_VIEW, absol.form.PluginFormComponent);
// absol.form.PluginManager.push(absol.form.R.PLUGINS.BUILD_COMPONENT, absol.form.PluginBuildComponent);

hr.output_form_mobile.fragmentClasses = {
    staticLoaded: false
};

//load những class viết trực tiếp từ js


//dùng để thông báo các sự kiện thay đổi dữ liệu, cập nhật hiển thị
hr.output_form_mobile.emittor = absol.form.emittor;

// hr.output_form_mobile


hr.output_form_mobile.generateOperateFunctionOfArray = function (typelist) {
    var handleCmdInsertRow;

    return handleCmdInsertRow;
}

hr.output_form_mobile.loadFormConstructorToAssembler = function (formList, typelists, mode) {
    return new Promise(function(rs, rj){
        var dict = {};
        var latestVersionForm = {};
        var caculateFunc = function(){
            typelists.forEach(function (elt, index) {
                if (typeof(elt.content) == "string") elt.content = EncodingClass.string.toVariable(elt.content);
                dict[elt.id] = elt;
            });
            typelists.forEach(function (elt, index) {
                if (
                    form_module.requireFormType.indexOf(elt.type) == -1
                    && elt.id < 0
                ){
                    var st = form_module.generateDefaultLinearMobileOutputForm({
                        database: {
                            output_forms: {items: formList},
                            typelists: {items: typelists}
                        },
                        typeDict: dict
                    }, elt.id, elt);
                    var constructor = absol.form.makeFmFragmentConstructor({
                        tag: elt.id + "_output",
                        contentViewData: st
                    });
                    absol.form.AssemblerInstance.addConstructor(constructor);
                }
            });
            formList.forEach(function (form) {
                if (!form.content.layout) return;
                if (!dict[form.typeid]) return;//fix me now
                if (dict[form.typeid].type == "structure" || dict[form.typeid].type == "extends_structure" || dict[form.typeid].type2 == "structure") {
                    if (form.content.layout.attributes.formVersion != form_module.formVersion){
                        if (!latestVersionForm[form.typeid]) {
                            var t_form = form_module.generateDefaultLinearMobileOutputForm({
                                database: {
                                    output_forms: {items: formList},
                                    typelists: {items: typelists}
                                },
                                typeDict: dict
                            }, form.typeid, dict[form.typeid]);
                            latestVersionForm[form.typeid] = {
                                layout: {},
                                circuit: {
                                    blocks: {},
                                    lines: {}
                                }
                            };
                            if (t_form !== false) {
                                var nameDict = {};
                                form_module.getNameDictOfTypelist(dict[form.typeid].content, nameDict);
                                form_module.makeLayoutFormDictionary(t_form.layout, nameDict, latestVersionForm[form.typeid]);
                                form_module.makeCircuitFormDictionary(t_form.circuit, latestVersionForm[form.typeid]);
                            }
                            else {
                                ModalElement.close();
                            }
                        }
                        form_module.convertLayoutInputFormToNewVersion(form.content.layout.children, latestVersionForm[form.typeid]);
                        form_module.convertCircuitInputFormToNewVersion(form.content.circuit, latestVersionForm[form.typeid]);
                        var t_dict = {};
                        form.content.circuit.blocks.forEach(function(elt){
                            if (!t_dict[elt.attributes.id]) {
                                t_dict[elt.attributes.id] = elt;
                            }
                            else {
                                if (!t_dict[elt.attributes.id].attributes.permissions) {
                                    t_dict[elt.attributes.id] = elt;
                                }
                            }
                        });
                        form.content.circuit.blocks = Object.values(t_dict);

                        t_dict = {};
                        form.content.circuit.lines.forEach(function(elt){
                            var text = elt.u + elt.uPin + elt.v + elt.vPin;
                            if (!t_dict[text]) {
                                t_dict[text] = elt;
                            }
                            else {
                                if (!t_dict[text].attributes.permissions) {
                                    t_dict[text] = elt;
                                }
                            }
                        });
                        form.content.circuit.lines = Object.values(t_dict);
                    }
                }
                // var formName = (form.content.attributes && form.content.attributes.name) || "not_detected";
                // var constructor = hr.output_form_mobile.fragmentClasses[formName];
                // if (constructor) {//có class viết sẵn
                //     constructor.prototype.tag = form.id + '';
                //     constructor.prototype.contentViewData = form.content;
                // }
                // else {//chưa xác địnhh
                    var constructor = absol.form.makeFmFragmentConstructor({
                        tag: '' + form.id,
                        contentViewData: form.content
                    });
                    if ((dict[form.typeid]) && (dict[form.typeid].type == "array" || dict[form.typeid].type2 == "array")) {
                        form_module.attachOnCreatedCb(form.content.layout);
                        constructor.prototype.onCreated = function () {
                            var myArrayComp = this.findViewByName(form.typeid.toString());
                            if (!myArrayComp) {
                                var t_id = dict[form.typeid].content.typeof;
                                myArrayComp = this.findViewByName("$value$");
                            }
                            myArrayComp.on('cmd_insert_row', this.handleCmdInsertRow.bind(this));
                            myArrayComp.on('cmd_remove_row', this.handleCmdRemoveRow.bind(this));
                        };
                        constructor.prototype.handleCmdRemoveRow = function (event) {
                            event.accept(new Promise(function (resolve) {
                                ModalElement.question({
                                    title: LanguageModule.text("txt_warning"),
                                    message: "Bạn có muốn xóa không?",
                                    onclick: function (sel) {
                                        if (sel == 0) {
                                            resolve(true);
                                        }
                                        else {
                                            resolve(false);
                                        }
                                    }
                                });
                            }))
                        };
                        constructor.prototype.handleCmdInsertRow = function (event) {
                            // var parentFrg = this.parentFragment;//laf cais form o ngoai
                            // var orgId = parentFrg.props.___.value;
                            var shareData = this.getContext("shareData");

                            var orgid;

                            if (shareData) {
                                orgid = shareData.orgid;
                            }

                            if (orgid && form.typeid == -25) event.resolve({type_select_position_orgid: {value: orgid}});
                            else event.resolve({});
                        };
                    }
                // }

                absol.form.AssemblerInstance.addConstructor(constructor);
                form.FragmentClass = constructor;
            });
            rs("success");
        }
        if (!mode) {
            form_module.defaultMobileOutputFormForPrimitiveType().then(function(primitiveForm){
                for (var i = primitiveForm.length - 1; i >= 0; i--){
                    primitiveForm[i].content = EncodingClass.string.toVariable(primitiveForm[i].content);
                    formList.unshift(primitiveForm[i]);
                }
                caculateFunc();
            });
        }
        else caculateFunc();
    });
};


hr.output_form_mobile.init = function (host) {
    if (window.ABSOL_DEBUG) console.trace(host);

    host.database = {};
    host.taskName = "m_output";
    /////////////////////////////////
    // Load người dùng, quốc gia, thành phố, form, kiểu dữ liệu
    var users = host.funcs.loadUsersList();
    var output_forms = host.funcs.loadFormList();
    var typelists = host.funcs.loadTypeList();
    var peoples = host.funcs.loadPeoplesList();
    var orgs = host.funcs.loadOrgsList();
    var employees = host.funcs.loadEmployeesList();
    var positions = host.funcs.loadPositionsList();
    var geographies = host.funcs.loadGeographiesList();
    host.isMobile = true;
    /////////////////////////////////
    Promise.all([users, output_forms, typelists, peoples, orgs, employees, positions, geographies]).then(function (result) {
        var content = {
            users: result[0],
            output_forms: result[1],
            typelists: result[2],
            peoples: result[3],
            orgs: result[4],
            employees: result[5],
            positions: result[6],
            geopos: result[7]
        };
        contentModule.makeDatabaseContent(host, content);
        contentModule.makeOrgsIndex(host);
        host.database.output_forms.items.forEach(function (elt) {
            elt.content = EncodingClass.string.toVariable(elt.content);
        });
        // host.database.typelists.items.forEach(function (elt) {
        //     contentModule.makeDataTypeDecode(elt);
        // });
        //////////////////////////////
        hr.output_form_mobile.loadFormConstructorToAssembler(host.database.output_forms.items, host.database.typelists.items).then(function(){
            host.database.output_forms.items.sort(function (a, b) {
                if (absol.string.nonAccentVietnamese(a.name).toLowerCase() < absol.string.nonAccentVietnamese(b.name).toLowerCase()) return -1;
                if (absol.string.nonAccentVietnamese(a.name).toLowerCase() > absol.string.nonAccentVietnamese(b.name).toLowerCase()) return 1;
                return 0;
            });
            hr.output_form_mobile.emittor.emit('form_load', { formList: host.database.output_forms.items });
            // Tạo form và gắn form
            // Plugin viết trong file FunctionEditor.js
            // Các hàm thêm sửa xóa form viết trong file form_module.js
            host.formEditor = new absol.form.FormEditor();
            host.formEditor.getView()
            .addStyle({
                width: '100%',
                height: '100%'
            }).addTo(host.holder);
            host.formEditor.setContext("HOST", host);
            host.formEditor.start();
            host.holder.on('deactive', function () {
                host.formEditor.pause();
            });

            host.holder.on('active', function () {
                host.formEditor.start();
            });

            host.holder.on('remove', function () {
                host.formEditor.destroy();
            });
        });
        ///////////////////////////
    }, function (rj_mes) {
        console.log(rj_mes);
    });
}

VaKeR 2022