![]() 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/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-form/js/frame/BlocklyDataModel.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _FDataModel = _interopRequireDefault(require("../launcher/FDataModel")); var _LoadingCubeModal = _interopRequireDefault(require("absol-acomp/js/LoadingCubeModal")); /*** * @extends FDataModel * @constructor */ function BlocklyDataModel() { _FDataModel.default.apply(this, arguments); this.runningTasks = []; this.cache = {}; this.callTask = window.callTask || this.callTask; this.typeDescriptorsCache = null; } BlocklyDataModel.prototype.callTask = function (callee, args) { //for test only var txt = `return ${callee}(${args.map(arg => absol.generateJSVariable(arg)).join(', ')})`; return new Function(txt)(); }; BlocklyDataModel.prototype.getPackageTreeList = function () { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.getPackageTreeList', []).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.getExploreTree = function () {}; BlocklyDataModel.prototype.loadNodeById = function (id) { var task = this.newTask(); return this.callTask('data_module.loadSCLangNodeById', [id]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.saveNewPackage = function (name, description) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.saveNewPackage', [name, description]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.saveNewSystemPackage = function (name, description) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.saveNewSystemPackage', [name, description]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.saveNewSubpackage = function (parentId, name, description) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.saveNewSubpackage', [parentId, name, description]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.saveNewSystemSubpackage = function (parentId, name, description) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.saveNewSystemSubpackage', [parentId, name, description]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.deletePackage = function (id) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.deletePackage', [id]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.deleteSystemPackage = function (id) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.deleteSystemPackage', [id]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.deletePackageList = function (idList) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.deletePackageList', [idList]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.deleteSystemPackageList = function (idList) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.deleteSystemPackageList', [idList]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.saveNewNode = function (packageId, type, name, description) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.saveNewNode', [packageId, type, name, description]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.saveNewSystemNode = function (packageId, type, name, description) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.saveNewSystemNode', [packageId, type, name, description]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.deleteNode = function (id) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.deleteNode', [id]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.deleteSystemNode = function (id) { var task = this.newTask(); this.cache = {}; return this.callTask('hr.sclang.deleteNodeSystem', [id]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.getTypeDescriptors = function () { var task; if (!this.typeDescriptorsCache) { task = this.newTask(); this.typeDescriptorsCache = this.callTask('contentModule.getTypeList', []).then(typeList => { var sync = typeList.map(id => this.callTask('contentModule.getTypeDescriptor', [id])); return Promise.all(sync).then(descriptorList => { return typeList.reduce((ac, cr, i) => { ac[cr] = descriptorList[i]; return ac; }, {}); }); }).then(result => { task.finish(); return result; }); } return this.typeDescriptorsCache; }; BlocklyDataModel.prototype.updateNode = function (id, modifiedData) { var task = this.newTask(); return this.callTask('hr.sclang.updateNode', [id, modifiedData]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.updateSystemNode = function (id, modifiedData) { var task = this.newTask(); return this.callTask('hr.sclang.updateSystemNode', [id, modifiedData]).then(result => { task.finish(); return result; }); }; BlocklyDataModel.prototype.newTask = function () { var task = {}; task.finish = () => { var idx = this.runningTasks.indexOf(task); if (idx < 0) return; this.runningTasks.splice(idx, 1); if (this.runningTasks.length === 0) { if (window.ModalElement && window.ModalElement.close) { window.ModalElement.close(); } else { _LoadingCubeModal.default.close(this._loadingToken); } } }; if (this.runningTasks.length === 0) { if (window.ModalElement && window.ModalElement.show_loading) { window.ModalElement.show_loading(); } else { this._loadingToken = _LoadingCubeModal.default.show(); } } this.runningTasks.push(task); return task; }; var _default = BlocklyDataModel; exports.default = _default;